OLD | NEW |
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 bool GURL::DomainIs(base::StringPiece lower_ascii_domain) const { | 461 bool GURL::DomainIs(base::StringPiece lower_ascii_domain) const { |
462 if (!is_valid_) | 462 if (!is_valid_) |
463 return false; | 463 return false; |
464 | 464 |
465 // FileSystem URLs have empty host_piece, so check this first. | 465 // FileSystem URLs have empty host_piece, so check this first. |
466 if (SchemeIsFileSystem() && inner_url_) | 466 if (SchemeIsFileSystem() && inner_url_) |
467 return inner_url_->DomainIs(lower_ascii_domain); | 467 return inner_url_->DomainIs(lower_ascii_domain); |
468 return url::DomainIs(host_piece(), lower_ascii_domain); | 468 return url::DomainIs(host_piece(), lower_ascii_domain); |
469 } | 469 } |
470 | 470 |
| 471 bool GURL::EqualsIgnoringRef(const GURL& other) const { |
| 472 int ref_position = parsed_.CountCharactersBefore(url::Parsed::REF, true); |
| 473 int ref_position_other = |
| 474 other.parsed_.CountCharactersBefore(url::Parsed::REF, true); |
| 475 return base::StringPiece(spec_).substr(0, ref_position) == |
| 476 base::StringPiece(other.spec_).substr(0, ref_position_other); |
| 477 } |
| 478 |
471 void GURL::Swap(GURL* other) { | 479 void GURL::Swap(GURL* other) { |
472 spec_.swap(other->spec_); | 480 spec_.swap(other->spec_); |
473 std::swap(is_valid_, other->is_valid_); | 481 std::swap(is_valid_, other->is_valid_); |
474 std::swap(parsed_, other->parsed_); | 482 std::swap(parsed_, other->parsed_); |
475 inner_url_.swap(other->inner_url_); | 483 inner_url_.swap(other->inner_url_); |
476 } | 484 } |
477 | 485 |
478 size_t GURL::EstimateMemoryUsage() const { | 486 size_t GURL::EstimateMemoryUsage() const { |
479 return base::trace_event::EstimateMemoryUsage(spec_) + | 487 return base::trace_event::EstimateMemoryUsage(spec_) + |
480 base::trace_event::EstimateMemoryUsage(inner_url_) + | 488 base::trace_event::EstimateMemoryUsage(inner_url_) + |
(...skipping 13 matching lines...) Expand all Loading... |
494 } | 502 } |
495 | 503 |
496 bool operator==(const GURL& x, const base::StringPiece& spec) { | 504 bool operator==(const GURL& x, const base::StringPiece& spec) { |
497 DCHECK_EQ(GURL(spec).possibly_invalid_spec(), spec); | 505 DCHECK_EQ(GURL(spec).possibly_invalid_spec(), spec); |
498 return x.possibly_invalid_spec() == spec; | 506 return x.possibly_invalid_spec() == spec; |
499 } | 507 } |
500 | 508 |
501 bool operator!=(const GURL& x, const base::StringPiece& spec) { | 509 bool operator!=(const GURL& x, const base::StringPiece& spec) { |
502 return !(x == spec); | 510 return !(x == spec); |
503 } | 511 } |
OLD | NEW |