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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 DCHECK(test_url.parsed_.query == parsed_.query); | 160 DCHECK(test_url.parsed_.query == parsed_.query); |
161 DCHECK(test_url.parsed_.ref == parsed_.ref); | 161 DCHECK(test_url.parsed_.ref == parsed_.ref); |
162 } | 162 } |
163 } | 163 } |
164 #endif | 164 #endif |
165 } | 165 } |
166 | 166 |
167 GURL::~GURL() { | 167 GURL::~GURL() { |
168 } | 168 } |
169 | 169 |
170 GURL& GURL::operator=(const GURL& other) { | 170 GURL& GURL::operator=(GURL other) { |
171 if (&other == this) | 171 Swap(&other); |
172 return *this; | |
173 | |
174 spec_ = other.spec_; | |
175 is_valid_ = other.is_valid_; | |
176 parsed_ = other.parsed_; | |
177 inner_url_.reset(NULL); | |
178 if (other.inner_url_) | |
179 inner_url_.reset(new GURL(*other.inner_url_)); | |
180 // Valid filesystem urls should always have an inner_url_. | |
181 DCHECK(!is_valid_ || !SchemeIsFileSystem() || inner_url_); | |
182 return *this; | 172 return *this; |
183 } | 173 } |
184 | 174 |
185 const std::string& GURL::spec() const { | 175 const std::string& GURL::spec() const { |
186 if (is_valid_ || spec_.empty()) | 176 if (is_valid_ || spec_.empty()) |
187 return spec_; | 177 return spec_; |
188 | 178 |
189 DCHECK(false) << "Trying to get the spec of an invalid URL!"; | 179 DCHECK(false) << "Trying to get the spec of an invalid URL!"; |
190 return EmptyStringForGURL(); | 180 return EmptyStringForGURL(); |
191 } | 181 } |
(...skipping 323 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 inner_url_.swap(other->inner_url_); | 509 inner_url_.swap(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 |