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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 typedef std::vector<std::string> ServerList; | |
171 | |
170 // The location where ScheduleUpdatePrefsOnNetworkSequence was called. | 172 // The location where ScheduleUpdatePrefsOnNetworkSequence was called. |
171 // Must be kept up to date with HttpServerPropertiesUpdatePrefsLocation in | 173 // Must be kept up to date with HttpServerPropertiesUpdatePrefsLocation in |
172 // histograms.xml. | 174 // histograms.xml. |
173 enum Location { | 175 enum Location { |
174 SUPPORTS_SPDY = 0, | 176 SUPPORTS_SPDY = 0, |
175 HTTP_11_REQUIRED = 1, | 177 HTTP_11_REQUIRED = 1, |
176 SET_ALTERNATIVE_SERVICES = 2, | 178 SET_ALTERNATIVE_SERVICES = 2, |
177 MARK_ALTERNATIVE_SERVICE_BROKEN = 3, | 179 MARK_ALTERNATIVE_SERVICE_BROKEN = 3, |
178 MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN = 4, | 180 MARK_ALTERNATIVE_SERVICE_RECENTLY_BROKEN = 4, |
179 CONFIRM_ALTERNATIVE_SERVICE = 5, | 181 CONFIRM_ALTERNATIVE_SERVICE = 5, |
(...skipping 19 matching lines...) Expand all Loading... | |
199 | 201 |
200 // Update cached prefs in |http_server_properties_impl_| with data from | 202 // Update cached prefs in |http_server_properties_impl_| with data from |
201 // preferences. It gets the data on pref thread and calls | 203 // preferences. It gets the data on pref thread and calls |
202 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on | 204 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on |
203 // network thread. | 205 // network thread. |
204 virtual void UpdateCacheFromPrefsOnPrefSequence(); | 206 virtual void UpdateCacheFromPrefsOnPrefSequence(); |
205 | 207 |
206 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 208 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
207 // network thread. Protected for testing. | 209 // network thread. Protected for testing. |
208 void UpdateCacheFromPrefsOnNetworkSequence( | 210 void UpdateCacheFromPrefsOnNetworkSequence( |
209 std::vector<std::string>* spdy_servers, | 211 const ServerList* spdy_servers, |
Zhongyi Shi
2017/06/20 22:06:19
Could this be std::unique_ptr<ServerList>?
wangyix1
2017/06/21 18:45:33
Done.
| |
210 AlternativeServiceMap* alternative_service_map, | 212 std::unique_ptr<AlternativeServiceMap> alternative_service_map, |
211 IPAddress* last_quic_address, | 213 const IPAddress* last_quic_address, |
212 ServerNetworkStatsMap* server_network_stats_map, | 214 std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map, |
213 QuicServerInfoMap* quic_server_info_map, | 215 std::unique_ptr<QuicServerInfoMap> quic_server_info_map, |
214 bool detected_corrupted_prefs); | 216 bool detected_corrupted_prefs); |
215 | 217 |
216 // These are used to delay updating the preferences when cached data in | 218 // 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 | 219 // |http_server_properties_impl_| is changing, and execute only one update per |
218 // simultaneous spdy_servers or spdy_settings or alternative_service changes. | 220 // simultaneous spdy_servers or spdy_settings or alternative_service changes. |
219 // |location| specifies where this method is called from. Virtual for testing. | 221 // |location| specifies where this method is called from. Virtual for testing. |
220 virtual void ScheduleUpdatePrefsOnNetworkSequence(Location location); | 222 virtual void ScheduleUpdatePrefsOnNetworkSequence(Location location); |
221 | 223 |
222 // Update prefs::kHttpServerProperties in preferences with the cached data | 224 // Update prefs::kHttpServerProperties in preferences with the cached data |
223 // from |http_server_properties_impl_|. This gets the data on network thread | 225 // from |http_server_properties_impl_|. This gets the data on network thread |
224 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref | 226 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref |
225 // thread. | 227 // thread. |
226 void UpdatePrefsFromCacheOnNetworkSequence(); | 228 void UpdatePrefsFromCacheOnNetworkSequence(); |
227 | 229 |
228 // Same as above, but fires an optional |completion| callback on pref thread | 230 // Same as above, but fires an optional |completion| callback on pref thread |
229 // when finished. Virtual for testing. | 231 // when finished. Virtual for testing. |
230 virtual void UpdatePrefsFromCacheOnNetworkSequence( | 232 virtual void UpdatePrefsFromCacheOnNetworkSequence( |
231 const base::Closure& completion); | 233 const base::Closure& completion); |
232 | 234 |
233 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an | 235 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an |
234 // optional |completion| callback when finished. Protected for testing. | 236 // optional |completion| callback when finished. Protected for testing. |
235 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, | 237 void UpdatePrefsOnPrefThread(std::unique_ptr<ServerList> spdy_servers, |
Ryan Hamilton
2017/06/20 18:25:56
Instead of passing a unique_ptr here (where all th
Zhongyi Shi
2017/06/20 22:06:19
+1, right now it's a mix of the two. It will be mu
wangyix1
2017/06/21 18:45:33
Ah, I think I just forgot to update these. For Upd
Ryan Hamilton
2017/06/22 02:45:52
Sweet! Much cleaner!
| |
236 AlternativeServiceMap* alternative_service_map, | 238 AlternativeServiceMap* alternative_service_map, |
237 IPAddress* last_quic_address, | 239 IPAddress* last_quic_address, |
238 ServerNetworkStatsMap* server_network_stats_map, | 240 ServerNetworkStatsMap* server_network_stats_map, |
239 QuicServerInfoMap* quic_server_info_map, | 241 QuicServerInfoMap* quic_server_info_map, |
240 const base::Closure& completion); | 242 const base::Closure& completion); |
241 | 243 |
242 private: | 244 private: |
243 typedef std::vector<std::string> ServerList; | |
244 | |
245 FRIEND_TEST_ALL_PREFIXES(HttpServerPropertiesManagerTest, | 245 FRIEND_TEST_ALL_PREFIXES(HttpServerPropertiesManagerTest, |
246 AddToAlternativeServiceMap); | 246 AddToAlternativeServiceMap); |
247 FRIEND_TEST_ALL_PREFIXES(HttpServerPropertiesManagerTest, | 247 FRIEND_TEST_ALL_PREFIXES(HttpServerPropertiesManagerTest, |
248 DoNotLoadAltSvcForInsecureOrigins); | 248 DoNotLoadAltSvcForInsecureOrigins); |
249 FRIEND_TEST_ALL_PREFIXES(HttpServerPropertiesManagerTest, | 249 FRIEND_TEST_ALL_PREFIXES(HttpServerPropertiesManagerTest, |
250 DoNotLoadExpiredAlternativeService); | 250 DoNotLoadExpiredAlternativeService); |
251 void OnHttpServerPropertiesChanged(); | 251 void OnHttpServerPropertiesChanged(); |
252 | 252 |
253 bool AddServersData(const base::DictionaryValue& server_dict, | 253 bool AddServersData(const base::DictionaryValue& server_dict, |
254 ServerList* spdy_servers, | 254 ServerList* spdy_servers, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_ |
OLD | NEW |