| 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_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> |
| 8 #include <map> | 9 #include <map> |
| 9 #include <set> | 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 14 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
| 15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 16 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const HostPortPair& host_port_pair) override; | 114 const HostPortPair& host_port_pair) override; |
| 114 const ServerNetworkStatsMap& server_network_stats_map() const override; | 115 const ServerNetworkStatsMap& server_network_stats_map() const override; |
| 115 | 116 |
| 116 private: | 117 private: |
| 117 // |spdy_servers_map_| has flattened representation of servers (host, port) | 118 // |spdy_servers_map_| has flattened representation of servers (host, port) |
| 118 // that either support or not support SPDY protocol. | 119 // that either support or not support SPDY protocol. |
| 119 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; | 120 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; |
| 120 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; | 121 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; |
| 121 typedef std::vector<std::string> CanonicalSufficList; | 122 typedef std::vector<std::string> CanonicalSufficList; |
| 122 typedef std::set<HostPortPair> Http11ServerHostPortSet; | 123 typedef std::set<HostPortPair> Http11ServerHostPortSet; |
| 123 // List of broken host:ports and the times when they can be expired. | 124 |
| 125 // Server, port, and AlternateProtocol: an entity that can be broken. (Once |
| 126 // we use AlternativeService, the same AltSvc can be broken for one server but |
| 127 // not for another depending on what certificate it can offer.) |
| 124 struct BrokenAlternateProtocolEntry { | 128 struct BrokenAlternateProtocolEntry { |
| 129 BrokenAlternateProtocolEntry(const BrokenAlternateProtocolEntry&) = default; |
| 130 BrokenAlternateProtocolEntry(const HostPortPair& server, |
| 131 uint16 port, |
| 132 AlternateProtocol protocol) |
| 133 : server(server), port(port), protocol(protocol) {} |
| 134 |
| 135 bool operator<(const BrokenAlternateProtocolEntry& other) const { |
| 136 if (!server.Equals(other.server)) |
| 137 return server < other.server; |
| 138 if (port != other.port) |
| 139 return port < other.port; |
| 140 return protocol < other.protocol; |
| 141 } |
| 142 |
| 125 HostPortPair server; | 143 HostPortPair server; |
| 144 uint16 port; |
| 145 AlternateProtocol protocol; |
| 146 }; |
| 147 // BrokenAlternateProtocolEntry with expiration time. |
| 148 struct BrokenAlternateProtocolEntryWithTime { |
| 149 BrokenAlternateProtocolEntryWithTime( |
| 150 const BrokenAlternateProtocolEntry& broken_alternate_protocol_entry, |
| 151 base::TimeTicks when) |
| 152 : broken_alternate_protocol_entry(broken_alternate_protocol_entry), |
| 153 when(when) {} |
| 154 |
| 155 BrokenAlternateProtocolEntry broken_alternate_protocol_entry; |
| 126 base::TimeTicks when; | 156 base::TimeTicks when; |
| 127 }; | 157 }; |
| 128 typedef std::list<BrokenAlternateProtocolEntry> | 158 // Deque of BrokenAlternateProtocolEntryWithTime items, ordered by expiration |
| 159 // time. |
| 160 typedef std::deque<BrokenAlternateProtocolEntryWithTime> |
| 129 BrokenAlternateProtocolList; | 161 BrokenAlternateProtocolList; |
| 130 // Map from host:port to the number of times alternate protocol has | 162 // Map from host:port to the number of times alternate protocol has been |
| 131 // been marked broken. | 163 // marked broken. |
| 132 typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap; | 164 typedef std::map<BrokenAlternateProtocolEntry, int> |
| 165 BrokenAlternateProtocolMap; |
| 133 | 166 |
| 134 // Return the iterator for |server|, or for its canonical host, or end. | 167 // Return the iterator for |server|, or for its canonical host, or end. |
| 135 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( | 168 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( |
| 136 const HostPortPair& server); | 169 const HostPortPair& server); |
| 137 | 170 |
| 138 // Return the canonical host for |server|, or end if none exists. | 171 // Return the canonical host for |server|, or end if none exists. |
| 139 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; | 172 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; |
| 140 | 173 |
| 141 void RemoveCanonicalHost(const HostPortPair& server); | 174 void RemoveCanonicalHost(const HostPortPair& server); |
| 142 void ExpireBrokenAlternateProtocolMappings(); | 175 void ExpireBrokenAlternateProtocolMappings(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 163 double alternate_protocol_probability_threshold_; | 196 double alternate_protocol_probability_threshold_; |
| 164 | 197 |
| 165 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; | 198 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; |
| 166 | 199 |
| 167 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); | 200 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
| 168 }; | 201 }; |
| 169 | 202 |
| 170 } // namespace net | 203 } // namespace net |
| 171 | 204 |
| 172 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 205 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| OLD | NEW |