Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: url/gurl.cc

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | url/url_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifdef WIN32 5 #ifdef WIN32
6 #include <windows.h> 6 #include <windows.h>
7 #else 7 #else
8 #include <pthread.h> 8 #include <pthread.h>
9 #endif 9 #endif
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <ostream> 12 #include <ostream>
13 13
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/strings/string_util.h"
17 #include "url/url_canon_stdstring.h" 18 #include "url/url_canon_stdstring.h"
18 #include "url/url_util.h" 19 #include "url/url_util.h"
19 20
20 namespace { 21 namespace {
21 22
22 static std::string* empty_string = NULL; 23 static std::string* empty_string = NULL;
23 static GURL* empty_gurl = NULL; 24 static GURL* empty_gurl = NULL;
24 25
25 #ifdef WIN32 26 #ifdef WIN32
26 27
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 return other; 376 return other;
376 } 377 }
377 378
378 bool GURL::IsStandard() const { 379 bool GURL::IsStandard() const {
379 return url::IsStandard(spec_.data(), parsed_.scheme); 380 return url::IsStandard(spec_.data(), parsed_.scheme);
380 } 381 }
381 382
382 bool GURL::SchemeIs(const char* lower_ascii_scheme) const { 383 bool GURL::SchemeIs(const char* lower_ascii_scheme) const {
383 if (parsed_.scheme.len <= 0) 384 if (parsed_.scheme.len <= 0)
384 return lower_ascii_scheme == NULL; 385 return lower_ascii_scheme == NULL;
385 return url::LowerCaseEqualsASCII(spec_.data() + parsed_.scheme.begin, 386 return base::LowerCaseEqualsASCII(spec_.data() + parsed_.scheme.begin,
386 spec_.data() + parsed_.scheme.end(), 387 spec_.data() + parsed_.scheme.end(),
387 lower_ascii_scheme); 388 lower_ascii_scheme);
388 } 389 }
389 390
390 bool GURL::SchemeIsHTTPOrHTTPS() const { 391 bool GURL::SchemeIsHTTPOrHTTPS() const {
391 return SchemeIs(url::kHttpScheme) || SchemeIs(url::kHttpsScheme); 392 return SchemeIs(url::kHttpScheme) || SchemeIs(url::kHttpsScheme);
392 } 393 }
393 394
394 bool GURL::SchemeIsWSOrWSS() const { 395 bool GURL::SchemeIsWSOrWSS() const {
395 return SchemeIs(url::kWsScheme) || SchemeIs(url::kWssScheme); 396 return SchemeIs(url::kWsScheme) || SchemeIs(url::kWssScheme);
396 } 397 }
397 398
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 515 }
515 516
516 // Return false if host's length is less than domain's length. 517 // Return false if host's length is less than domain's length.
517 if (host_len < domain_len) 518 if (host_len < domain_len)
518 return false; 519 return false;
519 520
520 // Compare this url whether belong specific domain. 521 // Compare this url whether belong specific domain.
521 const char* start_pos = spec_.data() + parsed_.host.begin + 522 const char* start_pos = spec_.data() + parsed_.host.begin +
522 host_len - domain_len; 523 host_len - domain_len;
523 524
524 if (!url::LowerCaseEqualsASCII(start_pos, 525 if (!base::LowerCaseEqualsASCII(start_pos,
525 last_pos + 1, 526 last_pos + 1,
526 lower_ascii_domain, 527 lower_ascii_domain,
527 lower_ascii_domain + domain_len)) 528 lower_ascii_domain + domain_len))
528 return false; 529 return false;
529 530
530 // Check whether host has right domain start with dot, make sure we got 531 // Check whether host has right domain start with dot, make sure we got
531 // right domain range. For example www.google.com has domain 532 // right domain range. For example www.google.com has domain
532 // "google.com" but www.iamnotgoogle.com does not. 533 // "google.com" but www.iamnotgoogle.com does not.
533 if ('.' != lower_ascii_domain[0] && host_len > domain_len && 534 if ('.' != lower_ascii_domain[0] && host_len > domain_len &&
534 '.' != *(start_pos - 1)) 535 '.' != *(start_pos - 1))
535 return false; 536 return false;
536 537
537 return true; 538 return true;
538 } 539 }
539 540
540 void GURL::Swap(GURL* other) { 541 void GURL::Swap(GURL* other) {
541 spec_.swap(other->spec_); 542 spec_.swap(other->spec_);
542 std::swap(is_valid_, other->is_valid_); 543 std::swap(is_valid_, other->is_valid_);
543 std::swap(parsed_, other->parsed_); 544 std::swap(parsed_, other->parsed_);
544 inner_url_.swap(other->inner_url_); 545 inner_url_.swap(other->inner_url_);
545 } 546 }
546 547
547 std::ostream& operator<<(std::ostream& out, const GURL& url) { 548 std::ostream& operator<<(std::ostream& out, const GURL& url) {
548 return out << url.possibly_invalid_spec(); 549 return out << url.possibly_invalid_spec();
549 } 550 }
OLDNEW
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | url/url_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698