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

Side by Side Diff: net/http/http_server_properties_impl.h

Issue 253903002: SPDY - persist 300 most recently used servers that support SPDY to preferences file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Persist 300 MRU servers that support SPDY Created 6 years, 7 months 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 | « net/http/http_server_properties.h ('k') | net/http/http_server_properties_impl.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) 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 16 matching lines...) Expand all
27 namespace net { 27 namespace net {
28 28
29 // The implementation for setting/retrieving the HTTP server properties. 29 // The implementation for setting/retrieving the HTTP server properties.
30 class NET_EXPORT HttpServerPropertiesImpl 30 class NET_EXPORT HttpServerPropertiesImpl
31 : public HttpServerProperties, 31 : public HttpServerProperties,
32 NON_EXPORTED_BASE(public base::NonThreadSafe) { 32 NON_EXPORTED_BASE(public base::NonThreadSafe) {
33 public: 33 public:
34 HttpServerPropertiesImpl(); 34 HttpServerPropertiesImpl();
35 virtual ~HttpServerPropertiesImpl(); 35 virtual ~HttpServerPropertiesImpl();
36 36
37 // Initializes |spdy_servers_table_| with the servers (host/port) from 37 // Initializes |spdy_servers_map_| with the servers (host/port) from
38 // |spdy_servers| that either support SPDY or not. 38 // |spdy_servers| that either support SPDY or not.
39 void InitializeSpdyServers(std::vector<std::string>* spdy_servers, 39 void InitializeSpdyServers(std::vector<std::string>* spdy_servers,
40 bool support_spdy); 40 bool support_spdy);
41 41
42 void InitializeAlternateProtocolServers( 42 void InitializeAlternateProtocolServers(
43 AlternateProtocolMap* alternate_protocol_servers); 43 AlternateProtocolMap* alternate_protocol_servers);
44 44
45 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map); 45 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map);
46 46
47 // Initializes |pipeline_capability_map_| with the servers (host/port) from 47 // Initializes |pipeline_capability_map_| with the servers (host/port) from
48 // |pipeline_capability_map| that either support HTTP pipelining or not. 48 // |pipeline_capability_map| that either support HTTP pipelining or not.
49 void InitializePipelineCapabilities( 49 void InitializePipelineCapabilities(
50 const PipelineCapabilityMap* pipeline_capability_map); 50 const PipelineCapabilityMap* pipeline_capability_map);
51 51
52 // Get the list of servers (host/port) that support SPDY. 52 // Get the list of servers (host/port) that support SPDY. The max_size is the
53 void GetSpdyServerList(base::ListValue* spdy_server_list) const; 53 // number of MRU servers that support SPDY that are to be returned.
54 void GetSpdyServerList(base::ListValue* spdy_server_list,
55 size_t max_size) const;
54 56
55 // Returns flattened string representation of the |host_port_pair|. Used by 57 // Returns flattened string representation of the |host_port_pair|. Used by
56 // unittests. 58 // unittests.
57 static std::string GetFlattenedSpdyServer( 59 static std::string GetFlattenedSpdyServer(
58 const net::HostPortPair& host_port_pair); 60 const net::HostPortPair& host_port_pair);
59 61
60 // Debugging to simulate presence of an AlternateProtocol. 62 // Debugging to simulate presence of an AlternateProtocol.
61 // If we don't have an alternate protocol in the map for any given host/port 63 // If we don't have an alternate protocol in the map for any given host/port
62 // pair, force this ProtocolPortPair. 64 // pair, force this ProtocolPortPair.
63 static void ForceAlternateProtocol(const PortAlternateProtocolPair& pair); 65 static void ForceAlternateProtocol(const PortAlternateProtocolPair& pair);
64 static void DisableForcedAlternateProtocol(); 66 static void DisableForcedAlternateProtocol();
65 67
66 // Changes the number of host/port pairs we remember pipelining capability 68 // Changes the number of host/port pairs we remember pipelining capability
67 // for. A larger number means we're more likely to be able to pipeline 69 // for. A larger number means we're more likely to be able to pipeline
68 // immediately if a host is known good, but uses more memory. This function 70 // immediately if a host is known good, but uses more memory. This function
69 // can only be called if |pipeline_capability_map_| is empty. 71 // can only be called if |pipeline_capability_map_| is empty.
70 void SetNumPipelinedHostsToRemember(int max_size); 72 void SetNumPipelinedHostsToRemember(int max_size);
71 73
72 // ----------------------------- 74 // -----------------------------
73 // HttpServerProperties methods: 75 // HttpServerProperties methods:
74 // ----------------------------- 76 // -----------------------------
75 77
76 // Gets a weak pointer for this object. 78 // Gets a weak pointer for this object.
77 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() OVERRIDE; 79 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() OVERRIDE;
78 80
79 // Deletes all data. 81 // Deletes all data.
80 virtual void Clear() OVERRIDE; 82 virtual void Clear() OVERRIDE;
81 83
82 // Returns true if |server| supports SPDY. 84 // Returns true if |server| supports SPDY.
83 virtual bool SupportsSpdy(const HostPortPair& server) const OVERRIDE; 85 virtual bool SupportsSpdy(const HostPortPair& server) OVERRIDE;
84 86
85 // Add |server| into the persistent store. 87 // Add |server| into the persistent store.
86 virtual void SetSupportsSpdy(const HostPortPair& server, 88 virtual void SetSupportsSpdy(const HostPortPair& server,
87 bool support_spdy) OVERRIDE; 89 bool support_spdy) OVERRIDE;
88 90
89 // Returns true if |server| has an Alternate-Protocol header. 91 // Returns true if |server| has an Alternate-Protocol header.
90 virtual bool HasAlternateProtocol(const HostPortPair& server) OVERRIDE; 92 virtual bool HasAlternateProtocol(const HostPortPair& server) OVERRIDE;
91 93
92 // Returns the Alternate-Protocol and port for |server|. 94 // Returns the Alternate-Protocol and port for |server|.
93 // HasAlternateProtocol(server) must be true. 95 // HasAlternateProtocol(server) must be true.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 const HostPortPair& origin, 152 const HostPortPair& origin,
151 HttpPipelinedHostCapability capability) OVERRIDE; 153 HttpPipelinedHostCapability capability) OVERRIDE;
152 154
153 virtual void ClearPipelineCapabilities() OVERRIDE; 155 virtual void ClearPipelineCapabilities() OVERRIDE;
154 156
155 virtual PipelineCapabilityMap GetPipelineCapabilityMap() const OVERRIDE; 157 virtual PipelineCapabilityMap GetPipelineCapabilityMap() const OVERRIDE;
156 158
157 private: 159 private:
158 typedef base::MRUCache< 160 typedef base::MRUCache<
159 HostPortPair, HttpPipelinedHostCapability> CachedPipelineCapabilityMap; 161 HostPortPair, HttpPipelinedHostCapability> CachedPipelineCapabilityMap;
160 // |spdy_servers_table_| has flattened representation of servers (host/port 162 // |spdy_servers_map_| has flattened representation of servers (host, port)
161 // pair) that either support or not support SPDY protocol. 163 // that either support or not support SPDY protocol.
162 typedef base::hash_map<std::string, bool> SpdyServerHostPortTable; 164 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap;
163 typedef std::map<HostPortPair, NetworkStats> ServerNetworkStatsMap; 165 typedef std::map<HostPortPair, NetworkStats> ServerNetworkStatsMap;
164 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; 166 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap;
165 typedef std::vector<std::string> CanonicalSufficList; 167 typedef std::vector<std::string> CanonicalSufficList;
166 // List of broken host:ports and the times when they can be expired. 168 // List of broken host:ports and the times when they can be expired.
167 struct BrokenAlternateProtocolEntry { 169 struct BrokenAlternateProtocolEntry {
168 HostPortPair server; 170 HostPortPair server;
169 base::TimeTicks when; 171 base::TimeTicks when;
170 }; 172 };
171 typedef std::list<BrokenAlternateProtocolEntry> 173 typedef std::list<BrokenAlternateProtocolEntry>
172 BrokenAlternateProtocolList; 174 BrokenAlternateProtocolList;
173 // Map from host:port to the number of times alternate protocol has 175 // Map from host:port to the number of times alternate protocol has
174 // been marked broken. 176 // been marked broken.
175 typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap; 177 typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap;
176 178
177 // Return the canonical host for |server|, or end if none exists. 179 // Return the canonical host for |server|, or end if none exists.
178 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; 180 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const;
179 181
180 void ExpireBrokenAlternateProtocolMappings(); 182 void ExpireBrokenAlternateProtocolMappings();
181 void ScheduleBrokenAlternateProtocolMappingsExpiration(); 183 void ScheduleBrokenAlternateProtocolMappingsExpiration();
182 184
183 SpdyServerHostPortTable spdy_servers_table_; 185 SpdyServerHostPortMap spdy_servers_map_;
184 186
185 AlternateProtocolMap alternate_protocol_map_; 187 AlternateProtocolMap alternate_protocol_map_;
186 BrokenAlternateProtocolList broken_alternate_protocol_list_; 188 BrokenAlternateProtocolList broken_alternate_protocol_list_;
187 BrokenAlternateProtocolMap broken_alternate_protocol_map_; 189 BrokenAlternateProtocolMap broken_alternate_protocol_map_;
188 190
189 SpdySettingsMap spdy_settings_map_; 191 SpdySettingsMap spdy_settings_map_;
190 ServerNetworkStatsMap server_network_stats_map_; 192 ServerNetworkStatsMap server_network_stats_map_;
191 scoped_ptr<CachedPipelineCapabilityMap> pipeline_capability_map_; 193 scoped_ptr<CachedPipelineCapabilityMap> pipeline_capability_map_;
192 // Contains a map of servers which could share the same alternate protocol. 194 // Contains a map of servers which could share the same alternate protocol.
193 // Map from a Canonical host/port (host is some postfix of host names) to an 195 // Map from a Canonical host/port (host is some postfix of host names) to an
194 // actual origin, which has a plausible alternate protocol mapping. 196 // actual origin, which has a plausible alternate protocol mapping.
195 CanonicalHostMap canonical_host_to_origin_map_; 197 CanonicalHostMap canonical_host_to_origin_map_;
196 // Contains list of suffixes (for exmaple ".c.youtube.com", 198 // Contains list of suffixes (for exmaple ".c.youtube.com",
197 // ".googlevideo.com") of canoncial hostnames. 199 // ".googlevideo.com") of canoncial hostnames.
198 CanonicalSufficList canoncial_suffixes_; 200 CanonicalSufficList canoncial_suffixes_;
199 201
200 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; 202 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
201 203
202 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); 204 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
203 }; 205 };
204 206
205 } // namespace net 207 } // namespace net
206 208
207 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 209 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
OLDNEW
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698