| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/scheme_host_port.h" | 5 #include "url/scheme_host_port.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 NOTREACHED(); | 109 NOTREACHED(); |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace | 114 } // namespace |
| 115 | 115 |
| 116 SchemeHostPort::SchemeHostPort() : port_(0) { | 116 SchemeHostPort::SchemeHostPort() : port_(0) { |
| 117 } | 117 } |
| 118 | 118 |
| 119 SchemeHostPort::SchemeHostPort(base::StringPiece scheme, | 119 SchemeHostPort::SchemeHostPort(std::string scheme, |
| 120 base::StringPiece host, | 120 std::string host, |
| 121 uint16_t port, | 121 uint16_t port, |
| 122 ConstructPolicy policy) | 122 ConstructPolicy policy) |
| 123 : port_(0) { | 123 : port_(0) { |
| 124 if (!IsValidInput(scheme, host, port, policy)) | 124 if (!IsValidInput(scheme, host, port, policy)) |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 scheme.CopyToString(&scheme_); | 127 scheme_ = std::move(scheme); |
| 128 host.CopyToString(&host_); | 128 host_ = std::move(host); |
| 129 port_ = port; | 129 port_ = port; |
| 130 } | 130 } |
| 131 | 131 |
| 132 SchemeHostPort::SchemeHostPort(base::StringPiece scheme, | 132 SchemeHostPort::SchemeHostPort(base::StringPiece scheme, |
| 133 base::StringPiece host, | 133 base::StringPiece host, |
| 134 uint16_t port) | 134 uint16_t port) |
| 135 : SchemeHostPort(scheme, | 135 : SchemeHostPort(scheme.as_string(), |
| 136 host, | 136 host.as_string(), |
| 137 port, | 137 port, |
| 138 ConstructPolicy::CHECK_CANONICALIZATION) {} | 138 ConstructPolicy::CHECK_CANONICALIZATION) {} |
| 139 | 139 |
| 140 SchemeHostPort::SchemeHostPort(const GURL& url) : port_(0) { | 140 SchemeHostPort::SchemeHostPort(const GURL& url) : port_(0) { |
| 141 if (!url.is_valid()) | 141 if (!url.is_valid()) |
| 142 return; | 142 return; |
| 143 | 143 |
| 144 base::StringPiece scheme = url.scheme_piece(); | 144 base::StringPiece scheme = url.scheme_piece(); |
| 145 base::StringPiece host = url.host_piece(); | 145 base::StringPiece host = url.host_piece(); |
| 146 | 146 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 result.push_back(':'); | 230 result.push_back(':'); |
| 231 std::string port(base::UintToString(port_)); | 231 std::string port(base::UintToString(port_)); |
| 232 parsed->port = Component(result.length(), port.length()); | 232 parsed->port = Component(result.length(), port.length()); |
| 233 result.append(std::move(port)); | 233 result.append(std::move(port)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 return result; | 236 return result; |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace url | 239 } // namespace url |
| OLD | NEW |