Chromium Code Reviews| Index: net/base/net_util.cc |
| diff --git a/net/base/net_util.cc b/net/base/net_util.cc |
| index 5426b6820511a246da0b8fd4964b7df54374783e..1987391cf4920f86508984f0c386a74155f560bc 100644 |
| --- a/net/base/net_util.cc |
| +++ b/net/base/net_util.cc |
| @@ -1052,7 +1052,7 @@ const FormatUrlType kFormatUrlOmitAll = kFormatUrlOmitUsernamePassword | |
| kFormatUrlOmitHTTP | kFormatUrlOmitTrailingSlashOnBareHostname; |
| // TODO(viettrungluu): We don't want non-POD globals; change this. |
| -std::set<int> explicitly_allowed_ports; |
| +std::multiset<int> explicitly_allowed_ports; |
| GURL FilePathToFileURL(const FilePath& path) { |
| // Produce a URL like "file:///C:/foo" for a regular file, or |
| @@ -1496,12 +1496,7 @@ bool IsPortAllowedByOverride(int port) { |
| if (explicitly_allowed_ports.empty()) |
| return false; |
| - std::set<int>::const_iterator it = |
| - std::find(explicitly_allowed_ports.begin(), |
| - explicitly_allowed_ports.end(), |
| - port); |
| - |
| - return it != explicitly_allowed_ports.end(); |
| + return explicitly_allowed_ports.count(port) > 0; |
| } |
| int SetNonBlocking(int fd) { |
| @@ -1726,7 +1721,7 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) { |
| if (allowed_ports.empty()) |
| return; |
| - std::set<int> ports; |
| + std::multiset<int> ports; |
| size_t last = 0; |
| size_t size = allowed_ports.size(); |
| // The comma delimiter. |
| @@ -1752,6 +1747,16 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) { |
| explicitly_allowed_ports = ports; |
| } |
| +ScopedPortException::ScopedPortException(int port) : port_(port) { |
| + explicitly_allowed_ports.insert(port); |
| +} |
| + |
| +ScopedPortException::~ScopedPortException() { |
| + std::multiset<int>::iterator it = explicitly_allowed_ports.find(port_); |
| + if (it != explicitly_allowed_ports.end()) |
| + explicitly_allowed_ports.erase(it); |
|
akalin
2010/12/09 19:10:31
suggest LOG(DFATAL) if it == end()
Bernhard Bauer
2010/12/10 14:47:04
I used NOTREACHED() if that's okay. We don't reall
|
| +} |
| + |
| enum IPv6SupportStatus { |
| IPV6_CANNOT_CREATE_SOCKETS, |
| IPV6_CAN_CREATE_SOCKETS, |