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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // It may, however, be inappropriate to use as a cache key for persistent | 29 // It may, however, be inappropriate to use as a cache key for persistent |
30 // storage associated with a host. | 30 // storage associated with a host. |
31 // | 31 // |
32 // In particular, note that: | 32 // In particular, note that: |
33 // | 33 // |
34 // * SchemeHostPort can only represent schemes which follow the RFC 3986 syntax | 34 // * SchemeHostPort can only represent schemes which follow the RFC 3986 syntax |
35 // (e.g. those registered with GURL as "standard schemes"). Non-standard | 35 // (e.g. those registered with GURL as "standard schemes"). Non-standard |
36 // schemes such as "blob", "filesystem", "data", and "javascript" can only be | 36 // schemes such as "blob", "filesystem", "data", and "javascript" can only be |
37 // represented as invalid SchemeHostPort objects. | 37 // represented as invalid SchemeHostPort objects. |
38 // | 38 // |
39 // * For example, the "file" scheme follows the standard syntax, but it is | 39 // * The "file" scheme follows the standard syntax, but it is important to note |
40 // important to note that the authority portion (host, port) is optional. | 40 // that the authority portion (host, port) is optional. URLs without an |
41 // URLs without an authority portion will be represented with an empty string | 41 // authority portion will be represented with an empty string for the host, |
42 // for the host, and a port of 0 (e.g. "file:///etc/hosts" => | 42 // and a port of 0 (e.g. "file:///etc/hosts" => ("file", "", 0)), and URLs |
43 // ("file", "", 0)), and URLs with a host-only authority portion will be | 43 // with a host-only authority portion will be represented with a port of 0 |
44 // represented with a port of 0 (e.g. "file://example.com/etc/hosts" => | 44 // (e.g. "file://example.com/etc/hosts" => ("file", "example.com", 0)). See |
45 // ("file", "example.com", 0)). See Section 3 of RFC 3986 to better understand | 45 // Section 3 of RFC 3986 to better understand these constructs. |
46 // these constructs. | |
47 // | 46 // |
48 // * SchemeHostPort has no notion of the Origin concept (RFC 6454), and in | 47 // * SchemeHostPort has no notion of the Origin concept (RFC 6454), and in |
49 // particular, it has no notion of a "unique" Origin. If you need to take | 48 // particular, it has no notion of a "unique" Origin. If you need to take |
50 // uniqueness into account (and, if you're making security-relevant decisions | 49 // uniqueness into account (and, if you're making security-relevant decisions |
51 // then you absolutely do), please use 'url::Origin' instead. | 50 // then you absolutely do), please use 'url::Origin' instead[1]. |
| 51 // |
| 52 // [1]: // TODO(mkwst): Land 'url::Origin'. :) |
52 // | 53 // |
53 // Usage: | 54 // Usage: |
54 // | 55 // |
55 // * SchemeHostPort objects are commonly created from GURL objects: | 56 // * SchemeHostPort objects are commonly created from GURL objects: |
56 // | 57 // |
57 // GURL url("https://example.com/"); | 58 // GURL url("https://example.com/"); |
58 // url::SchemeHostPort tuple(url); | 59 // url::SchemeHostPort tuple(url); |
59 // tuple.scheme(); // "https" | 60 // tuple.scheme(); // "https" |
60 // tuple.host(); // "example.com" | 61 // tuple.host(); // "example.com" |
61 // tuple.port(); // 443 | 62 // tuple.port(); // 443 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 private: | 124 private: |
124 std::string scheme_; | 125 std::string scheme_; |
125 std::string host_; | 126 std::string host_; |
126 uint16 port_; | 127 uint16 port_; |
127 }; | 128 }; |
128 | 129 |
129 } // namespace url | 130 } // namespace url |
130 | 131 |
131 #endif // URL_SCHEME_HOST_PORT_H_ | 132 #endif // URL_SCHEME_HOST_PORT_H_ |
OLD | NEW |