OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 NET_BASE_NET_UTIL_H_ | 5 #ifndef NET_BASE_NET_UTIL_H_ |
6 #define NET_BASE_NET_UTIL_H_ | 6 #define NET_BASE_NET_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 extern const FormatUrlType kFormatUrlOmitHTTP; | 64 extern const FormatUrlType kFormatUrlOmitHTTP; |
65 | 65 |
66 // Omits the path if it is just a slash and there is no query or ref. This is | 66 // Omits the path if it is just a slash and there is no query or ref. This is |
67 // meaningful for non-file "standard" URLs. | 67 // meaningful for non-file "standard" URLs. |
68 extern const FormatUrlType kFormatUrlOmitTrailingSlashOnBareHostname; | 68 extern const FormatUrlType kFormatUrlOmitTrailingSlashOnBareHostname; |
69 | 69 |
70 // Convenience for omitting all unecessary types. | 70 // Convenience for omitting all unecessary types. |
71 extern const FormatUrlType kFormatUrlOmitAll; | 71 extern const FormatUrlType kFormatUrlOmitAll; |
72 | 72 |
73 // Holds a list of ports that should be accepted despite bans. | 73 // Holds a list of ports that should be accepted despite bans. |
74 extern std::set<int> explicitly_allowed_ports; | 74 extern std::multiset<int> explicitly_allowed_ports; |
75 | 75 |
76 // Given the full path to a file name, creates a file: URL. The returned URL | 76 // Given the full path to a file name, creates a file: URL. The returned URL |
77 // may not be valid if the input is malformed. | 77 // may not be valid if the input is malformed. |
78 GURL FilePathToFileURL(const FilePath& path); | 78 GURL FilePathToFileURL(const FilePath& path); |
79 | 79 |
80 // Converts a file: URL back to a filename that can be passed to the OS. The | 80 // Converts a file: URL back to a filename that can be passed to the OS. The |
81 // file URL must be well-formed (GURL::is_valid() must return true); we don't | 81 // file URL must be well-formed (GURL::is_valid() must return true); we don't |
82 // handle degenerate cases here. Returns true on success, false if it isn't a | 82 // handle degenerate cases here. Returns true on success, false if it isn't a |
83 // valid file URL. On failure, *file_path will be empty. | 83 // valid file URL. On failure, *file_path will be empty. |
84 bool FileURLToFilePath(const GURL& url, FilePath* file_path); | 84 bool FileURLToFilePath(const GURL& url, FilePath* file_path); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 // format flag including kFormatUrlOmitTrailingSlashOnBareHostname. | 331 // format flag including kFormatUrlOmitTrailingSlashOnBareHostname. |
332 bool CanStripTrailingSlash(const GURL& url); | 332 bool CanStripTrailingSlash(const GURL& url); |
333 | 333 |
334 // Strip the portions of |url| that aren't core to the network request. | 334 // Strip the portions of |url| that aren't core to the network request. |
335 // - user name / password | 335 // - user name / password |
336 // - reference section | 336 // - reference section |
337 GURL SimplifyUrlForRequest(const GURL& url); | 337 GURL SimplifyUrlForRequest(const GURL& url); |
338 | 338 |
339 void SetExplicitlyAllowedPorts(const std::string& allowed_ports); | 339 void SetExplicitlyAllowedPorts(const std::string& allowed_ports); |
340 | 340 |
341 class ScopedPortException { | |
cbentzel
2010/12/09 14:25:13
DISALLOW_COPY_AND_ASSIGN
| |
342 public: | |
343 ScopedPortException(int port); | |
344 ~ScopedPortException(); | |
345 | |
346 private: | |
347 int port_; | |
348 }; | |
349 | |
341 // Perform a simplistic test to see if IPv6 is supported by trying to create an | 350 // Perform a simplistic test to see if IPv6 is supported by trying to create an |
342 // IPv6 socket. | 351 // IPv6 socket. |
343 // TODO(jar): Make test more in-depth as needed. | 352 // TODO(jar): Make test more in-depth as needed. |
344 bool IPv6Supported(); | 353 bool IPv6Supported(); |
345 | 354 |
346 // Returns true if it can determine that only loopback addresses are configured. | 355 // Returns true if it can determine that only loopback addresses are configured. |
347 // i.e. if only 127.0.0.1 and ::1 are routable. | 356 // i.e. if only 127.0.0.1 and ::1 are routable. |
348 bool HaveOnlyLoopbackAddresses(); | 357 bool HaveOnlyLoopbackAddresses(); |
349 | 358 |
350 // IPAddressNumber is used to represent an IP address's numeric value as an | 359 // IPAddressNumber is used to represent an IP address's numeric value as an |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 | 403 |
395 // Returns the port field of the sockaddr in |info|. | 404 // Returns the port field of the sockaddr in |info|. |
396 uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); | 405 uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); |
397 | 406 |
398 // Returns the value of |info's| port (in host byte ordering). | 407 // Returns the value of |info's| port (in host byte ordering). |
399 int GetPortFromAddrinfo(const struct addrinfo* info); | 408 int GetPortFromAddrinfo(const struct addrinfo* info); |
400 | 409 |
401 } // namespace net | 410 } // namespace net |
402 | 411 |
403 #endif // NET_BASE_NET_UTIL_H_ | 412 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |