OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MANAGER_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void SetAlternateProtocolProbabilityThreshold(double threshold) override; | 101 void SetAlternateProtocolProbabilityThreshold(double threshold) override; |
102 const SettingsMap& GetSpdySettings( | 102 const SettingsMap& GetSpdySettings( |
103 const HostPortPair& host_port_pair) override; | 103 const HostPortPair& host_port_pair) override; |
104 bool SetSpdySetting(const HostPortPair& host_port_pair, | 104 bool SetSpdySetting(const HostPortPair& host_port_pair, |
105 SpdySettingsIds id, | 105 SpdySettingsIds id, |
106 SpdySettingsFlags flags, | 106 SpdySettingsFlags flags, |
107 uint32 value) override; | 107 uint32 value) override; |
108 void ClearSpdySettings(const HostPortPair& host_port_pair) override; | 108 void ClearSpdySettings(const HostPortPair& host_port_pair) override; |
109 void ClearAllSpdySettings() override; | 109 void ClearAllSpdySettings() override; |
110 const SpdySettingsMap& spdy_settings_map() const override; | 110 const SpdySettingsMap& spdy_settings_map() const override; |
111 SupportsQuic GetSupportsQuic( | 111 bool GetSupportsQuic(IPAddressNumber* last_address) const override; |
112 const HostPortPair& host_port_pair) const override; | 112 void SetSupportsQuic(bool used_quic, |
113 void SetSupportsQuic(const HostPortPair& host_port_pair, | 113 const IPAddressNumber& last_address) override; |
114 bool used_quic, | |
115 const std::string& address) override; | |
116 const SupportsQuicMap& supports_quic_map() const override; | |
117 void SetServerNetworkStats(const HostPortPair& host_port_pair, | 114 void SetServerNetworkStats(const HostPortPair& host_port_pair, |
118 ServerNetworkStats stats) override; | 115 ServerNetworkStats stats) override; |
119 const ServerNetworkStats* GetServerNetworkStats( | 116 const ServerNetworkStats* GetServerNetworkStats( |
120 const HostPortPair& host_port_pair) override; | 117 const HostPortPair& host_port_pair) override; |
121 const ServerNetworkStatsMap& server_network_stats_map() const override; | 118 const ServerNetworkStatsMap& server_network_stats_map() const override; |
122 | 119 |
123 protected: | 120 protected: |
124 // -------------------- | 121 // -------------------- |
125 // SPDY related methods | 122 // SPDY related methods |
126 | 123 |
(...skipping 11 matching lines...) Expand all Loading... |
138 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on | 135 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on |
139 // network thread. | 136 // network thread. |
140 virtual void UpdateCacheFromPrefsOnPrefThread(); | 137 virtual void UpdateCacheFromPrefsOnPrefThread(); |
141 | 138 |
142 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 139 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
143 // network thread. Protected for testing. | 140 // network thread. Protected for testing. |
144 void UpdateCacheFromPrefsOnNetworkThread( | 141 void UpdateCacheFromPrefsOnNetworkThread( |
145 std::vector<std::string>* spdy_servers, | 142 std::vector<std::string>* spdy_servers, |
146 SpdySettingsMap* spdy_settings_map, | 143 SpdySettingsMap* spdy_settings_map, |
147 AlternateProtocolMap* alternate_protocol_map, | 144 AlternateProtocolMap* alternate_protocol_map, |
148 SupportsQuicMap* supports_quic_map, | 145 IPAddressNumber* last_quic_address, |
149 ServerNetworkStatsMap* server_network_stats_map, | 146 ServerNetworkStatsMap* server_network_stats_map, |
150 bool detected_corrupted_prefs); | 147 bool detected_corrupted_prefs); |
151 | 148 |
152 // These are used to delay updating the preferences when cached data in | 149 // These are used to delay updating the preferences when cached data in |
153 // |http_server_properties_impl_| is changing, and execute only one update per | 150 // |http_server_properties_impl_| is changing, and execute only one update per |
154 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 151 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. |
155 void ScheduleUpdatePrefsOnNetworkThread(); | 152 void ScheduleUpdatePrefsOnNetworkThread(); |
156 | 153 |
157 // Starts the timers to update the prefs from cache. This are overridden in | 154 // Starts the timers to update the prefs from cache. This are overridden in |
158 // tests to prevent the delay. | 155 // tests to prevent the delay. |
159 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); | 156 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); |
160 | 157 |
161 // Update prefs::kHttpServerProperties in preferences with the cached data | 158 // Update prefs::kHttpServerProperties in preferences with the cached data |
162 // from |http_server_properties_impl_|. This gets the data on network thread | 159 // from |http_server_properties_impl_|. This gets the data on network thread |
163 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref | 160 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref |
164 // thread. | 161 // thread. |
165 void UpdatePrefsFromCacheOnNetworkThread(); | 162 void UpdatePrefsFromCacheOnNetworkThread(); |
166 | 163 |
167 // Same as above, but fires an optional |completion| callback on pref thread | 164 // Same as above, but fires an optional |completion| callback on pref thread |
168 // when finished. Virtual for testing. | 165 // when finished. Virtual for testing. |
169 virtual void UpdatePrefsFromCacheOnNetworkThread( | 166 virtual void UpdatePrefsFromCacheOnNetworkThread( |
170 const base::Closure& completion); | 167 const base::Closure& completion); |
171 | 168 |
172 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an | 169 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an |
173 // optional |completion| callback when finished. Protected for testing. | 170 // optional |completion| callback when finished. Protected for testing. |
174 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, | 171 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, |
175 SpdySettingsMap* spdy_settings_map, | 172 SpdySettingsMap* spdy_settings_map, |
176 AlternateProtocolMap* alternate_protocol_map, | 173 AlternateProtocolMap* alternate_protocol_map, |
177 SupportsQuicMap* supports_quic_map, | 174 IPAddressNumber* last_quic_address, |
178 ServerNetworkStatsMap* server_network_stats_map, | 175 ServerNetworkStatsMap* server_network_stats_map, |
179 const base::Closure& completion); | 176 const base::Closure& completion); |
180 | 177 |
181 private: | 178 private: |
182 void OnHttpServerPropertiesChanged(); | 179 void OnHttpServerPropertiesChanged(); |
183 | 180 |
| 181 bool ReadSupportsQuic(const base::DictionaryValue& server_dict, |
| 182 IPAddressNumber* last_quic_address); |
184 void AddToSpdySettingsMap(const HostPortPair& server, | 183 void AddToSpdySettingsMap(const HostPortPair& server, |
185 const base::DictionaryValue& server_dict, | 184 const base::DictionaryValue& server_dict, |
186 SpdySettingsMap* spdy_settings_map); | 185 SpdySettingsMap* spdy_settings_map); |
187 bool AddToAlternateProtocolMap(const HostPortPair& server, | 186 bool AddToAlternateProtocolMap(const HostPortPair& server, |
188 const base::DictionaryValue& server_dict, | 187 const base::DictionaryValue& server_dict, |
189 AlternateProtocolMap* alternate_protocol_map); | 188 AlternateProtocolMap* alternate_protocol_map); |
190 bool AddToSupportsQuicMap(const HostPortPair& server, | |
191 const base::DictionaryValue& server_dict, | |
192 SupportsQuicMap* supports_quic_map); | |
193 bool AddToNetworkStatsMap(const HostPortPair& server, | 189 bool AddToNetworkStatsMap(const HostPortPair& server, |
194 const base::DictionaryValue& server_dict, | 190 const base::DictionaryValue& server_dict, |
195 ServerNetworkStatsMap* network_stats_map); | 191 ServerNetworkStatsMap* network_stats_map); |
196 | 192 |
197 void SaveSpdySettingsToServerPrefs(const SettingsMap* spdy_settings_map, | 193 void SaveSpdySettingsToServerPrefs(const SettingsMap* spdy_settings_map, |
198 base::DictionaryValue* server_pref_dict); | 194 base::DictionaryValue* server_pref_dict); |
199 void SaveAlternateProtocolToServerPrefs( | 195 void SaveAlternateProtocolToServerPrefs( |
200 const AlternateProtocolInfo* port_alternate_protocol, | 196 const AlternateProtocolInfo* port_alternate_protocol, |
201 base::DictionaryValue* server_pref_dict); | 197 base::DictionaryValue* server_pref_dict); |
202 void SaveSupportsQuicToServerPrefs(const SupportsQuic* supports_quic, | |
203 base::DictionaryValue* server_pref_dict); | |
204 void SaveNetworkStatsToServerPrefs( | 198 void SaveNetworkStatsToServerPrefs( |
205 const ServerNetworkStats* server_network_stats, | 199 const ServerNetworkStats* server_network_stats, |
206 base::DictionaryValue* server_pref_dict); | 200 base::DictionaryValue* server_pref_dict); |
207 | 201 |
| 202 void SaveSupportsQuicToPrefs( |
| 203 const IPAddressNumber* last_quic_address, |
| 204 base::DictionaryValue* http_server_properties_dict); |
| 205 |
208 // ----------- | 206 // ----------- |
209 // Pref thread | 207 // Pref thread |
210 // ----------- | 208 // ----------- |
211 | 209 |
212 const scoped_refptr<base::SequencedTaskRunner> pref_task_runner_; | 210 const scoped_refptr<base::SequencedTaskRunner> pref_task_runner_; |
213 | 211 |
214 base::WeakPtr<HttpServerPropertiesManager> pref_weak_ptr_; | 212 base::WeakPtr<HttpServerPropertiesManager> pref_weak_ptr_; |
215 | 213 |
216 // Used to post cache update tasks. | 214 // Used to post cache update tasks. |
217 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > | 215 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > |
(...skipping 24 matching lines...) Expand all Loading... |
242 // Used to get |weak_ptr_| to self on the network thread. | 240 // Used to get |weak_ptr_| to self on the network thread. |
243 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > | 241 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > |
244 network_weak_ptr_factory_; | 242 network_weak_ptr_factory_; |
245 | 243 |
246 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 244 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
247 }; | 245 }; |
248 | 246 |
249 } // namespace net | 247 } // namespace net |
250 | 248 |
251 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 249 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
OLD | NEW |