Chromium Code Reviews| 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 #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 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 #endif | 164 #endif |
| 165 } | 165 } |
| 166 | 166 |
| 167 GURL::~GURL() { | 167 GURL::~GURL() { |
| 168 delete inner_url_; | 168 delete inner_url_; |
| 169 } | 169 } |
| 170 | 170 |
| 171 GURL& GURL::operator=(const GURL& other) { | 171 GURL& GURL::operator=(const GURL& other) { |
| 172 if (&other == this) | 172 GURL copy(other); |
|
cjhopman
2013/10/22 17:14:01
This is less subtle than taking the thing by value
akalin
2013/10/22 17:56:41
http://gotw.ca/gotw/059.htm uses your way so I'm i
Jeffrey Yasskin
2013/10/22 18:02:54
Taking GURL by value saves a copy when the argumen
cjhopman
2013/10/22 19:03:44
Done.
| |
| 173 return *this; | 173 Swap(©); |
| 174 | |
| 175 spec_ = other.spec_; | |
| 176 is_valid_ = other.is_valid_; | |
| 177 parsed_ = other.parsed_; | |
| 178 delete inner_url_; | |
| 179 inner_url_ = NULL; | |
| 180 if (other.inner_url_) | |
| 181 inner_url_ = new GURL(*other.inner_url_); | |
| 182 // Valid filesystem urls should always have an inner_url_. | |
| 183 DCHECK(!is_valid_ || !SchemeIsFileSystem() || inner_url_); | |
| 184 return *this; | 174 return *this; |
| 185 } | 175 } |
| 186 | 176 |
| 187 const std::string& GURL::spec() const { | 177 const std::string& GURL::spec() const { |
| 188 if (is_valid_ || spec_.empty()) | 178 if (is_valid_ || spec_.empty()) |
| 189 return spec_; | 179 return spec_; |
| 190 | 180 |
| 191 DCHECK(false) << "Trying to get the spec of an invalid URL!"; | 181 DCHECK(false) << "Trying to get the spec of an invalid URL!"; |
| 192 return EmptyStringForGURL(); | 182 return EmptyStringForGURL(); |
| 193 } | 183 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 void GURL::Swap(GURL* other) { | 505 void GURL::Swap(GURL* other) { |
| 516 spec_.swap(other->spec_); | 506 spec_.swap(other->spec_); |
| 517 std::swap(is_valid_, other->is_valid_); | 507 std::swap(is_valid_, other->is_valid_); |
| 518 std::swap(parsed_, other->parsed_); | 508 std::swap(parsed_, other->parsed_); |
| 519 std::swap(inner_url_, other->inner_url_); | 509 std::swap(inner_url_, other->inner_url_); |
| 520 } | 510 } |
| 521 | 511 |
| 522 std::ostream& operator<<(std::ostream& out, const GURL& url) { | 512 std::ostream& operator<<(std::ostream& out, const GURL& url) { |
| 523 return out << url.possibly_invalid_spec(); | 513 return out << url.possibly_invalid_spec(); |
| 524 } | 514 } |
| OLD | NEW |