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