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

Side by Side Diff: net/base/net_util.h

Issue 5519015: Explicitly whitelist the test server port. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/live_sync/live_sync_test.cc ('k') | net/base/net_util.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 (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
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
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 {
342 public:
343 ScopedPortException(int port);
344 ~ScopedPortException();
345
346 private:
347 int port_;
348
349 DISALLOW_COPY_AND_ASSIGN(ScopedPortException);
350 };
351
341 // Perform a simplistic test to see if IPv6 is supported by trying to create an 352 // Perform a simplistic test to see if IPv6 is supported by trying to create an
342 // IPv6 socket. 353 // IPv6 socket.
343 // TODO(jar): Make test more in-depth as needed. 354 // TODO(jar): Make test more in-depth as needed.
344 bool IPv6Supported(); 355 bool IPv6Supported();
345 356
346 // Returns true if it can determine that only loopback addresses are configured. 357 // 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. 358 // i.e. if only 127.0.0.1 and ::1 are routable.
348 bool HaveOnlyLoopbackAddresses(); 359 bool HaveOnlyLoopbackAddresses();
349 360
350 // IPAddressNumber is used to represent an IP address's numeric value as an 361 // 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
394 405
395 // Returns the port field of the sockaddr in |info|. 406 // Returns the port field of the sockaddr in |info|.
396 uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); 407 uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info);
397 408
398 // Returns the value of |info's| port (in host byte ordering). 409 // Returns the value of |info's| port (in host byte ordering).
399 int GetPortFromAddrinfo(const struct addrinfo* info); 410 int GetPortFromAddrinfo(const struct addrinfo* info);
400 411
401 } // namespace net 412 } // namespace net
402 413
403 #endif // NET_BASE_NET_UTIL_H_ 414 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sync_test.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698