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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 | 174 |
175 const std::string& GURL::spec() const { | 175 const std::string& GURL::spec() const { |
176 if (is_valid_ || spec_.empty()) | 176 if (is_valid_ || spec_.empty()) |
177 return spec_; | 177 return spec_; |
178 | 178 |
179 DCHECK(false) << "Trying to get the spec of an invalid URL!"; | 179 DCHECK(false) << "Trying to get the spec of an invalid URL!"; |
180 return EmptyStringForGURL(); | 180 return EmptyStringForGURL(); |
181 } | 181 } |
182 | 182 |
183 bool GURL::operator==(const GURL& other) const { | |
184 return spec_ == other.spec_; | |
185 } | |
186 | |
187 bool GURL::operator!=(const GURL& other) const { | |
188 return spec_ != other.spec_; | |
189 } | |
190 | |
191 bool GURL::operator<(const GURL& other) const { | 183 bool GURL::operator<(const GURL& other) const { |
192 return spec_ < other.spec_; | 184 return spec_ < other.spec_; |
193 } | 185 } |
194 | 186 |
195 bool GURL::operator>(const GURL& other) const { | 187 bool GURL::operator>(const GURL& other) const { |
196 return spec_ > other.spec_; | 188 return spec_ > other.spec_; |
197 } | 189 } |
198 | 190 |
199 // Note: code duplicated below (it's inconvenient to use a template here). | 191 // Note: code duplicated below (it's inconvenient to use a template here). |
200 GURL GURL::Resolve(const std::string& relative) const { | 192 GURL GURL::Resolve(const std::string& relative) const { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 void GURL::Swap(GURL* other) { | 495 void GURL::Swap(GURL* other) { |
504 spec_.swap(other->spec_); | 496 spec_.swap(other->spec_); |
505 std::swap(is_valid_, other->is_valid_); | 497 std::swap(is_valid_, other->is_valid_); |
506 std::swap(parsed_, other->parsed_); | 498 std::swap(parsed_, other->parsed_); |
507 inner_url_.swap(other->inner_url_); | 499 inner_url_.swap(other->inner_url_); |
508 } | 500 } |
509 | 501 |
510 std::ostream& operator<<(std::ostream& out, const GURL& url) { | 502 std::ostream& operator<<(std::ostream& out, const GURL& url) { |
511 return out << url.possibly_invalid_spec(); | 503 return out << url.possibly_invalid_spec(); |
512 } | 504 } |
| 505 |
| 506 bool operator==(const GURL& x, const GURL& y) { |
| 507 return x.possibly_invalid_spec() == y.possibly_invalid_spec(); |
| 508 } |
| 509 |
| 510 bool operator!=(const GURL& x, const GURL& y) { |
| 511 return !(x == y); |
| 512 } |
| 513 |
| 514 bool operator==(const GURL& x, const base::StringPiece& spec) { |
| 515 return x.possibly_invalid_spec() == spec; |
| 516 } |
| 517 |
| 518 bool operator!=(const GURL& x, const base::StringPiece& spec) { |
| 519 return !(x == spec); |
| 520 } |
OLD | NEW |