Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1064)

Side by Side Diff: chrome/browser/net/http_server_properties_manager.h

Issue 8423028: Persist dynamically learned SPDY settings (like CWND). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/net/http_server_properties_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 net::AlternateProtocol alternate_protocol) OVERRIDE; 100 net::AlternateProtocol alternate_protocol) OVERRIDE;
101 101
102 // Sets the Alternate-Protocol for |server| to be BROKEN. 102 // Sets the Alternate-Protocol for |server| to be BROKEN.
103 virtual void SetBrokenAlternateProtocol( 103 virtual void SetBrokenAlternateProtocol(
104 const net::HostPortPair& server) OVERRIDE; 104 const net::HostPortPair& server) OVERRIDE;
105 105
106 // Returns all Alternate-Protocol mappings. 106 // Returns all Alternate-Protocol mappings.
107 virtual const net::AlternateProtocolMap& 107 virtual const net::AlternateProtocolMap&
108 alternate_protocol_map() const OVERRIDE; 108 alternate_protocol_map() const OVERRIDE;
109 109
110 // Gets a reference to the SpdySettings stored for a host.
111 // If no settings are stored, returns an empty set of settings.
112 virtual const spdy::SpdySettings& GetSpdySettings(
113 const net::HostPortPair& host_port_pair) const OVERRIDE;
114
115 // Saves settings for a host. Returns true if SpdySettings are persisted.
116 virtual bool SetSpdySettings(
117 const net::HostPortPair& host_port_pair,
118 const spdy::SpdySettings& settings) OVERRIDE;
119
120 // Clears all spdy_settings.
121 virtual void ClearSpdySettings() OVERRIDE;
122
123 // Returns all SpdySettings mappings.
124 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE;
125
110 protected: 126 protected:
111 typedef base::RefCountedData<base::ListValue> RefCountedListValue; 127 struct RefCountedListValue
willchan no longer on Chromium 2011/11/10 19:00:59 Now that base::Owned() is available, please use it
112 typedef base::RefCountedData<net::AlternateProtocolMap> 128 : public base::RefCountedThreadSafe<RefCountedListValue> {
113 RefCountedAlternateProtocolMap; 129 base::ListValue data;
130 };
131
132 struct RefCountedAlternateProtocolMap
133 : public base::RefCountedThreadSafe<RefCountedAlternateProtocolMap> {
134 RefCountedAlternateProtocolMap() {}
135 ~RefCountedAlternateProtocolMap() {}
136 net::AlternateProtocolMap data;
137 };
138
139 struct RefCountedSpdySettingsMap
140 : public base::RefCountedThreadSafe<RefCountedSpdySettingsMap> {
141 RefCountedSpdySettingsMap() {}
142 ~RefCountedSpdySettingsMap() {}
143 net::SpdySettingsMap data;
144 };
114 145
115 // -------------------- 146 // --------------------
116 // SPDY related methods 147 // SPDY related methods
117 148
118 // These are used to delay updating the spdy servers in 149 // These are used to delay updating of the cached data in
119 // |http_server_properties_impl_| while the preferences are changing, and 150 // |http_server_properties_impl_| while the preferences are changing, and
120 // execute only one update per simultaneous prefs changes. 151 // execute only one update per simultaneous prefs changes.
121 void ScheduleUpdateSpdyCacheOnUI(); 152 void ScheduleUpdateCacheOnUI();
122 153
123 // Update spdy servers (the cached data in |http_server_properties_impl_|) 154 // Starts the timers to update the cached prefs. This are overridden in tests
124 // with data from preferences. Virtual for testing. 155 // to prevent the delay.
125 virtual void UpdateSpdyCacheFromPrefs(); 156 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay);
126 157
127 // Starts the |spdy_servers| update on the IO thread. Protected for testing. 158 // Update cached prefs in |http_server_properties_impl_| with data from
128 void UpdateSpdyCacheFromPrefsOnIO(std::vector<std::string>* spdy_servers, 159 // preferences. It gets the data on UI thread and calls
129 bool support_spdy); 160 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread.
161 virtual void UpdateCacheFromPrefsOnUI();
130 162
131 // These are used to delay updating the preferences when spdy servers_ are 163 // Starts the update of cached prefs in |http_server_properties_impl_| on the
132 // changing, and execute only one update per simultaneous spdy server changes. 164 // IO thread. Protected for testing.
133 void ScheduleUpdateSpdyPrefsOnIO(); 165 void UpdateCacheFromPrefsOnIO(
134 166 std::vector<std::string>* spdy_servers,
135 // Update spdy servers in preferences with the cached data from 167 RefCountedSpdySettingsMap* spdy_settings_map,
136 // |http_server_properties_impl_|. Virtual for testing.
137 virtual void UpdateSpdyPrefsFromCache(); // Virtual for testing.
138
139 // Update |prefs::kSpdyServers| preferences with |spdy_server_list| on UI
140 // thread. Protected for testing.
141 void SetSpdyServersInPrefsOnUI(
142 scoped_refptr<RefCountedListValue> spdy_server_list);
143
144 // Starts the timers to update the cache/prefs. This are overridden in tests
145 // to prevent the delay.
146 virtual void StartSpdyCacheUpdateTimerOnUI(base::TimeDelta delay);
147 virtual void StartSpdyPrefsUpdateTimerOnIO(base::TimeDelta delay);
148
149 // ----------------------------------
150 // Alternate-Protocol related methods
151
152 // These are used to delay updating the Alternate-Protocol servers in
153 // |http_server_properties_impl_| while the preferences are changing, and
154 // execute only one update per simultaneous prefs changes.
155 void ScheduleUpdateAlternateProtocolCacheOnUI();
156
157 // Update Alternate-Protocol servers (the cached data in
158 // |http_server_properties_impl_|) with data from preferences. Virtual for
159 // testing.
160 virtual void UpdateAlternateProtocolCacheFromPrefs();
161
162 // Starts the |alternate_protocol_servers| update on the IO thread. Protected
163 // for testing.
164 void UpdateAlternateProtocolCacheFromPrefsOnIO(
165 RefCountedAlternateProtocolMap* alternate_protocol_map); 168 RefCountedAlternateProtocolMap* alternate_protocol_map);
166 169
167 // These are used to delay updating the preferences when Alternate-Protocol 170 // These are used to delay updating the preferences when cached data in
168 // servers_ are changing, and execute only one update per simultaneous 171 // |http_server_properties_impl_| is changing, and execute only one update per
169 // Alternate-Protocol server changes. 172 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes.
170 void ScheduleUpdateAlternateProtocolPrefsOnIO(); 173 void ScheduleUpdatePrefsOnIO();
171 174
172 // Update Alternate-Protocol servers in preferences with the cached data from 175 // Starts the timers to update the prefs from cache. This are overridden in
173 // |http_server_properties_impl_|. Virtual for testing. 176 // tests to prevent the delay.
174 virtual void UpdateAlternateProtocolPrefsFromCache(); // Virtual for testing. 177 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay);
175 178
176 // Update |prefs::kAlternateProtocolServers| preferences with 179 // Update prefs::kHttpServerProperties in preferences with the cached data
177 // |alternate_protocol_server_list| on UI thread. Protected for testing. 180 // from |http_server_properties_impl_|. This gets the data on IO thread and
178 void SetAlternateProtocolServersInPrefsOnUI( 181 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread.
182 // Virtual for testing.
183 virtual void UpdatePrefsFromCacheOnIO();
184
185 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for
186 // testing.
187 void UpdatePrefsOnUI(
188 scoped_refptr<RefCountedListValue> spdy_server_list,
189 RefCountedSpdySettingsMap* spdy_settings_map,
179 RefCountedAlternateProtocolMap* alternate_protocol_map); 190 RefCountedAlternateProtocolMap* alternate_protocol_map);
180 191
181 // Starts the timers to update the cache/prefs. This are overridden in tests
182 // to prevent the delay.
183 virtual void StartAlternateProtocolCacheUpdateTimerOnUI(
184 base::TimeDelta delay);
185 virtual void StartAlternateProtocolPrefsUpdateTimerOnIO(
186 base::TimeDelta delay);
187
188 private: 192 private:
189 // Callback for preference changes. 193 // Callback for preference changes.
190 virtual void Observe(int type, 194 virtual void Observe(int type,
191 const content::NotificationSource& source, 195 const content::NotificationSource& source,
192 const content::NotificationDetails& details); 196 const content::NotificationDetails& details);
193 197
194 // --------- 198 // ---------
195 // UI thread 199 // UI thread
196 // --------- 200 // ---------
197 201
198 // Used to get |weak_ptr_| to self on the UI thread. 202 // Used to get |weak_ptr_| to self on the UI thread.
199 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > 203 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> >
200 ui_weak_ptr_factory_; 204 ui_weak_ptr_factory_;
201 205
202 base::WeakPtr<HttpServerPropertiesManager> ui_weak_ptr_; 206 base::WeakPtr<HttpServerPropertiesManager> ui_weak_ptr_;
203 207
204 // Used to post SPDY cache update tasks. 208 // Used to post cache update tasks.
205 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > 209 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> >
206 ui_spdy_cache_update_timer_; 210 ui_cache_update_timer_;
207
208 // Used to post Alternate-Protocol cache update tasks.
209 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> >
210 ui_alternate_protocol_cache_update_timer_;
211 211
212 // Used to track the spdy servers changes. 212 // Used to track the spdy servers changes.
213 PrefChangeRegistrar pref_change_registrar_; 213 PrefChangeRegistrar pref_change_registrar_;
214 PrefService* pref_service_; // Weak. 214 PrefService* pref_service_; // Weak.
215 bool setting_spdy_servers_; 215 bool setting_prefs_;
216 bool setting_alternate_protocol_servers_;
217 216
218 // --------- 217 // ---------
219 // IO thread 218 // IO thread
220 // --------- 219 // ---------
221 220
222 // Used to post SPDY pref update tasks. 221 // Used to post SPDY pref update tasks.
223 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > 222 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> >
224 io_spdy_prefs_update_timer_; 223 io_spdy_prefs_update_timer_;
225 224
226 // Used to post Alternate-Protocol pref update tasks.
227 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> >
228 io_alternate_protocol_prefs_update_timer_;
229
230 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; 225 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_;
231 226
232 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); 227 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager);
233 }; 228 };
234 229
235 } // namespace chrome_browser_net 230 } // namespace chrome_browser_net
236 231
237 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ 232 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/http_server_properties_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698