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

Side by Side Diff: url/gurl.cc

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Rebase. Created 3 years, 10 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
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 #include "url/gurl.h" 5 #include "url/gurl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <ostream> 10 #include <ostream>
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 bool GURL::DomainIs(base::StringPiece lower_ascii_domain) const { 460 bool GURL::DomainIs(base::StringPiece lower_ascii_domain) const {
461 if (!is_valid_) 461 if (!is_valid_)
462 return false; 462 return false;
463 463
464 // FileSystem URLs have empty host_piece, so check this first. 464 // FileSystem URLs have empty host_piece, so check this first.
465 if (SchemeIsFileSystem() && inner_url_) 465 if (SchemeIsFileSystem() && inner_url_)
466 return inner_url_->DomainIs(lower_ascii_domain); 466 return inner_url_->DomainIs(lower_ascii_domain);
467 return url::DomainIs(host_piece(), lower_ascii_domain); 467 return url::DomainIs(host_piece(), lower_ascii_domain);
468 } 468 }
469 469
470 // static
471 bool GURL::EqualsIgnoringRef(const GURL& x, const GURL& y) {
472 int ref_position_x = x.parsed_.CountCharactersBefore(url::Parsed::REF, true);
473 int ref_position_y = y.parsed_.CountCharactersBefore(url::Parsed::REF, true);
474 return base::StringPiece(x.spec_).substr(0, ref_position_x) ==
475 base::StringPiece(y.spec_).substr(0, ref_position_y);
476 }
477
470 void GURL::Swap(GURL* other) { 478 void GURL::Swap(GURL* other) {
471 spec_.swap(other->spec_); 479 spec_.swap(other->spec_);
472 std::swap(is_valid_, other->is_valid_); 480 std::swap(is_valid_, other->is_valid_);
473 std::swap(parsed_, other->parsed_); 481 std::swap(parsed_, other->parsed_);
474 inner_url_.swap(other->inner_url_); 482 inner_url_.swap(other->inner_url_);
475 } 483 }
476 484
477 std::ostream& operator<<(std::ostream& out, const GURL& url) { 485 std::ostream& operator<<(std::ostream& out, const GURL& url) {
478 return out << url.possibly_invalid_spec(); 486 return out << url.possibly_invalid_spec();
479 } 487 }
480 488
481 bool operator==(const GURL& x, const GURL& y) { 489 bool operator==(const GURL& x, const GURL& y) {
482 return x.possibly_invalid_spec() == y.possibly_invalid_spec(); 490 return x.possibly_invalid_spec() == y.possibly_invalid_spec();
483 } 491 }
484 492
485 bool operator!=(const GURL& x, const GURL& y) { 493 bool operator!=(const GURL& x, const GURL& y) {
486 return !(x == y); 494 return !(x == y);
487 } 495 }
488 496
489 bool operator==(const GURL& x, const base::StringPiece& spec) { 497 bool operator==(const GURL& x, const base::StringPiece& spec) {
490 DCHECK_EQ(GURL(spec).possibly_invalid_spec(), spec); 498 DCHECK_EQ(GURL(spec).possibly_invalid_spec(), spec);
491 return x.possibly_invalid_spec() == spec; 499 return x.possibly_invalid_spec() == spec;
492 } 500 }
493 501
494 bool operator!=(const GURL& x, const base::StringPiece& spec) { 502 bool operator!=(const GURL& x, const base::StringPiece& spec) {
495 return !(x == spec); 503 return !(x == spec);
496 } 504 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698