| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 149 |
| 151 // Returns all SPDY persistent settings. | 150 // Returns all SPDY persistent settings. |
| 152 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE; | 151 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE; |
| 153 | 152 |
| 154 virtual void SetServerNetworkStats(const net::HostPortPair& host_port_pair, | 153 virtual void SetServerNetworkStats(const net::HostPortPair& host_port_pair, |
| 155 NetworkStats stats) OVERRIDE; | 154 NetworkStats stats) OVERRIDE; |
| 156 | 155 |
| 157 virtual const NetworkStats* GetServerNetworkStats( | 156 virtual const NetworkStats* GetServerNetworkStats( |
| 158 const net::HostPortPair& host_port_pair) const OVERRIDE; | 157 const net::HostPortPair& host_port_pair) const OVERRIDE; |
| 159 | 158 |
| 160 virtual net::HttpPipelinedHostCapability GetPipelineCapability( | |
| 161 const net::HostPortPair& origin) OVERRIDE; | |
| 162 | |
| 163 virtual void SetPipelineCapability( | |
| 164 const net::HostPortPair& origin, | |
| 165 net::HttpPipelinedHostCapability capability) OVERRIDE; | |
| 166 | |
| 167 virtual void ClearPipelineCapabilities() OVERRIDE; | |
| 168 | |
| 169 virtual net::PipelineCapabilityMap GetPipelineCapabilityMap() const OVERRIDE; | |
| 170 | |
| 171 protected: | 159 protected: |
| 172 // -------------------- | 160 // -------------------- |
| 173 // SPDY related methods | 161 // SPDY related methods |
| 174 | 162 |
| 175 // These are used to delay updating of the cached data in | 163 // These are used to delay updating of the cached data in |
| 176 // |http_server_properties_impl_| while the preferences are changing, and | 164 // |http_server_properties_impl_| while the preferences are changing, and |
| 177 // execute only one update per simultaneous prefs changes. | 165 // execute only one update per simultaneous prefs changes. |
| 178 void ScheduleUpdateCacheOnUI(); | 166 void ScheduleUpdateCacheOnUI(); |
| 179 | 167 |
| 180 // Starts the timers to update the cached prefs. This are overridden in tests | 168 // Starts the timers to update the cached prefs. This are overridden in tests |
| 181 // to prevent the delay. | 169 // to prevent the delay. |
| 182 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay); | 170 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay); |
| 183 | 171 |
| 184 // Update cached prefs in |http_server_properties_impl_| with data from | 172 // Update cached prefs in |http_server_properties_impl_| with data from |
| 185 // preferences. It gets the data on UI thread and calls | 173 // preferences. It gets the data on UI thread and calls |
| 186 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread. | 174 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread. |
| 187 virtual void UpdateCacheFromPrefsOnUI(); | 175 virtual void UpdateCacheFromPrefsOnUI(); |
| 188 | 176 |
| 189 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 177 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
| 190 // IO thread. Protected for testing. | 178 // IO thread. Protected for testing. |
| 191 void UpdateCacheFromPrefsOnIO( | 179 void UpdateCacheFromPrefsOnIO( |
| 192 std::vector<std::string>* spdy_servers, | 180 std::vector<std::string>* spdy_servers, |
| 193 net::SpdySettingsMap* spdy_settings_map, | 181 net::SpdySettingsMap* spdy_settings_map, |
| 194 net::AlternateProtocolMap* alternate_protocol_map, | 182 net::AlternateProtocolMap* alternate_protocol_map, |
| 195 net::PipelineCapabilityMap* pipeline_capability_map, | |
| 196 bool detected_corrupted_prefs); | 183 bool detected_corrupted_prefs); |
| 197 | 184 |
| 198 // These are used to delay updating the preferences when cached data in | 185 // These are used to delay updating the preferences when cached data in |
| 199 // |http_server_properties_impl_| is changing, and execute only one update per | 186 // |http_server_properties_impl_| is changing, and execute only one update per |
| 200 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 187 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. |
| 201 void ScheduleUpdatePrefsOnIO(); | 188 void ScheduleUpdatePrefsOnIO(); |
| 202 | 189 |
| 203 // Starts the timers to update the prefs from cache. This are overridden in | 190 // Starts the timers to update the prefs from cache. This are overridden in |
| 204 // tests to prevent the delay. | 191 // tests to prevent the delay. |
| 205 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); | 192 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); |
| 206 | 193 |
| 207 // Update prefs::kHttpServerProperties in preferences with the cached data | 194 // Update prefs::kHttpServerProperties in preferences with the cached data |
| 208 // from |http_server_properties_impl_|. This gets the data on IO thread and | 195 // from |http_server_properties_impl_|. This gets the data on IO thread and |
| 209 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. | 196 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. |
| 210 void UpdatePrefsFromCacheOnIO(); | 197 void UpdatePrefsFromCacheOnIO(); |
| 211 | 198 |
| 212 // Same as above, but fires an optional |completion| callback on the UI thread | 199 // Same as above, but fires an optional |completion| callback on the UI thread |
| 213 // when finished. Virtual for testing. | 200 // when finished. Virtual for testing. |
| 214 virtual void UpdatePrefsFromCacheOnIO(const base::Closure& completion); | 201 virtual void UpdatePrefsFromCacheOnIO(const base::Closure& completion); |
| 215 | 202 |
| 216 // Update prefs::kHttpServerProperties preferences on UI thread. Executes an | 203 // Update prefs::kHttpServerProperties preferences on UI thread. Executes an |
| 217 // optional |completion| callback when finished. Protected for testing. | 204 // optional |completion| callback when finished. Protected for testing. |
| 218 void UpdatePrefsOnUI( | 205 void UpdatePrefsOnUI( |
| 219 base::ListValue* spdy_server_list, | 206 base::ListValue* spdy_server_list, |
| 220 net::SpdySettingsMap* spdy_settings_map, | 207 net::SpdySettingsMap* spdy_settings_map, |
| 221 net::AlternateProtocolMap* alternate_protocol_map, | 208 net::AlternateProtocolMap* alternate_protocol_map, |
| 222 net::PipelineCapabilityMap* pipeline_capability_map, | |
| 223 const base::Closure& completion); | 209 const base::Closure& completion); |
| 224 | 210 |
| 225 private: | 211 private: |
| 226 void OnHttpServerPropertiesChanged(); | 212 void OnHttpServerPropertiesChanged(); |
| 227 | 213 |
| 228 // --------- | 214 // --------- |
| 229 // UI thread | 215 // UI thread |
| 230 // --------- | 216 // --------- |
| 231 | 217 |
| 232 // Used to get |weak_ptr_| to self on the UI thread. | 218 // Used to get |weak_ptr_| to self on the UI thread. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 257 io_prefs_update_timer_; | 243 io_prefs_update_timer_; |
| 258 | 244 |
| 259 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; | 245 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; |
| 260 | 246 |
| 261 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 247 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
| 262 }; | 248 }; |
| 263 | 249 |
| 264 } // namespace chrome_browser_net | 250 } // namespace chrome_browser_net |
| 265 | 251 |
| 266 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 252 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| OLD | NEW |