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 #ifndef URL_SCHEME_HOST_PORT_H_ | 5 #ifndef URL_SCHEME_HOST_PORT_H_ |
6 #define URL_SCHEME_HOST_PORT_H_ | 6 #define URL_SCHEME_HOST_PORT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 bool IsInvalid() const; | 104 bool IsInvalid() const; |
105 | 105 |
106 // Serializes the SchemeHostPort tuple to a canonical form. | 106 // Serializes the SchemeHostPort tuple to a canonical form. |
107 // | 107 // |
108 // While this string form resembles the Origin serialization specified in | 108 // While this string form resembles the Origin serialization specified in |
109 // Section 6.2 of RFC 6454, it is important to note that invalid | 109 // Section 6.2 of RFC 6454, it is important to note that invalid |
110 // SchemeHostPort tuples serialize to the empty string, rather than being | 110 // SchemeHostPort tuples serialize to the empty string, rather than being |
111 // serialized as a unique Origin. | 111 // serialized as a unique Origin. |
112 std::string Serialize() const; | 112 std::string Serialize() const; |
113 | 113 |
| 114 // Efficiently returns what GURL(Serialize()) would return, without needing to |
| 115 // re-parse the URL. |
| 116 GURL GetURL() const; |
| 117 |
114 // Two SchemeHostPort objects are "equal" iff their schemes, hosts, and ports | 118 // Two SchemeHostPort objects are "equal" iff their schemes, hosts, and ports |
115 // are exact matches. | 119 // are exact matches. |
116 // | 120 // |
117 // Note that this comparison is _not_ the same as an origin-based comparison. | 121 // Note that this comparison is _not_ the same as an origin-based comparison. |
118 // In particular, invalid SchemeHostPort objects match each other (and | 122 // In particular, invalid SchemeHostPort objects match each other (and |
119 // themselves). Unique origins, on the other hand, would not. | 123 // themselves). Unique origins, on the other hand, would not. |
120 bool Equals(const SchemeHostPort& other) const; | 124 bool Equals(const SchemeHostPort& other) const; |
121 | 125 |
122 // Allows SchemeHostPort to be used as a key in STL (for example, a std::set | 126 // Allows SchemeHostPort to be used as a key in STL (for example, a std::set |
123 // or std::map). | 127 // or std::map). |
124 bool operator<(const SchemeHostPort& other) const; | 128 bool operator<(const SchemeHostPort& other) const; |
125 | 129 |
126 private: | 130 private: |
127 std::string scheme_; | 131 std::string scheme_; |
128 std::string host_; | 132 std::string host_; |
129 uint16_t port_; | 133 uint16_t port_; |
130 }; | 134 }; |
131 | 135 |
132 } // namespace url | 136 } // namespace url |
133 | 137 |
134 #endif // URL_SCHEME_HOST_PORT_H_ | 138 #endif // URL_SCHEME_HOST_PORT_H_ |
OLD | NEW |