OLD | NEW |
---|---|
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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // release the prefs listeners on the pref thread. | 44 // release the prefs listeners on the pref thread. |
45 // | 45 // |
46 // Class requires that update tasks from the Pref thread can post safely to the | 46 // Class requires that update tasks from the Pref thread can post safely to the |
47 // network thread, so the destruction order must guarantee that if |this| | 47 // network thread, so the destruction order must guarantee that if |this| |
48 // exists in pref thread, then a potential destruction on network thread will | 48 // exists in pref thread, then a potential destruction on network thread will |
49 // come after any task posted to network thread from that method on pref thread. | 49 // come after any task posted to network thread from that method on pref thread. |
50 // This is used to go through network thread before the actual update starts, | 50 // This is used to go through network thread before the actual update starts, |
51 // and grab a WeakPtr. | 51 // and grab a WeakPtr. |
52 class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { | 52 class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { |
53 public: | 53 public: |
54 // The location where ScheduleUpdatePrefsOnNetworkThread was called. | |
55 enum Location { | |
mmenke
2015/05/12 17:38:52
Suggest putting these in protected section and the
ramant (doing other things)
2015/05/12 17:57:17
Done.
| |
56 SUPPORTS_SPDY = 0, | |
57 HTTP_11_REQUIRED = 1, | |
58 SET_ALTERNATIVE_SERVICE = 2, | |
59 MARK_ALTERNATIVE_SERVICE_BROKEN = 3, | |
60 MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN = 4, | |
61 CONFIRM_ALTERNATIVE_SERVICE = 5, | |
62 CLEAR_ALTERNATIVE_SERVICE = 6, | |
63 SET_SPDY_SETTING = 7, | |
64 CLEAR_SPDY_SETTINGS = 8, | |
65 CLEAR_ALL_SPDY_SETTINGS = 9, | |
66 SET_SUPPORTS_QUIC = 10, | |
67 SET_SERVER_NETWORK_STATS = 11, | |
68 DETECTED_CORRUPTED_PREFS = 12, | |
69 UNIT_TESTS = 13, | |
mmenke
2015/05/12 17:38:52
Don't think this is really needed - can just use a
ramant (doing other things)
2015/05/12 17:57:17
Done.
| |
70 NUM_LOCATIONS = 14, | |
71 }; | |
72 | |
54 // Create an instance of the HttpServerPropertiesManager. The lifetime of the | 73 // Create an instance of the HttpServerPropertiesManager. The lifetime of the |
55 // PrefService objects must be longer than that of the | 74 // PrefService objects must be longer than that of the |
56 // HttpServerPropertiesManager object. Must be constructed on the Pref thread. | 75 // HttpServerPropertiesManager object. Must be constructed on the Pref thread. |
57 HttpServerPropertiesManager( | 76 HttpServerPropertiesManager( |
58 PrefService* pref_service, | 77 PrefService* pref_service, |
59 const char* pref_path, | 78 const char* pref_path, |
60 scoped_refptr<base::SequencedTaskRunner> network_task_runner); | 79 scoped_refptr<base::SequencedTaskRunner> network_task_runner); |
61 ~HttpServerPropertiesManager() override; | 80 ~HttpServerPropertiesManager() override; |
62 | 81 |
63 // Initialize on Network thread. | 82 // Initialize on Network thread. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 std::vector<std::string>* spdy_servers, | 166 std::vector<std::string>* spdy_servers, |
148 SpdySettingsMap* spdy_settings_map, | 167 SpdySettingsMap* spdy_settings_map, |
149 AlternativeServiceMap* alternative_service_map, | 168 AlternativeServiceMap* alternative_service_map, |
150 IPAddressNumber* last_quic_address, | 169 IPAddressNumber* last_quic_address, |
151 ServerNetworkStatsMap* server_network_stats_map, | 170 ServerNetworkStatsMap* server_network_stats_map, |
152 bool detected_corrupted_prefs); | 171 bool detected_corrupted_prefs); |
153 | 172 |
154 // These are used to delay updating the preferences when cached data in | 173 // These are used to delay updating the preferences when cached data in |
155 // |http_server_properties_impl_| is changing, and execute only one update per | 174 // |http_server_properties_impl_| is changing, and execute only one update per |
156 // simultaneous spdy_servers or spdy_settings or alternative_service changes. | 175 // simultaneous spdy_servers or spdy_settings or alternative_service changes. |
157 void ScheduleUpdatePrefsOnNetworkThread(); | 176 // |location| specifies where this method is called from. |
177 void ScheduleUpdatePrefsOnNetworkThread(Location location); | |
158 | 178 |
159 // Starts the timers to update the prefs from cache. This are overridden in | 179 // Starts the timers to update the prefs from cache. This are overridden in |
160 // tests to prevent the delay. | 180 // tests to prevent the delay. |
161 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); | 181 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); |
162 | 182 |
163 // Update prefs::kHttpServerProperties in preferences with the cached data | 183 // Update prefs::kHttpServerProperties in preferences with the cached data |
164 // from |http_server_properties_impl_|. This gets the data on network thread | 184 // from |http_server_properties_impl_|. This gets the data on network thread |
165 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref | 185 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref |
166 // thread. | 186 // thread. |
167 void UpdatePrefsFromCacheOnNetworkThread(); | 187 void UpdatePrefsFromCacheOnNetworkThread(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 // Used to get |weak_ptr_| to self on the network thread. | 269 // Used to get |weak_ptr_| to self on the network thread. |
250 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > | 270 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > |
251 network_weak_ptr_factory_; | 271 network_weak_ptr_factory_; |
252 | 272 |
253 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 273 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
254 }; | 274 }; |
255 | 275 |
256 } // namespace net | 276 } // namespace net |
257 | 277 |
258 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 278 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
OLD | NEW |