| 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" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // thread. It also posts a task to UI thread to get SPDY Server preferences | 60 // thread. It also posts a task to UI thread to get SPDY Server preferences |
| 61 // from |pref_service_|. | 61 // from |pref_service_|. |
| 62 void InitializeOnIOThread(); | 62 void InitializeOnIOThread(); |
| 63 | 63 |
| 64 // Prepare for shutdown. Must be called on the UI thread, before destruction. | 64 // Prepare for shutdown. Must be called on the UI thread, before destruction. |
| 65 void ShutdownOnUIThread(); | 65 void ShutdownOnUIThread(); |
| 66 | 66 |
| 67 // Register |prefs| for properties managed here. | 67 // Register |prefs| for properties managed here. |
| 68 static void RegisterPrefs(PrefService* prefs); | 68 static void RegisterPrefs(PrefService* prefs); |
| 69 | 69 |
| 70 // Deletes all data. Works asynchronously, but if a |completion| callback is |
| 71 // provided, it will be fired on the UI thread when everything is done. |
| 72 void Clear(const base::Closure& completion); |
| 73 |
| 70 // ---------------------------------- | 74 // ---------------------------------- |
| 71 // net::HttpServerProperties methods: | 75 // net::HttpServerProperties methods: |
| 72 // ---------------------------------- | 76 // ---------------------------------- |
| 73 | 77 |
| 74 // Deletes all data. | 78 // Deletes all data. Works asynchronously. |
| 75 virtual void Clear() OVERRIDE; | 79 virtual void Clear() OVERRIDE; |
| 76 | 80 |
| 77 // Returns true if |server| supports SPDY. Should only be called from IO | 81 // Returns true if |server| supports SPDY. Should only be called from IO |
| 78 // thread. | 82 // thread. |
| 79 virtual bool SupportsSpdy(const net::HostPortPair& server) const OVERRIDE; | 83 virtual bool SupportsSpdy(const net::HostPortPair& server) const OVERRIDE; |
| 80 | 84 |
| 81 // Add |server| as the SPDY server which supports SPDY protocol into the | 85 // Add |server| as the SPDY server which supports SPDY protocol into the |
| 82 // persisitent store. Should only be called from IO thread. | 86 // persisitent store. Should only be called from IO thread. |
| 83 virtual void SetSupportsSpdy(const net::HostPortPair& server, | 87 virtual void SetSupportsSpdy(const net::HostPortPair& server, |
| 84 bool support_spdy) OVERRIDE; | 88 bool support_spdy) OVERRIDE; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 171 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. |
| 168 void ScheduleUpdatePrefsOnIO(); | 172 void ScheduleUpdatePrefsOnIO(); |
| 169 | 173 |
| 170 // Starts the timers to update the prefs from cache. This are overridden in | 174 // Starts the timers to update the prefs from cache. This are overridden in |
| 171 // tests to prevent the delay. | 175 // tests to prevent the delay. |
| 172 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); | 176 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); |
| 173 | 177 |
| 174 // Update prefs::kHttpServerProperties in preferences with the cached data | 178 // Update prefs::kHttpServerProperties in preferences with the cached data |
| 175 // from |http_server_properties_impl_|. This gets the data on IO thread and | 179 // from |http_server_properties_impl_|. This gets the data on IO thread and |
| 176 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. | 180 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. |
| 177 // Virtual for testing. | 181 void UpdatePrefsFromCacheOnIO(); |
| 178 virtual void UpdatePrefsFromCacheOnIO(); | |
| 179 | 182 |
| 180 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for | 183 // Same as above, but fires an optional |completion| callback on the UI thread |
| 181 // testing. | 184 // when finished. Virtual for testing. |
| 185 virtual void UpdatePrefsFromCacheOnIO(const base::Closure& completion); |
| 186 |
| 187 // Update prefs::kHttpServerProperties preferences on UI thread. Executes an |
| 188 // optional |completion| callback when finished. Protected for testing. |
| 182 void UpdatePrefsOnUI( | 189 void UpdatePrefsOnUI( |
| 183 base::ListValue* spdy_server_list, | 190 base::ListValue* spdy_server_list, |
| 184 net::SpdySettingsMap* spdy_settings_map, | 191 net::SpdySettingsMap* spdy_settings_map, |
| 185 net::AlternateProtocolMap* alternate_protocol_map, | 192 net::AlternateProtocolMap* alternate_protocol_map, |
| 186 net::PipelineCapabilityMap* pipeline_capability_map); | 193 net::PipelineCapabilityMap* pipeline_capability_map, |
| 194 const base::Closure& completion); |
| 187 | 195 |
| 188 private: | 196 private: |
| 189 // Callback for preference changes. | 197 // Callback for preference changes. |
| 190 virtual void OnPreferenceChanged(PrefServiceBase* service, | 198 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 191 const std::string& pref_name) OVERRIDE; | 199 const std::string& pref_name) OVERRIDE; |
| 192 | 200 |
| 193 // --------- | 201 // --------- |
| 194 // UI thread | 202 // UI thread |
| 195 // --------- | 203 // --------- |
| 196 | 204 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 218 io_prefs_update_timer_; | 226 io_prefs_update_timer_; |
| 219 | 227 |
| 220 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; | 228 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; |
| 221 | 229 |
| 222 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 230 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
| 223 }; | 231 }; |
| 224 | 232 |
| 225 } // namespace chrome_browser_net | 233 } // namespace chrome_browser_net |
| 226 | 234 |
| 227 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 235 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| OLD | NEW |