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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 GURL::GURL(const char* canonical_spec, | 91 GURL::GURL(const char* canonical_spec, |
92 size_t canonical_spec_len, | 92 size_t canonical_spec_len, |
93 const url::Parsed& parsed, | 93 const url::Parsed& parsed, |
94 bool is_valid) | 94 bool is_valid) |
95 : spec_(canonical_spec, canonical_spec_len), | 95 : spec_(canonical_spec, canonical_spec_len), |
96 is_valid_(is_valid), | 96 is_valid_(is_valid), |
97 parsed_(parsed) { | 97 parsed_(parsed) { |
98 InitializeFromCanonicalSpec(); | 98 InitializeFromCanonicalSpec(); |
99 } | 99 } |
100 | 100 |
101 GURL::GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid) | 101 GURL::GURL(const std::string& canonical_spec, |
102 : is_valid_(is_valid), | 102 const url::Parsed& parsed, |
| 103 bool is_valid) |
| 104 : spec_(canonical_spec), |
| 105 is_valid_(is_valid), |
103 parsed_(parsed) { | 106 parsed_(parsed) { |
104 spec_.swap(canonical_spec); | |
105 InitializeFromCanonicalSpec(); | 107 InitializeFromCanonicalSpec(); |
106 } | 108 } |
107 | 109 |
| 110 GURL::GURL(std::string&& canonical_spec, |
| 111 const url::Parsed& parsed, |
| 112 bool is_valid) noexcept |
| 113 : spec_(std::move(canonical_spec)), |
| 114 is_valid_(is_valid), |
| 115 parsed_(parsed) { |
| 116 InitializeFromCanonicalSpec(); |
| 117 } |
| 118 |
108 template<typename STR> | 119 template<typename STR> |
109 void GURL::InitCanonical(const STR& input_spec, bool trim_path_end) { | 120 void GURL::InitCanonical(const STR& input_spec, bool trim_path_end) { |
110 // Reserve enough room in the output for the input, plus some extra so that | 121 // Reserve enough room in the output for the input, plus some extra so that |
111 // we have room if we have to escape a few things without reallocating. | 122 // we have room if we have to escape a few things without reallocating. |
112 spec_.reserve(input_spec.size() + 32); | 123 spec_.reserve(input_spec.size() + 32); |
113 url::StdStringCanonOutput output(&spec_); | 124 url::StdStringCanonOutput output(&spec_); |
114 is_valid_ = url::Canonicalize( | 125 is_valid_ = url::Canonicalize( |
115 input_spec.data(), static_cast<int>(input_spec.length()), trim_path_end, | 126 input_spec.data(), static_cast<int>(input_spec.length()), trim_path_end, |
116 NULL, &output, &parsed_); | 127 NULL, &output, &parsed_); |
117 | 128 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 void GURL::Swap(GURL* other) { | 541 void GURL::Swap(GURL* other) { |
531 spec_.swap(other->spec_); | 542 spec_.swap(other->spec_); |
532 std::swap(is_valid_, other->is_valid_); | 543 std::swap(is_valid_, other->is_valid_); |
533 std::swap(parsed_, other->parsed_); | 544 std::swap(parsed_, other->parsed_); |
534 inner_url_.swap(other->inner_url_); | 545 inner_url_.swap(other->inner_url_); |
535 } | 546 } |
536 | 547 |
537 std::ostream& operator<<(std::ostream& out, const GURL& url) { | 548 std::ostream& operator<<(std::ostream& out, const GURL& url) { |
538 return out << url.possibly_invalid_spec(); | 549 return out << url.possibly_invalid_spec(); |
539 } | 550 } |
OLD | NEW |