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

Side by Side Diff: url/scheme_host_port.cc

Issue 2560923002: [url] Remove comparisons for blob/filesystem schemes in scheme_host_port (Closed)
Patch Set: Remove DCHECK, add comment to unit test (trybots prev) Created 4 years 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 | « no previous file | url/scheme_host_port_unittest.cc » ('j') | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 uint16_t port, 52 uint16_t port,
53 SchemeHostPort::ConstructPolicy policy) { 53 SchemeHostPort::ConstructPolicy policy) {
54 SchemeType scheme_type = SCHEME_WITH_PORT; 54 SchemeType scheme_type = SCHEME_WITH_PORT;
55 bool is_standard = GetStandardSchemeType( 55 bool is_standard = GetStandardSchemeType(
56 scheme.data(), 56 scheme.data(),
57 Component(0, base::checked_cast<int>(scheme.length())), 57 Component(0, base::checked_cast<int>(scheme.length())),
58 &scheme_type); 58 &scheme_type);
59 if (!is_standard) 59 if (!is_standard)
60 return false; 60 return false;
61 61
62 // These schemes do not follow the generic URL syntax, so we treat them as
63 // invalid (scheme, host, port) tuples (even though such URLs' _Origin_ might
64 // have a (scheme, host, port) tuple, they themselves do not).
65 if (scheme == kFileSystemScheme || scheme == kBlobScheme)
66 return false;
67
68 switch (scheme_type) { 62 switch (scheme_type) {
69 case SCHEME_WITH_PORT: 63 case SCHEME_WITH_PORT:
70 // A URL with |scheme| is required to have the host and port (may be 64 // A URL with |scheme| is required to have the host and port (may be
71 // omitted in a serialization if it's the same as the default value). 65 // omitted in a serialization if it's the same as the default value).
72 // Return an invalid instance if either of them is not given. 66 // Return an invalid instance if either of them is not given.
73 if (host.empty() || port == 0) 67 if (host.empty() || port == 0)
74 return false; 68 return false;
75 69
76 // Don't do an expensive canonicalization if the host is already 70 // Don't do an expensive canonicalization if the host is already
77 // canonicalized. 71 // canonicalized.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 result.push_back(':'); 221 result.push_back(':');
228 std::string port(base::UintToString(port_)); 222 std::string port(base::UintToString(port_));
229 parsed->port = Component(result.length(), port.length()); 223 parsed->port = Component(result.length(), port.length());
230 result.append(std::move(port)); 224 result.append(std::move(port));
231 } 225 }
232 226
233 return result; 227 return result;
234 } 228 }
235 229
236 } // namespace url 230 } // namespace url
OLDNEW
« no previous file with comments | « no previous file | url/scheme_host_port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698