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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return result; | 151 return result; |
152 | 152 |
153 // Omit the port component if the port matches with the default port | 153 // Omit the port component if the port matches with the default port |
154 // defined for the scheme, if any. | 154 // defined for the scheme, if any. |
155 int default_port = DefaultPortForScheme(scheme_.data(), | 155 int default_port = DefaultPortForScheme(scheme_.data(), |
156 static_cast<int>(scheme_.length())); | 156 static_cast<int>(scheme_.length())); |
157 if (default_port == PORT_UNSPECIFIED) | 157 if (default_port == PORT_UNSPECIFIED) |
158 return result; | 158 return result; |
159 if (port_ != default_port) { | 159 if (port_ != default_port) { |
160 result.push_back(':'); | 160 result.push_back(':'); |
161 result.append(base::IntToString(port_)); | 161 result.append(base::UintToString(port_)); |
162 } | 162 } |
163 | 163 |
164 return result; | 164 return result; |
165 } | 165 } |
166 | 166 |
167 bool SchemeHostPort::Equals(const SchemeHostPort& other) const { | 167 bool SchemeHostPort::Equals(const SchemeHostPort& other) const { |
168 return port_ == other.port() && scheme_ == other.scheme() && | 168 return port_ == other.port() && scheme_ == other.scheme() && |
169 host_ == other.host(); | 169 host_ == other.host(); |
170 } | 170 } |
171 | 171 |
172 bool SchemeHostPort::operator<(const SchemeHostPort& other) const { | 172 bool SchemeHostPort::operator<(const SchemeHostPort& other) const { |
173 if (port_ != other.port_) | 173 if (port_ != other.port_) |
174 return port_ < other.port_; | 174 return port_ < other.port_; |
175 if (scheme_ != other.scheme_) | 175 if (scheme_ != other.scheme_) |
176 return scheme_ < other.scheme_; | 176 return scheme_ < other.scheme_; |
177 if (host_ != other.host_) | 177 if (host_ != other.host_) |
178 return host_ < other.host_; | 178 return host_ < other.host_; |
179 return false; | 179 return false; |
180 } | 180 } |
181 | 181 |
182 } // namespace url | 182 } // namespace url |
OLD | NEW |