| 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 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/prefs/pref_change_registrar.h" | 17 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
| 20 #include "net/http/http_pipelined_host_capability.h" |
| 20 #include "net/http/http_server_properties.h" | 21 #include "net/http/http_server_properties.h" |
| 21 #include "net/http/http_server_properties_impl.h" | 22 #include "net/http/http_server_properties_impl.h" |
| 22 | 23 |
| 23 class PrefService; | 24 class PrefService; |
| 24 | 25 |
| 25 namespace chrome_browser_net { | 26 namespace chrome_browser_net { |
| 26 | 27 |
| 27 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
| 28 // HttpServerPropertiesManager | 29 // HttpServerPropertiesManager |
| 29 | 30 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 virtual bool SetSpdySettings( | 116 virtual bool SetSpdySettings( |
| 116 const net::HostPortPair& host_port_pair, | 117 const net::HostPortPair& host_port_pair, |
| 117 const spdy::SpdySettings& settings) OVERRIDE; | 118 const spdy::SpdySettings& settings) OVERRIDE; |
| 118 | 119 |
| 119 // Clears all spdy_settings. | 120 // Clears all spdy_settings. |
| 120 virtual void ClearSpdySettings() OVERRIDE; | 121 virtual void ClearSpdySettings() OVERRIDE; |
| 121 | 122 |
| 122 // Returns all SpdySettings mappings. | 123 // Returns all SpdySettings mappings. |
| 123 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE; | 124 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE; |
| 124 | 125 |
| 126 virtual net::HttpPipelinedHostCapability GetPipelineCapability( |
| 127 const net::HostPortPair& origin) OVERRIDE; |
| 128 |
| 129 virtual void SetPipelineCapability( |
| 130 const net::HostPortPair& origin, |
| 131 net::HttpPipelinedHostCapability capability) OVERRIDE; |
| 132 |
| 133 virtual void ClearPipelineCapabilities() OVERRIDE; |
| 134 |
| 135 virtual net::PipelineCapabilityMap GetPipelineCapabilityMap() const OVERRIDE; |
| 136 |
| 125 protected: | 137 protected: |
| 126 // -------------------- | 138 // -------------------- |
| 127 // SPDY related methods | 139 // SPDY related methods |
| 128 | 140 |
| 129 // These are used to delay updating of the cached data in | 141 // These are used to delay updating of the cached data in |
| 130 // |http_server_properties_impl_| while the preferences are changing, and | 142 // |http_server_properties_impl_| while the preferences are changing, and |
| 131 // execute only one update per simultaneous prefs changes. | 143 // execute only one update per simultaneous prefs changes. |
| 132 void ScheduleUpdateCacheOnUI(); | 144 void ScheduleUpdateCacheOnUI(); |
| 133 | 145 |
| 134 // Starts the timers to update the cached prefs. This are overridden in tests | 146 // Starts the timers to update the cached prefs. This are overridden in tests |
| 135 // to prevent the delay. | 147 // to prevent the delay. |
| 136 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay); | 148 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay); |
| 137 | 149 |
| 138 // Update cached prefs in |http_server_properties_impl_| with data from | 150 // Update cached prefs in |http_server_properties_impl_| with data from |
| 139 // preferences. It gets the data on UI thread and calls | 151 // preferences. It gets the data on UI thread and calls |
| 140 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread. | 152 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread. |
| 141 virtual void UpdateCacheFromPrefsOnUI(); | 153 virtual void UpdateCacheFromPrefsOnUI(); |
| 142 | 154 |
| 143 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 155 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
| 144 // IO thread. Protected for testing. | 156 // IO thread. Protected for testing. |
| 145 void UpdateCacheFromPrefsOnIO( | 157 void UpdateCacheFromPrefsOnIO( |
| 146 std::vector<std::string>* spdy_servers, | 158 std::vector<std::string>* spdy_servers, |
| 147 net::SpdySettingsMap* spdy_settings_map, | 159 net::SpdySettingsMap* spdy_settings_map, |
| 148 net::AlternateProtocolMap* alternate_protocol_map); | 160 net::AlternateProtocolMap* alternate_protocol_map, |
| 161 net::PipelineCapabilityMap* pipeline_capability_map); |
| 149 | 162 |
| 150 // These are used to delay updating the preferences when cached data in | 163 // These are used to delay updating the preferences when cached data in |
| 151 // |http_server_properties_impl_| is changing, and execute only one update per | 164 // |http_server_properties_impl_| is changing, and execute only one update per |
| 152 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 165 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. |
| 153 void ScheduleUpdatePrefsOnIO(); | 166 void ScheduleUpdatePrefsOnIO(); |
| 154 | 167 |
| 155 // Starts the timers to update the prefs from cache. This are overridden in | 168 // Starts the timers to update the prefs from cache. This are overridden in |
| 156 // tests to prevent the delay. | 169 // tests to prevent the delay. |
| 157 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); | 170 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay); |
| 158 | 171 |
| 159 // Update prefs::kHttpServerProperties in preferences with the cached data | 172 // Update prefs::kHttpServerProperties in preferences with the cached data |
| 160 // from |http_server_properties_impl_|. This gets the data on IO thread and | 173 // from |http_server_properties_impl_|. This gets the data on IO thread and |
| 161 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. | 174 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread. |
| 162 // Virtual for testing. | 175 // Virtual for testing. |
| 163 virtual void UpdatePrefsFromCacheOnIO(); | 176 virtual void UpdatePrefsFromCacheOnIO(); |
| 164 | 177 |
| 165 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for | 178 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for |
| 166 // testing. | 179 // testing. |
| 167 void UpdatePrefsOnUI( | 180 void UpdatePrefsOnUI( |
| 168 base::ListValue* spdy_server_list, | 181 base::ListValue* spdy_server_list, |
| 169 net::SpdySettingsMap* spdy_settings_map, | 182 net::SpdySettingsMap* spdy_settings_map, |
| 170 net::AlternateProtocolMap* alternate_protocol_map); | 183 net::AlternateProtocolMap* alternate_protocol_map, |
| 184 net::PipelineCapabilityMap* pipeline_capability_map); |
| 171 | 185 |
| 172 private: | 186 private: |
| 173 // Callback for preference changes. | 187 // Callback for preference changes. |
| 174 virtual void Observe(int type, | 188 virtual void Observe(int type, |
| 175 const content::NotificationSource& source, | 189 const content::NotificationSource& source, |
| 176 const content::NotificationDetails& details) OVERRIDE; | 190 const content::NotificationDetails& details) OVERRIDE; |
| 177 | 191 |
| 178 // --------- | 192 // --------- |
| 179 // UI thread | 193 // UI thread |
| 180 // --------- | 194 // --------- |
| (...skipping 22 matching lines...) Expand all Loading... |
| 203 io_prefs_update_timer_; | 217 io_prefs_update_timer_; |
| 204 | 218 |
| 205 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; | 219 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; |
| 206 | 220 |
| 207 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 221 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
| 208 }; | 222 }; |
| 209 | 223 |
| 210 } // namespace chrome_browser_net | 224 } // namespace chrome_browser_net |
| 211 | 225 |
| 212 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 226 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| OLD | NEW |