Skip to content

Commit

Permalink
Replace some hard coded schemes with the constants in /url/url_consta…
Browse files Browse the repository at this point in the history
…nts.h.

BUG=none
TEST=compile

Review URL: https://codereview.chromium.org/335353002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277979 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sungmann.cho@navercorp.com committed Jun 18, 2014
1 parent afbed27 commit 08dc705
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion url/gurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void GURL::InitializeFromCanonicalSpec() {
// canonical_spec actually points to the start of the outer URL, so we'd
// end up with infinite recursion in this constructor.
if (!url::FindAndCompareScheme(spec_.data(), spec_.length(),
"filesystem", &scheme) ||
url::kFileSystemScheme, &scheme) ||
scheme.begin == parsed_.scheme.begin) {
// We need to retain trailing whitespace on path URLs, as the |parsed_|
// spec we originally received may legitimately contain trailing white-
Expand Down
4 changes: 2 additions & 2 deletions url/gurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ class URL_EXPORT GURL {
// We often need to know if this is a file URL. File URLs are "standard", but
// are often treated separately by some programs.
bool SchemeIsFile() const {
return SchemeIs("file");
return SchemeIs(url::kFileScheme);
}

// FileSystem URLs need to be treated differently in some cases.
bool SchemeIsFileSystem() const {
return SchemeIs("filesystem");
return SchemeIs(url::kFileSystemScheme);
}

// If the scheme indicates a secure connection
Expand Down
3 changes: 2 additions & 1 deletion url/url_canon_relative.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/logging.h"
#include "url/url_canon.h"
#include "url/url_canon_internal.h"
#include "url/url_constants.h"
#include "url/url_file.h"
#include "url/url_parse_internal.h"
#include "url/url_util_internal.h"
Expand Down Expand Up @@ -145,7 +146,7 @@ bool DoIsRelativeURL(const char* base,

// If it's a filesystem URL, the only valid way to make it relative is not to
// supply a scheme. There's no equivalent to e.g. http:index.html.
if (CompareSchemeComponent(url, scheme, "filesystem"))
if (CompareSchemeComponent(url, scheme, kFileSystemScheme))
return true;

// ExtractScheme guarantees that the colon immediately follows what it
Expand Down
13 changes: 7 additions & 6 deletions url/url_canon_stdurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "url/url_canon.h"
#include "url/url_canon_internal.h"
#include "url/url_constants.h"

namespace url {

Expand Down Expand Up @@ -98,25 +99,25 @@ int DefaultPortForScheme(const char* scheme, int scheme_len) {
int default_port = PORT_UNSPECIFIED;
switch (scheme_len) {
case 4:
if (!strncmp(scheme, "http", scheme_len))
if (!strncmp(scheme, kHttpScheme, scheme_len))
default_port = 80;
break;
case 5:
if (!strncmp(scheme, "https", scheme_len))
if (!strncmp(scheme, kHttpsScheme, scheme_len))
default_port = 443;
break;
case 3:
if (!strncmp(scheme, "ftp", scheme_len))
if (!strncmp(scheme, kFtpScheme, scheme_len))
default_port = 21;
else if (!strncmp(scheme, "wss", scheme_len))
else if (!strncmp(scheme, kWssScheme, scheme_len))
default_port = 443;
break;
case 6:
if (!strncmp(scheme, "gopher", scheme_len))
if (!strncmp(scheme, kGopherScheme, scheme_len))
default_port = 70;
break;
case 2:
if (!strncmp(scheme, "ws", scheme_len))
if (!strncmp(scheme, kWsScheme, scheme_len))
default_port = 80;
break;
}
Expand Down
1 change: 1 addition & 0 deletions url/url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const char kDataScheme[] = "data";
const char kFileScheme[] = "file";
const char kFileSystemScheme[] = "filesystem";
const char kFtpScheme[] = "ftp";
const char kGopherScheme[] = "gopher";
const char kHttpScheme[] = "http";
const char kHttpsScheme[] = "https";
const char kJavaScriptScheme[] = "javascript";
Expand Down
1 change: 1 addition & 0 deletions url/url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ URL_EXPORT extern const char kDataScheme[];
URL_EXPORT extern const char kFileScheme[];
URL_EXPORT extern const char kFileSystemScheme[];
URL_EXPORT extern const char kFtpScheme[];
URL_EXPORT extern const char kGopherScheme[];
URL_EXPORT extern const char kHttpScheme[];
URL_EXPORT extern const char kHttpsScheme[];
URL_EXPORT extern const char kJavaScriptScheme[];
Expand Down
12 changes: 6 additions & 6 deletions url/url_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char* b) {

const int kNumStandardURLSchemes = 8;
const char* kStandardURLSchemes[kNumStandardURLSchemes] = {
"http",
"https",
kHttpScheme,
kHttpsScheme,
kFileScheme, // Yes, file urls can have a hostname!
"ftp",
"gopher",
"ws", // WebSocket.
"wss", // WebSocket secure.
kFtpScheme,
kGopherScheme,
kWsScheme, // WebSocket.
kWssScheme, // WebSocket secure.
kFileSystemScheme,
};

Expand Down

0 comments on commit 08dc705

Please sign in to comment.