| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 int64_t size, | 204 int64_t size, |
| 205 base::Time modified); | 205 base::Time modified); |
| 206 | 206 |
| 207 // If text starts with "www." it is removed, otherwise text is returned | 207 // If text starts with "www." it is removed, otherwise text is returned |
| 208 // unmodified. | 208 // unmodified. |
| 209 NET_EXPORT base::string16 StripWWW(const base::string16& text); | 209 NET_EXPORT base::string16 StripWWW(const base::string16& text); |
| 210 | 210 |
| 211 // Runs |url|'s host through StripWWW(). |url| must be valid. | 211 // Runs |url|'s host through StripWWW(). |url| must be valid. |
| 212 NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); | 212 NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); |
| 213 | 213 |
| 214 // Checks if |port| is in the valid range (0 to 65535, though 0 is technically | |
| 215 // reserved). Should be used before casting a port to a uint16_t. | |
| 216 NET_EXPORT bool IsPortValid(int port); | |
| 217 | |
| 218 // Returns true if the port is in the range [0, 1023]. These ports are | |
| 219 // registered by IANA and typically need root access to listen on. | |
| 220 bool IsWellKnownPort(int port); | |
| 221 | |
| 222 // Checks if the port is allowed for the specified scheme. Ports set as allowed | |
| 223 // with SetExplicitlyAllowedPorts() or by using ScopedPortException() will be | |
| 224 // considered allowed for any scheme. | |
| 225 NET_EXPORT bool IsPortAllowedForScheme(int port, const std::string& url_scheme); | |
| 226 | |
| 227 // Returns the number of explicitly allowed ports; for testing. | |
| 228 NET_EXPORT_PRIVATE size_t GetCountOfExplicitlyAllowedPorts(); | |
| 229 | |
| 230 NET_EXPORT void SetExplicitlyAllowedPorts(const std::string& allowed_ports); | |
| 231 | |
| 232 class NET_EXPORT ScopedPortException { | |
| 233 public: | |
| 234 explicit ScopedPortException(int port); | |
| 235 ~ScopedPortException(); | |
| 236 | |
| 237 private: | |
| 238 int port_; | |
| 239 | |
| 240 DISALLOW_COPY_AND_ASSIGN(ScopedPortException); | |
| 241 }; | |
| 242 | |
| 243 // Set socket to non-blocking mode | 214 // Set socket to non-blocking mode |
| 244 NET_EXPORT int SetNonBlocking(int fd); | 215 NET_EXPORT int SetNonBlocking(int fd); |
| 245 | 216 |
| 246 // Formats the host in |url| and appends it to |output|. The host formatter | 217 // Formats the host in |url| and appends it to |output|. The host formatter |
| 247 // takes the same accept languages component as ElideURL(). | 218 // takes the same accept languages component as ElideURL(). |
| 248 NET_EXPORT void AppendFormattedHost(const GURL& url, | 219 NET_EXPORT void AppendFormattedHost(const GURL& url, |
| 249 const std::string& languages, | 220 const std::string& languages, |
| 250 base::string16* output); | 221 base::string16* output); |
| 251 | 222 |
| 252 // Creates a string representation of |url|. The IDN host name may be in Unicode | 223 // Creates a string representation of |url|. The IDN host name may be in Unicode |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 DSCP_CS5 = 40, // Video | 383 DSCP_CS5 = 40, // Video |
| 413 DSCP_EF = 46, // Voice | 384 DSCP_EF = 46, // Voice |
| 414 DSCP_CS6 = 48, // Voice | 385 DSCP_CS6 = 48, // Voice |
| 415 DSCP_CS7 = 56, // Control messages | 386 DSCP_CS7 = 56, // Control messages |
| 416 DSCP_LAST = DSCP_CS7 | 387 DSCP_LAST = DSCP_CS7 |
| 417 }; | 388 }; |
| 418 | 389 |
| 419 } // namespace net | 390 } // namespace net |
| 420 | 391 |
| 421 #endif // NET_BASE_NET_UTIL_H_ | 392 #endif // NET_BASE_NET_UTIL_H_ |
| OLD | NEW |