summaryrefslogtreecommitdiffstats
path: root/url
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-06-09 15:39:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-09 22:39:37 +0000
commitbc17d2c8d864a118f48a84de0709f5a6c463cffd (patch)
tree1b22817d8ab1d8797b14d734f0f2924c4db1736b /url
parent952985e3821fea40f284004cae13795f8a3db489 (diff)
downloadchromium_src-bc17d2c8d864a118f48a84de0709f5a6c463cffd.zip
chromium_src-bc17d2c8d864a118f48a84de0709f5a6c463cffd.tar.gz
chromium_src-bc17d2c8d864a118f48a84de0709f5a6c463cffd.tar.bz2
Move LowerCaseEqualsASCII to base namespace
Remove url:: variants. Add the 4-element version from url:: to base:: Review URL: https://codereview.chromium.org/1172753003 Cr-Commit-Position: refs/heads/master@{#333597}
Diffstat (limited to 'url')
-rw-r--r--url/gurl.cc15
-rw-r--r--url/url_util.cc53
-rw-r--r--url/url_util.h17
3 files changed, 14 insertions, 71 deletions
diff --git a/url/gurl.cc b/url/gurl.cc
index 46ca408..52aad73 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -14,6 +14,7 @@
#include "url/gurl.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "url/url_canon_stdstring.h"
#include "url/url_util.h"
@@ -382,9 +383,9 @@ bool GURL::IsStandard() const {
bool GURL::SchemeIs(const char* lower_ascii_scheme) const {
if (parsed_.scheme.len <= 0)
return lower_ascii_scheme == NULL;
- return url::LowerCaseEqualsASCII(spec_.data() + parsed_.scheme.begin,
- spec_.data() + parsed_.scheme.end(),
- lower_ascii_scheme);
+ return base::LowerCaseEqualsASCII(spec_.data() + parsed_.scheme.begin,
+ spec_.data() + parsed_.scheme.end(),
+ lower_ascii_scheme);
}
bool GURL::SchemeIsHTTPOrHTTPS() const {
@@ -521,10 +522,10 @@ bool GURL::DomainIs(const char* lower_ascii_domain,
const char* start_pos = spec_.data() + parsed_.host.begin +
host_len - domain_len;
- if (!url::LowerCaseEqualsASCII(start_pos,
- last_pos + 1,
- lower_ascii_domain,
- lower_ascii_domain + domain_len))
+ if (!base::LowerCaseEqualsASCII(start_pos,
+ last_pos + 1,
+ lower_ascii_domain,
+ lower_ascii_domain + domain_len))
return false;
// Check whether host has right domain start with dot, make sure we got
diff --git a/url/url_util.cc b/url/url_util.cc
index 008a5e4..28a8931 100644
--- a/url/url_util.cc
+++ b/url/url_util.cc
@@ -9,6 +9,7 @@
#include "base/debug/leak_annotations.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "url/url_canon_internal.h"
#include "url/url_file.h"
#include "url/url_util_internal.h"
@@ -17,23 +18,6 @@ namespace url {
namespace {
-// ASCII-specific tolower. The standard library's tolower is locale sensitive,
-// so we don't want to use it here.
-template<class Char>
-inline Char ToLowerASCII(Char c) {
- return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
-}
-
-// Backend for LowerCaseEqualsASCII.
-template<typename Iter>
-inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char* b) {
- for (Iter it = a_begin; it != a_end; ++it, ++b) {
- if (!*b || ToLowerASCII(*it) != *b)
- return false;
- }
- return *b == 0;
-}
-
const int kNumStandardURLSchemes = 8;
const char* kStandardURLSchemes[kNumStandardURLSchemes] = {
kHttpScheme,
@@ -72,9 +56,9 @@ inline bool DoCompareSchemeComponent(const CHAR* spec,
const char* compare_to) {
if (!component.is_nonempty())
return compare_to[0] == 0; // When component is empty, match empty scheme.
- return LowerCaseEqualsASCII(&spec[component.begin],
- &spec[component.end()],
- compare_to);
+ return base::LowerCaseEqualsASCII(&spec[component.begin],
+ &spec[component.end()],
+ compare_to);
}
// Returns true if the given scheme identified by |scheme| within |spec| is one
@@ -86,8 +70,8 @@ bool DoIsStandard(const CHAR* spec, const Component& scheme) {
InitStandardSchemes();
for (size_t i = 0; i < standard_schemes->size(); i++) {
- if (LowerCaseEqualsASCII(&spec[scheme.begin], &spec[scheme.end()],
- standard_schemes->at(i)))
+ if (base::LowerCaseEqualsASCII(&spec[scheme.begin], &spec[scheme.end()],
+ standard_schemes->at(i)))
return true;
}
return false;
@@ -486,31 +470,6 @@ bool ReplaceComponents(const char* spec,
charset_converter, output, out_parsed);
}
-// Front-ends for LowerCaseEqualsASCII.
-bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
-}
-
-bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b_begin,
- const char* b_end) {
- while (a_begin != a_end && b_begin != b_end &&
- ToLowerASCII(*a_begin) == *b_begin) {
- a_begin++;
- b_begin++;
- }
- return a_begin == a_end && b_begin == b_end;
-}
-
-bool LowerCaseEqualsASCII(const base::char16* a_begin,
- const base::char16* a_end,
- const char* b) {
- return DoLowerCaseEqualsASCII(a_begin, a_end, b);
-}
-
void DecodeURLEscapeSequences(const char* input,
int length,
CanonOutputW* output) {
diff --git a/url/url_util.h b/url/url_util.h
index bf05e87..55a83eb 100644
--- a/url/url_util.h
+++ b/url/url_util.h
@@ -166,23 +166,6 @@ URL_EXPORT bool ReplaceComponents(
// String helper functions ----------------------------------------------------
-// Compare the lower-case form of the given string against the given ASCII
-// string. This is useful for doing checking if an input string matches some
-// token, and it is optimized to avoid intermediate string copies.
-//
-// The versions of this function that don't take a b_end assume that the b
-// string is NULL terminated.
-URL_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b);
-URL_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b_begin,
- const char* b_end);
-URL_EXPORT bool LowerCaseEqualsASCII(const base::char16* a_begin,
- const base::char16* a_end,
- const char* b);
-
// Unescapes the given string using URL escaping rules.
URL_EXPORT void DecodeURLEscapeSequences(const char* input,
int length,