Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3576)

Side by Side Diff: url/scheme_host_port.cc

Issue 1858093002: Alt-Svc 8: Change Supports SPDY list using SHP as the key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alt_svc_7
Patch Set: server pref changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « url/scheme_host_port.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return; 130 return;
131 131
132 scheme.CopyToString(&scheme_); 132 scheme.CopyToString(&scheme_);
133 host.CopyToString(&host_); 133 host.CopyToString(&host_);
134 port_ = port; 134 port_ = port;
135 } 135 }
136 136
137 SchemeHostPort::~SchemeHostPort() { 137 SchemeHostPort::~SchemeHostPort() {
138 } 138 }
139 139
140 // static
141 SchemeHostPort SchemeHostPort::FromString(const std::string& url_string) {
142 GURL url(url_string);
143 return SchemeHostPort(url);
144 }
145
140 bool SchemeHostPort::IsInvalid() const { 146 bool SchemeHostPort::IsInvalid() const {
141 return scheme_.empty() && host_.empty() && !port_; 147 return scheme_.empty() && host_.empty() && !port_;
142 } 148 }
143 149
144 std::string SchemeHostPort::Serialize() const { 150 std::string SchemeHostPort::Serialize() const {
145 std::string result; 151 std::string result;
146 if (IsInvalid()) 152 if (IsInvalid())
147 return result; 153 return result;
148 154
149 result.append(scheme_); 155 result.append(scheme_);
(...skipping 10 matching lines...) Expand all
160 if (default_port == PORT_UNSPECIFIED) 166 if (default_port == PORT_UNSPECIFIED)
161 return result; 167 return result;
162 if (port_ != default_port) { 168 if (port_ != default_port) {
163 result.push_back(':'); 169 result.push_back(':');
164 result.append(base::UintToString(port_)); 170 result.append(base::UintToString(port_));
165 } 171 }
166 172
167 return result; 173 return result;
168 } 174 }
169 175
176 std::string SchemeHostPort::ToString() const {
177 std::string ret(scheme());
178 ret += "://";
179 ret += host();
180 ret += ':';
181 ret += base::UintToString(port());
182 return ret;
183 }
184
170 bool SchemeHostPort::Equals(const SchemeHostPort& other) const { 185 bool SchemeHostPort::Equals(const SchemeHostPort& other) const {
171 return port_ == other.port() && scheme_ == other.scheme() && 186 return port_ == other.port() && scheme_ == other.scheme() &&
172 host_ == other.host(); 187 host_ == other.host();
173 } 188 }
174 189
175 bool SchemeHostPort::operator<(const SchemeHostPort& other) const { 190 bool SchemeHostPort::operator<(const SchemeHostPort& other) const {
176 return std::tie(port_, scheme_, host_) < 191 return std::tie(port_, scheme_, host_) <
177 std::tie(other.port_, other.scheme_, other.host_); 192 std::tie(other.port_, other.scheme_, other.host_);
178 } 193 }
179 194
180 } // namespace url 195 } // namespace url
OLDNEW
« no previous file with comments | « url/scheme_host_port.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698