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

Side by Side Diff: net/http/http_server_properties_manager.h

Issue 2894863002: Rename TaskRunner::RunsTasksOnCurrentThread() in //net (Closed)
Patch Set: fixed build error Created 3 years, 7 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_
6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // 42 //
43 // There are two SingleThreadTaskRunners: 43 // There are two SingleThreadTaskRunners:
44 // |pref_task_runner_| should be bound with the pref thread and is used to post 44 // |pref_task_runner_| should be bound with the pref thread and is used to post
45 // cache update to the pref thread; 45 // cache update to the pref thread;
46 // |network_task_runner_| should be bound with the network thread and is used 46 // |network_task_runner_| should be bound with the network thread and is used
47 // to post pref update to the cache thread. 47 // to post pref update to the cache thread.
48 // 48 //
49 // It must be constructed with correct task runners passed in to set up 49 // It must be constructed with correct task runners passed in to set up
50 // |pref_task_runner_| and |network_task_runner| as well as the prefs listeners. 50 // |pref_task_runner_| and |network_task_runner| as well as the prefs listeners.
51 // 51 //
52 // ShutdownOnPrefThread must be called from pref thread before destruction, to 52 // ShutdownOnPrefSequence must be called from pref thread before destruction, to
53 // release the prefs listeners on the pref thread. 53 // release the prefs listeners on the pref thread.
54 // 54 //
55 // Class requires that update tasks from the Pref thread can post safely to the 55 // Class requires that update tasks from the Pref thread can post safely to the
56 // network thread, so the destruction order must guarantee that if |this| 56 // network thread, so the destruction order must guarantee that if |this|
57 // exists in pref thread, then a potential destruction on network thread will 57 // exists in pref thread, then a potential destruction on network thread will
58 // come after any task posted to network thread from that method on pref thread. 58 // come after any task posted to network thread from that method on pref thread.
59 // This is used to go through network thread before the actual update starts, 59 // This is used to go through network thread before the actual update starts,
60 // and grab a WeakPtr. 60 // and grab a WeakPtr.
61 class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { 61 class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties {
62 public: 62 public:
(...skipping 29 matching lines...) Expand all
92 // cache update to the pref thread; 92 // cache update to the pref thread;
93 // |network_task_runner| should be bound with the network thread and is used 93 // |network_task_runner| should be bound with the network thread and is used
94 // to post pref update to the cache thread. 94 // to post pref update to the cache thread.
95 HttpServerPropertiesManager( 95 HttpServerPropertiesManager(
96 PrefDelegate* pref_delegate, 96 PrefDelegate* pref_delegate,
97 scoped_refptr<base::SingleThreadTaskRunner> pref_task_runner, 97 scoped_refptr<base::SingleThreadTaskRunner> pref_task_runner,
98 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); 98 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
99 ~HttpServerPropertiesManager() override; 99 ~HttpServerPropertiesManager() override;
100 100
101 // Initialize on Network thread. 101 // Initialize on Network thread.
102 void InitializeOnNetworkThread(); 102 void InitializeOnNetworkSequence();
103 103
104 // Prepare for shutdown. Must be called on the Pref thread before destruction. 104 // Prepare for shutdown. Must be called on the Pref thread before destruction.
105 void ShutdownOnPrefThread(); 105 void ShutdownOnPrefSequence();
106 106
107 // Helper function for unit tests to set the version in the dictionary. 107 // Helper function for unit tests to set the version in the dictionary.
108 static void SetVersion(base::DictionaryValue* http_server_properties_dict, 108 static void SetVersion(base::DictionaryValue* http_server_properties_dict,
109 int version_number); 109 int version_number);
110 110
111 // Deletes all data. Works asynchronously, but if a |completion| callback is 111 // Deletes all data. Works asynchronously, but if a |completion| callback is
112 // provided, it will be fired on the pref thread when everything is done. 112 // provided, it will be fired on the pref thread when everything is done.
113 void Clear(const base::Closure& completion); 113 void Clear(const base::Closure& completion);
114 114
115 // ---------------------------------- 115 // ----------------------------------
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const QuicServerInfoMap& quic_server_info_map() const override; 160 const QuicServerInfoMap& quic_server_info_map() const override;
161 size_t max_server_configs_stored_in_properties() const override; 161 size_t max_server_configs_stored_in_properties() const override;
162 void SetMaxServerConfigsStoredInProperties( 162 void SetMaxServerConfigsStoredInProperties(
163 size_t max_server_configs_stored_in_properties) override; 163 size_t max_server_configs_stored_in_properties) override;
164 bool IsInitialized() const override; 164 bool IsInitialized() const override;
165 165
166 static base::TimeDelta GetUpdateCacheDelayForTesting(); 166 static base::TimeDelta GetUpdateCacheDelayForTesting();
167 static base::TimeDelta GetUpdatePrefsDelayForTesting(); 167 static base::TimeDelta GetUpdatePrefsDelayForTesting();
168 168
169 protected: 169 protected:
170 // The location where ScheduleUpdatePrefsOnNetworkThread was called. 170 // The location where ScheduleUpdatePrefsOnNetworkSequence was called.
171 // Must be kept up to date with HttpServerPropertiesUpdatePrefsLocation in 171 // Must be kept up to date with HttpServerPropertiesUpdatePrefsLocation in
172 // histograms.xml. 172 // histograms.xml.
173 enum Location { 173 enum Location {
174 SUPPORTS_SPDY = 0, 174 SUPPORTS_SPDY = 0,
175 HTTP_11_REQUIRED = 1, 175 HTTP_11_REQUIRED = 1,
176 SET_ALTERNATIVE_SERVICES = 2, 176 SET_ALTERNATIVE_SERVICES = 2,
177 MARK_ALTERNATIVE_SERVICE_BROKEN = 3, 177 MARK_ALTERNATIVE_SERVICE_BROKEN = 3,
178 MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN = 4, 178 MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN = 4,
179 CONFIRM_ALTERNATIVE_SERVICE = 5, 179 CONFIRM_ALTERNATIVE_SERVICE = 5,
180 CLEAR_ALTERNATIVE_SERVICE = 6, 180 CLEAR_ALTERNATIVE_SERVICE = 6,
(...skipping 13 matching lines...) Expand all
194 194
195 // These are used to delay updating of the cached data in 195 // These are used to delay updating of the cached data in
196 // |http_server_properties_impl_| while the preferences are changing, and 196 // |http_server_properties_impl_| while the preferences are changing, and
197 // execute only one update per simultaneous prefs changes. 197 // execute only one update per simultaneous prefs changes.
198 void ScheduleUpdateCacheOnPrefThread(); 198 void ScheduleUpdateCacheOnPrefThread();
199 199
200 // Update cached prefs in |http_server_properties_impl_| with data from 200 // Update cached prefs in |http_server_properties_impl_| with data from
201 // preferences. It gets the data on pref thread and calls 201 // preferences. It gets the data on pref thread and calls
202 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on 202 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on
203 // network thread. 203 // network thread.
204 virtual void UpdateCacheFromPrefsOnPrefThread(); 204 virtual void UpdateCacheFromPrefsOnPrefSequence();
205 205
206 // Starts the update of cached prefs in |http_server_properties_impl_| on the 206 // Starts the update of cached prefs in |http_server_properties_impl_| on the
207 // network thread. Protected for testing. 207 // network thread. Protected for testing.
208 void UpdateCacheFromPrefsOnNetworkThread( 208 void UpdateCacheFromPrefsOnNetworkSequence(
209 std::vector<std::string>* spdy_servers, 209 std::vector<std::string>* spdy_servers,
210 AlternativeServiceMap* alternative_service_map, 210 AlternativeServiceMap* alternative_service_map,
211 IPAddress* last_quic_address, 211 IPAddress* last_quic_address,
212 ServerNetworkStatsMap* server_network_stats_map, 212 ServerNetworkStatsMap* server_network_stats_map,
213 QuicServerInfoMap* quic_server_info_map, 213 QuicServerInfoMap* quic_server_info_map,
214 bool detected_corrupted_prefs); 214 bool detected_corrupted_prefs);
215 215
216 // These are used to delay updating the preferences when cached data in 216 // These are used to delay updating the preferences when cached data in
217 // |http_server_properties_impl_| is changing, and execute only one update per 217 // |http_server_properties_impl_| is changing, and execute only one update per
218 // simultaneous spdy_servers or spdy_settings or alternative_service changes. 218 // simultaneous spdy_servers or spdy_settings or alternative_service changes.
219 // |location| specifies where this method is called from. Virtual for testing. 219 // |location| specifies where this method is called from. Virtual for testing.
220 virtual void ScheduleUpdatePrefsOnNetworkThread(Location location); 220 virtual void ScheduleUpdatePrefsOnNetworkSequence(Location location);
221 221
222 // Update prefs::kHttpServerProperties in preferences with the cached data 222 // Update prefs::kHttpServerProperties in preferences with the cached data
223 // from |http_server_properties_impl_|. This gets the data on network thread 223 // from |http_server_properties_impl_|. This gets the data on network thread
224 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref 224 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref
225 // thread. 225 // thread.
226 void UpdatePrefsFromCacheOnNetworkThread(); 226 void UpdatePrefsFromCacheOnNetworkSequence();
227 227
228 // Same as above, but fires an optional |completion| callback on pref thread 228 // Same as above, but fires an optional |completion| callback on pref thread
229 // when finished. Virtual for testing. 229 // when finished. Virtual for testing.
230 virtual void UpdatePrefsFromCacheOnNetworkThread( 230 virtual void UpdatePrefsFromCacheOnNetworkSequence(
231 const base::Closure& completion); 231 const base::Closure& completion);
232 232
233 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an 233 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an
234 // optional |completion| callback when finished. Protected for testing. 234 // optional |completion| callback when finished. Protected for testing.
235 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, 235 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list,
236 AlternativeServiceMap* alternative_service_map, 236 AlternativeServiceMap* alternative_service_map,
237 IPAddress* last_quic_address, 237 IPAddress* last_quic_address,
238 ServerNetworkStatsMap* server_network_stats_map, 238 ServerNetworkStatsMap* server_network_stats_map,
239 QuicServerInfoMap* quic_server_info_map, 239 QuicServerInfoMap* quic_server_info_map,
240 const base::Closure& completion); 240 const base::Closure& completion);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Used to post cache update tasks. 296 // Used to post cache update tasks.
297 std::unique_ptr<base::OneShotTimer> pref_cache_update_timer_; 297 std::unique_ptr<base::OneShotTimer> pref_cache_update_timer_;
298 298
299 std::unique_ptr<PrefDelegate> pref_delegate_; 299 std::unique_ptr<PrefDelegate> pref_delegate_;
300 bool setting_prefs_; 300 bool setting_prefs_;
301 301
302 // -------------- 302 // --------------
303 // Network thread 303 // Network thread
304 // -------------- 304 // --------------
305 305
306 // Whether InitializeOnNetworkThread() has completed. 306 // Whether InitializeOnNetworkSequence() has completed.
307 bool is_initialized_; 307 bool is_initialized_;
308 308
309 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 309 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
310 310
311 // Used to post |prefs::kHttpServerProperties| pref update tasks. 311 // Used to post |prefs::kHttpServerProperties| pref update tasks.
312 std::unique_ptr<base::OneShotTimer> network_prefs_update_timer_; 312 std::unique_ptr<base::OneShotTimer> network_prefs_update_timer_;
313 313
314 std::unique_ptr<HttpServerPropertiesImpl> http_server_properties_impl_; 314 std::unique_ptr<HttpServerPropertiesImpl> http_server_properties_impl_;
315 315
316 // Used to get |weak_ptr_| to self on the pref thread. 316 // Used to get |weak_ptr_| to self on the pref thread.
317 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> 317 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>>
318 pref_weak_ptr_factory_; 318 pref_weak_ptr_factory_;
319 319
320 // Used to get |weak_ptr_| to self on the network thread. 320 // Used to get |weak_ptr_| to self on the network thread.
321 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> 321 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>>
322 network_weak_ptr_factory_; 322 network_weak_ptr_factory_;
323 323
324 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); 324 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager);
325 }; 325 };
326 326
327 } // namespace net 327 } // namespace net
328 328
329 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ 329 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_
OLDNEW
« no previous file with comments | « net/extras/sqlite/sqlite_persistent_cookie_store.cc ('k') | net/http/http_server_properties_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698