OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
| 15 #include "base/memory/mru_cache.h" |
15 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 20 #include "net/http/http_pipelined_host_capability.h" |
19 #include "net/http/http_server_properties.h" | 21 #include "net/http/http_server_properties.h" |
20 | 22 |
21 namespace base { | 23 namespace base { |
22 class ListValue; | 24 class ListValue; |
23 } | 25 } |
24 | 26 |
25 namespace net { | 27 namespace net { |
26 | 28 |
27 // The implementation for setting/retrieving the HTTP server properties. | 29 // The implementation for setting/retrieving the HTTP server properties. |
28 class NET_EXPORT HttpServerPropertiesImpl | 30 class NET_EXPORT HttpServerPropertiesImpl |
29 : public HttpServerProperties, | 31 : public HttpServerProperties, |
30 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 32 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
31 public: | 33 public: |
32 HttpServerPropertiesImpl(); | 34 HttpServerPropertiesImpl(); |
33 virtual ~HttpServerPropertiesImpl(); | 35 virtual ~HttpServerPropertiesImpl(); |
34 | 36 |
35 // Initializes |spdy_servers_table_| with the servers (host/port) from | 37 // Initializes |spdy_servers_table_| with the servers (host/port) from |
36 // |spdy_servers| that either support SPDY or not. | 38 // |spdy_servers| that either support SPDY or not. |
37 void InitializeSpdyServers(std::vector<std::string>* spdy_servers, | 39 void InitializeSpdyServers(std::vector<std::string>* spdy_servers, |
38 bool support_spdy); | 40 bool support_spdy); |
39 | 41 |
40 void InitializeAlternateProtocolServers( | 42 void InitializeAlternateProtocolServers( |
41 AlternateProtocolMap* alternate_protocol_servers); | 43 AlternateProtocolMap* alternate_protocol_servers); |
42 | 44 |
43 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map); | 45 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map); |
44 | 46 |
| 47 // Initializes |pipeline_capability_map_| with the servers (host/port) from |
| 48 // |pipeline_capability_map| that either support HTTP pipelining or not. |
| 49 void InitializePipelineCapabilities( |
| 50 const PipelineCapabilityMap* pipeline_capability_map); |
| 51 |
45 // Get the list of servers (host/port) that support SPDY. | 52 // Get the list of servers (host/port) that support SPDY. |
46 void GetSpdyServerList(base::ListValue* spdy_server_list) const; | 53 void GetSpdyServerList(base::ListValue* spdy_server_list) const; |
47 | 54 |
48 // Returns flattened string representation of the |host_port_pair|. Used by | 55 // Returns flattened string representation of the |host_port_pair|. Used by |
49 // unittests. | 56 // unittests. |
50 static std::string GetFlattenedSpdyServer( | 57 static std::string GetFlattenedSpdyServer( |
51 const net::HostPortPair& host_port_pair); | 58 const net::HostPortPair& host_port_pair); |
52 | 59 |
53 // Debugging to simulate presence of an AlternateProtocol. | 60 // Debugging to simulate presence of an AlternateProtocol. |
54 // If we don't have an alternate protocol in the map for any given host/port | 61 // If we don't have an alternate protocol in the map for any given host/port |
55 // pair, force this ProtocolPortPair. | 62 // pair, force this ProtocolPortPair. |
56 static void ForceAlternateProtocol(const PortAlternateProtocolPair& pair); | 63 static void ForceAlternateProtocol(const PortAlternateProtocolPair& pair); |
57 static void DisableForcedAlternateProtocol(); | 64 static void DisableForcedAlternateProtocol(); |
58 | 65 |
| 66 // 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 |
| 68 // immediately if a host is known good, but uses more memory. This function |
| 69 // can only be called if |pipeline_capability_map_| is empty. |
| 70 void SetNumPipelinedHostsToRemember(int max_size); |
| 71 |
59 // ----------------------------- | 72 // ----------------------------- |
60 // HttpServerProperties methods: | 73 // HttpServerProperties methods: |
61 // ----------------------------- | 74 // ----------------------------- |
62 | 75 |
63 // Deletes all data. | 76 // Deletes all data. |
64 virtual void Clear() OVERRIDE; | 77 virtual void Clear() OVERRIDE; |
65 | 78 |
66 // Returns true if |server| supports SPDY. | 79 // Returns true if |server| supports SPDY. |
67 virtual bool SupportsSpdy(const HostPortPair& server) const OVERRIDE; | 80 virtual bool SupportsSpdy(const HostPortPair& server) const OVERRIDE; |
68 | 81 |
(...skipping 30 matching lines...) Expand all Loading... |
99 // persisted because |spdy_settings_map_| has been updated. | 112 // persisted because |spdy_settings_map_| has been updated. |
100 virtual bool SetSpdySettings(const HostPortPair& host_port_pair, | 113 virtual bool SetSpdySettings(const HostPortPair& host_port_pair, |
101 const spdy::SpdySettings& settings) OVERRIDE; | 114 const spdy::SpdySettings& settings) OVERRIDE; |
102 | 115 |
103 // Clears all spdy_settings. | 116 // Clears all spdy_settings. |
104 virtual void ClearSpdySettings() OVERRIDE; | 117 virtual void ClearSpdySettings() OVERRIDE; |
105 | 118 |
106 // Returns all persistent SpdySettings. | 119 // Returns all persistent SpdySettings. |
107 virtual const SpdySettingsMap& spdy_settings_map() const OVERRIDE; | 120 virtual const SpdySettingsMap& spdy_settings_map() const OVERRIDE; |
108 | 121 |
| 122 virtual HttpPipelinedHostCapability GetPipelineCapability( |
| 123 const HostPortPair& origin) OVERRIDE; |
| 124 |
| 125 virtual void SetPipelineCapability( |
| 126 const HostPortPair& origin, |
| 127 HttpPipelinedHostCapability capability) OVERRIDE; |
| 128 |
| 129 virtual void ClearPipelineCapabilities() OVERRIDE; |
| 130 |
| 131 virtual PipelineCapabilityMap GetPipelineCapabilityMap() const OVERRIDE; |
| 132 |
109 private: | 133 private: |
| 134 typedef base::MRUCache< |
| 135 HostPortPair, HttpPipelinedHostCapability> CachedPipelineCapabilityMap; |
110 // |spdy_servers_table_| has flattened representation of servers (host/port | 136 // |spdy_servers_table_| has flattened representation of servers (host/port |
111 // pair) that either support or not support SPDY protocol. | 137 // pair) that either support or not support SPDY protocol. |
112 typedef base::hash_map<std::string, bool> SpdyServerHostPortTable; | 138 typedef base::hash_map<std::string, bool> SpdyServerHostPortTable; |
113 SpdyServerHostPortTable spdy_servers_table_; | 139 SpdyServerHostPortTable spdy_servers_table_; |
114 | 140 |
115 AlternateProtocolMap alternate_protocol_map_; | 141 AlternateProtocolMap alternate_protocol_map_; |
116 SpdySettingsMap spdy_settings_map_; | 142 SpdySettingsMap spdy_settings_map_; |
| 143 scoped_ptr<CachedPipelineCapabilityMap> pipeline_capability_map_; |
117 | 144 |
118 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); | 145 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
119 }; | 146 }; |
120 | 147 |
121 } // namespace net | 148 } // namespace net |
122 | 149 |
123 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 150 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
OLD | NEW |