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 CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
6 #define CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 6 #define CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
18 #include "net/http/http_pipelined_host_capability.h" | |
19 #include "net/http/http_server_properties.h" | 18 #include "net/http/http_server_properties.h" |
20 #include "net/http/http_server_properties_impl.h" | 19 #include "net/http/http_server_properties_impl.h" |
21 | 20 |
22 class PrefService; | 21 class PrefService; |
23 | 22 |
24 namespace user_prefs { | 23 namespace user_prefs { |
25 class PrefRegistrySyncable; | 24 class PrefRegistrySyncable; |
26 } | 25 } |
27 | 26 |
28 namespace chrome_browser_net { | 27 namespace chrome_browser_net { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 155 |
157 // Returns all SPDY persistent settings. | 156 // Returns all SPDY persistent settings. |
158 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE; | 157 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE; |
159 | 158 |
160 virtual void SetServerNetworkStats(const net::HostPortPair& host_port_pair, | 159 virtual void SetServerNetworkStats(const net::HostPortPair& host_port_pair, |
161 NetworkStats stats) OVERRIDE; | 160 NetworkStats stats) OVERRIDE; |
162 | 161 |
163 virtual const NetworkStats* GetServerNetworkStats( | 162 virtual const NetworkStats* GetServerNetworkStats( |
164 const net::HostPortPair& host_port_pair) const OVERRIDE; | 163 const net::HostPortPair& host_port_pair) const OVERRIDE; |
165 | 164 |
166 virtual net::HttpPipelinedHostCapability GetPipelineCapability( | |
167 const net::HostPortPair& origin) OVERRIDE; | |
168 | |
169 virtual void SetPipelineCapability( | |
170 const net::HostPortPair& origin, | |
171 net::HttpPipelinedHostCapability capability) OVERRIDE; | |
172 | |
173 virtual void ClearPipelineCapabilities() OVERRIDE; | |
174 | |
175 virtual net::PipelineCapabilityMap GetPipelineCapabilityMap() const OVERRIDE; | |
176 | |
177 protected: | 165 protected: |
178 // -------------------- | 166 // -------------------- |
179 // SPDY related methods | 167 // SPDY related methods |
180 | 168 |
181 // These are used to delay updating of the cached data in | 169 // These are used to delay updating of the cached data in |
182 // |http_server_properties_impl_| while the preferences are changing, and | 170 // |http_server_properties_impl_| while the preferences are changing, and |
183 // execute only one update per simultaneous prefs changes. | 171 // execute only one update per simultaneous prefs changes. |
184 void ScheduleUpdateCacheOnUI(); | 172 void ScheduleUpdateCacheOnUI(); |
185 | 173 |
186 // Starts the timers to update the cached prefs. This are overridden in tests | 174 // Starts the timers to update the cached prefs. This are overridden in tests |
187 // to prevent the delay. | 175 // to prevent the delay. |
188 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay); | 176 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay); |
189 | 177 |
190 // Update cached prefs in |http_server_properties_impl_| with data from | 178 // Update cached prefs in |http_server_properties_impl_| with data from |
191 // preferences. It gets the data on UI thread and calls | 179 // preferences. It gets the data on UI thread and calls |
192 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread. | 180 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread. |
193 virtual void UpdateCacheFromPrefsOnUI(); | 181 virtual void UpdateCacheFromPrefsOnUI(); |
194 | 182 |
195 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 183 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
196 // IO thread. Protected for testing. | 184 // IO thread. Protected for testing. |
197 void UpdateCacheFromPrefsOnIO( | 185 void UpdateCacheFromPrefsOnIO( |
198 std::vector<std::string>* spdy_servers, | 186 std::vector<std::string>* spdy_servers, |
199 net::SpdySettingsMap* spdy_settings_map, | 187 net::SpdySettingsMap* spdy_settings_map, |
200 net::AlternateProtocolMap* alternate_protocol_map, | 188 net::AlternateProtocolMap* alternate_protocol_map, |
201 net::PipelineCapabilityMap* pipeline_capability_map, | |
202 net::AlternateProtocolExperiment alternate_protocol_experiment, | 189 net::AlternateProtocolExperiment alternate_protocol_experiment, |
203 bool detected_corrupted_prefs); | 190 bool detected_corrupted_prefs); |
204 | 191 |
205 // These are used to delay updating the preferences when cached data in | 192 // These are used to delay updating the preferences when cached data in |
206 // |http_server_properties_impl_| is changing, and execute only one update per | 193 // |http_server_properties_impl_| is changing, and execute only one update per |
207 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 194 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. |
208 void ScheduleUpdatePrefsOnIO(); | 195 void ScheduleUpdatePrefsOnIO(); |
209 | 196 |
210 // Starts the timers to update the prefs from cache. This are overridden in | 197 // Starts the timers to update the prefs from cache. This are overridden in |
211 // tests to prevent the delay. | 198 // tests to prevent the delay. |
212 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); | 199 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); |
213 | 200 |
214 // Update prefs::kHttpServerProperties in preferences with the cached data | 201 // Update prefs::kHttpServerProperties in preferences with the cached data |
215 // from |http_server_properties_impl_|. This gets the data on IO thread and | 202 // from |http_server_properties_impl_|. This gets the data on IO thread and |
216 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. | 203 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. |
217 void UpdatePrefsFromCacheOnIO(); | 204 void UpdatePrefsFromCacheOnIO(); |
218 | 205 |
219 // Same as above, but fires an optional |completion| callback on the UI thread | 206 // Same as above, but fires an optional |completion| callback on the UI thread |
220 // when finished. Virtual for testing. | 207 // when finished. Virtual for testing. |
221 virtual void UpdatePrefsFromCacheOnIO(const base::Closure& completion); | 208 virtual void UpdatePrefsFromCacheOnIO(const base::Closure& completion); |
222 | 209 |
223 // Update prefs::kHttpServerProperties preferences on UI thread. Executes an | 210 // Update prefs::kHttpServerProperties preferences on UI thread. Executes an |
224 // optional |completion| callback when finished. Protected for testing. | 211 // optional |completion| callback when finished. Protected for testing. |
225 void UpdatePrefsOnUI( | 212 void UpdatePrefsOnUI( |
226 base::ListValue* spdy_server_list, | 213 base::ListValue* spdy_server_list, |
227 net::SpdySettingsMap* spdy_settings_map, | 214 net::SpdySettingsMap* spdy_settings_map, |
228 net::AlternateProtocolMap* alternate_protocol_map, | 215 net::AlternateProtocolMap* alternate_protocol_map, |
229 net::PipelineCapabilityMap* pipeline_capability_map, | |
230 const base::Closure& completion); | 216 const base::Closure& completion); |
231 | 217 |
232 private: | 218 private: |
233 void OnHttpServerPropertiesChanged(); | 219 void OnHttpServerPropertiesChanged(); |
234 | 220 |
235 // --------- | 221 // --------- |
236 // UI thread | 222 // UI thread |
237 // --------- | 223 // --------- |
238 | 224 |
239 // Used to get |weak_ptr_| to self on the UI thread. | 225 // Used to get |weak_ptr_| to self on the UI thread. |
(...skipping 24 matching lines...) Expand all Loading... |
264 io_prefs_update_timer_; | 250 io_prefs_update_timer_; |
265 | 251 |
266 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; | 252 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; |
267 | 253 |
268 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 254 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
269 }; | 255 }; |
270 | 256 |
271 } // namespace chrome_browser_net | 257 } // namespace chrome_browser_net |
272 | 258 |
273 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 259 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
OLD | NEW |