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

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
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>
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/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
16 #include "base/timer.h" 15 #include "base/timer.h"
17 #include "base/values.h" 16 #include "base/values.h"
18 #include "chrome/browser/prefs/pref_change_registrar.h" 17 #include "chrome/browser/prefs/pref_change_registrar.h"
19 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
20 #include "net/base/host_port_pair.h" 19 #include "net/base/host_port_pair.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
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 net::AlternateProtocol alternate_protocol) OVERRIDE; 99 net::AlternateProtocol alternate_protocol) OVERRIDE;
101 100
102 // Sets the Alternate-Protocol for |server| to be BROKEN. 101 // Sets the Alternate-Protocol for |server| to be BROKEN.
103 virtual void SetBrokenAlternateProtocol( 102 virtual void SetBrokenAlternateProtocol(
104 const net::HostPortPair& server) OVERRIDE; 103 const net::HostPortPair& server) OVERRIDE;
105 104
106 // Returns all Alternate-Protocol mappings. 105 // Returns all Alternate-Protocol mappings.
107 virtual const net::AlternateProtocolMap& 106 virtual const net::AlternateProtocolMap&
108 alternate_protocol_map() const OVERRIDE; 107 alternate_protocol_map() const OVERRIDE;
109 108
109 // Gets a reference to the SpdySettings stored for a host.
110 // If no settings are stored, returns an empty set of settings.
111 virtual const spdy::SpdySettings& GetSpdySettings(
112 const net::HostPortPair& host_port_pair) const OVERRIDE;
113
114 // Saves settings for a host. Returns true if SpdySettings are persisted.
115 virtual bool SetSpdySettings(
116 const net::HostPortPair& host_port_pair,
117 const spdy::SpdySettings& settings) OVERRIDE;
118
119 // Clears all spdy_settings.
120 virtual void ClearSpdySettings() OVERRIDE;
121
122 // Returns all SpdySettings mappings.
123 virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE;
124
110 protected: 125 protected:
111 typedef base::RefCountedData<base::ListValue> RefCountedListValue;
112 typedef base::RefCountedData<net::AlternateProtocolMap>
113 RefCountedAlternateProtocolMap;
114
115 // -------------------- 126 // --------------------
116 // SPDY related methods 127 // SPDY related methods
117 128
118 // These are used to delay updating the spdy servers in 129 // These are used to delay updating of the cached data in
119 // |http_server_properties_impl_| while the preferences are changing, and 130 // |http_server_properties_impl_| while the preferences are changing, and
120 // execute only one update per simultaneous prefs changes. 131 // execute only one update per simultaneous prefs changes.
121 void ScheduleUpdateSpdyCacheOnUI(); 132 void ScheduleUpdateCacheOnUI();
122 133
123 // Update spdy servers (the cached data in |http_server_properties_impl_|) 134 // Starts the timers to update the cached prefs. This are overridden in tests
124 // with data from preferences. Virtual for testing. 135 // to prevent the delay.
125 virtual void UpdateSpdyCacheFromPrefs(); 136 virtual void StartCacheUpdateTimerOnUI(base::TimeDelta delay);
126 137
127 // Starts the |spdy_servers| update on the IO thread. Protected for testing. 138 // Update cached prefs in |http_server_properties_impl_| with data from
128 void UpdateSpdyCacheFromPrefsOnIO(std::vector<std::string>* spdy_servers, 139 // preferences. It gets the data on UI thread and calls
129 bool support_spdy); 140 // UpdateSpdyServersFromPrefsOnIO() to perform the update on IO thread.
141 virtual void UpdateCacheFromPrefsOnUI();
130 142
131 // These are used to delay updating the preferences when spdy servers_ are 143 // 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. 144 // IO thread. Protected for testing.
133 void ScheduleUpdateSpdyPrefsOnIO(); 145 void UpdateCacheFromPrefsOnIO(
146 std::vector<std::string>* spdy_servers,
147 net::SpdySettingsMap* spdy_settings_map,
148 net::AlternateProtocolMap* alternate_protocol_map);
134 149
135 // Update spdy servers in preferences with the cached data from 150 // These are used to delay updating the preferences when cached data in
136 // |http_server_properties_impl_|. Virtual for testing. 151 // |http_server_properties_impl_| is changing, and execute only one update per
137 virtual void UpdateSpdyPrefsFromCache(); // Virtual for testing. 152 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes.
153 void ScheduleUpdatePrefsOnIO();
138 154
139 // Update |prefs::kSpdyServers| preferences with |spdy_server_list| on UI 155 // Starts the timers to update the prefs from cache. This are overridden in
140 // thread. Protected for testing. 156 // tests to prevent the delay.
141 void SetSpdyServersInPrefsOnUI( 157 virtual void StartPrefsUpdateTimerOnIO(base::TimeDelta delay);
142 scoped_refptr<RefCountedListValue> spdy_server_list);
143 158
144 // Starts the timers to update the cache/prefs. This are overridden in tests 159 // Update prefs::kHttpServerProperties in preferences with the cached data
145 // to prevent the delay. 160 // from |http_server_properties_impl_|. This gets the data on IO thread and
146 virtual void StartSpdyCacheUpdateTimerOnUI(base::TimeDelta delay); 161 // posts a task (UpdatePrefsOnUI) to update the preferences UI thread.
147 virtual void StartSpdyPrefsUpdateTimerOnIO(base::TimeDelta delay); 162 // Virtual for testing.
163 virtual void UpdatePrefsFromCacheOnIO();
148 164
149 // ---------------------------------- 165 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for
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. 166 // testing.
160 virtual void UpdateAlternateProtocolCacheFromPrefs(); 167 void UpdatePrefsOnUI(
161 168 base::ListValue* spdy_server_list,
162 // Starts the |alternate_protocol_servers| update on the IO thread. Protected 169 net::SpdySettingsMap* spdy_settings_map,
163 // for testing. 170 net::AlternateProtocolMap* alternate_protocol_map);
164 void UpdateAlternateProtocolCacheFromPrefsOnIO(
165 RefCountedAlternateProtocolMap* alternate_protocol_map);
166
167 // These are used to delay updating the preferences when Alternate-Protocol
168 // servers_ are changing, and execute only one update per simultaneous
169 // Alternate-Protocol server changes.
170 void ScheduleUpdateAlternateProtocolPrefsOnIO();
171
172 // Update Alternate-Protocol servers in preferences with the cached data from
173 // |http_server_properties_impl_|. Virtual for testing.
174 virtual void UpdateAlternateProtocolPrefsFromCache(); // Virtual for testing.
175
176 // Update |prefs::kAlternateProtocolServers| preferences with
177 // |alternate_protocol_server_list| on UI thread. Protected for testing.
178 void SetAlternateProtocolServersInPrefsOnUI(
179 RefCountedAlternateProtocolMap* alternate_protocol_map);
180
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 171
188 private: 172 private:
189 // Callback for preference changes. 173 // Callback for preference changes.
190 virtual void Observe(int type, 174 virtual void Observe(int type,
191 const content::NotificationSource& source, 175 const content::NotificationSource& source,
192 const content::NotificationDetails& details); 176 const content::NotificationDetails& details);
193 177
194 // --------- 178 // ---------
195 // UI thread 179 // UI thread
196 // --------- 180 // ---------
197 181
198 // Used to get |weak_ptr_| to self on the UI thread. 182 // Used to get |weak_ptr_| to self on the UI thread.
199 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > 183 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> >
200 ui_weak_ptr_factory_; 184 ui_weak_ptr_factory_;
201 185
202 base::WeakPtr<HttpServerPropertiesManager> ui_weak_ptr_; 186 base::WeakPtr<HttpServerPropertiesManager> ui_weak_ptr_;
203 187
204 // Used to post SPDY cache update tasks. 188 // Used to post cache update tasks.
205 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > 189 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> >
206 ui_spdy_cache_update_timer_; 190 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 191
212 // Used to track the spdy servers changes. 192 // Used to track the spdy servers changes.
213 PrefChangeRegistrar pref_change_registrar_; 193 PrefChangeRegistrar pref_change_registrar_;
214 PrefService* pref_service_; // Weak. 194 PrefService* pref_service_; // Weak.
215 bool setting_spdy_servers_; 195 bool setting_prefs_;
216 bool setting_alternate_protocol_servers_;
217 196
218 // --------- 197 // ---------
219 // IO thread 198 // IO thread
220 // --------- 199 // ---------
221 200
222 // Used to post SPDY pref update tasks. 201 // Used to post SPDY pref update tasks.
223 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > 202 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> >
224 io_spdy_prefs_update_timer_; 203 io_spdy_prefs_update_timer_;
willchan no longer on Chromium 2011/11/15 15:44:21 Maybe this should be renamed io_prefs_update_timer
225 204
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_; 205 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_;
231 206
232 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); 207 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager);
233 }; 208 };
234 209
235 } // namespace chrome_browser_net 210 } // namespace chrome_browser_net
236 211
237 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ 212 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698