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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
21 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
22 #include "net/http/http_server_properties.h" | 22 #include "net/http/http_server_properties.h" |
23 #include "net/http/http_server_properties_impl.h" | 23 #include "net/http/http_server_properties_impl.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class SequencedTaskRunner; | 26 class SingleThreadTaskRunner; |
27 } | 27 } |
28 | 28 |
29 namespace net { | 29 namespace net { |
30 | 30 |
31 class IPAddress; | 31 class IPAddress; |
32 | 32 |
33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
34 // HttpServerPropertiesManager | 34 // HttpServerPropertiesManager |
35 | 35 |
36 // The manager for creating and updating an HttpServerProperties (for example it | 36 // The manager for creating and updating an HttpServerProperties (for example it |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // Create an instance of the HttpServerPropertiesManager. | 78 // Create an instance of the HttpServerPropertiesManager. |
79 // | 79 // |
80 // Ownership of the PrefDelegate pointer is taken by this class. This is | 80 // Ownership of the PrefDelegate pointer is taken by this class. This is |
81 // passed as a raw pointer rather than a scoped_refptr currently because | 81 // passed as a raw pointer rather than a scoped_refptr currently because |
82 // the test uses gmock and it doesn't forward move semantics properly. | 82 // the test uses gmock and it doesn't forward move semantics properly. |
83 // | 83 // |
84 // Must be constructed on the Pref thread. | 84 // Must be constructed on the Pref thread. |
85 HttpServerPropertiesManager( | 85 HttpServerPropertiesManager( |
86 PrefDelegate* pref_delegate, | 86 PrefDelegate* pref_delegate, |
87 scoped_refptr<base::SequencedTaskRunner> network_task_runner); | 87 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); |
88 ~HttpServerPropertiesManager() override; | 88 ~HttpServerPropertiesManager() override; |
89 | 89 |
90 // Initialize on Network thread. | 90 // Initialize on Network thread. |
91 void InitializeOnNetworkThread(); | 91 void InitializeOnNetworkThread(); |
92 | 92 |
93 // Prepare for shutdown. Must be called on the Pref thread before destruction. | 93 // Prepare for shutdown. Must be called on the Pref thread before destruction. |
94 void ShutdownOnPrefThread(); | 94 void ShutdownOnPrefThread(); |
95 | 95 |
96 // Helper function for unit tests to set the version in the dictionary. | 96 // Helper function for unit tests to set the version in the dictionary. |
97 static void SetVersion(base::DictionaryValue* http_server_properties_dict, | 97 static void SetVersion(base::DictionaryValue* http_server_properties_dict, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 const ServerNetworkStats* server_network_stats, | 270 const ServerNetworkStats* server_network_stats, |
271 base::DictionaryValue* server_pref_dict); | 271 base::DictionaryValue* server_pref_dict); |
272 void SaveQuicServerInfoMapToServerPrefs( | 272 void SaveQuicServerInfoMapToServerPrefs( |
273 QuicServerInfoMap* quic_server_info_map, | 273 QuicServerInfoMap* quic_server_info_map, |
274 base::DictionaryValue* http_server_properties_dict); | 274 base::DictionaryValue* http_server_properties_dict); |
275 | 275 |
276 // ----------- | 276 // ----------- |
277 // Pref thread | 277 // Pref thread |
278 // ----------- | 278 // ----------- |
279 | 279 |
280 const scoped_refptr<base::SequencedTaskRunner> pref_task_runner_; | 280 const scoped_refptr<base::SingleThreadTaskRunner> pref_task_runner_; |
281 | 281 |
282 base::WeakPtr<HttpServerPropertiesManager> pref_weak_ptr_; | 282 base::WeakPtr<HttpServerPropertiesManager> pref_weak_ptr_; |
283 | 283 |
284 // Used to post cache update tasks. | 284 // Used to post cache update tasks. |
285 std::unique_ptr<base::OneShotTimer> pref_cache_update_timer_; | 285 std::unique_ptr<base::OneShotTimer> pref_cache_update_timer_; |
286 | 286 |
287 std::unique_ptr<PrefDelegate> pref_delegate_; | 287 std::unique_ptr<PrefDelegate> pref_delegate_; |
288 bool setting_prefs_; | 288 bool setting_prefs_; |
289 | 289 |
290 // -------------- | 290 // -------------- |
291 // Network thread | 291 // Network thread |
292 // -------------- | 292 // -------------- |
293 | 293 |
294 const scoped_refptr<base::SequencedTaskRunner> network_task_runner_; | 294 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
295 | 295 |
296 // Used to post |prefs::kHttpServerProperties| pref update tasks. | 296 // Used to post |prefs::kHttpServerProperties| pref update tasks. |
297 std::unique_ptr<base::OneShotTimer> network_prefs_update_timer_; | 297 std::unique_ptr<base::OneShotTimer> network_prefs_update_timer_; |
298 | 298 |
299 std::unique_ptr<HttpServerPropertiesImpl> http_server_properties_impl_; | 299 std::unique_ptr<HttpServerPropertiesImpl> http_server_properties_impl_; |
300 | 300 |
301 // Used to get |weak_ptr_| to self on the pref thread. | 301 // Used to get |weak_ptr_| to self on the pref thread. |
302 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> | 302 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> |
303 pref_weak_ptr_factory_; | 303 pref_weak_ptr_factory_; |
304 | 304 |
305 // Used to get |weak_ptr_| to self on the network thread. | 305 // Used to get |weak_ptr_| to self on the network thread. |
306 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> | 306 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> |
307 network_weak_ptr_factory_; | 307 network_weak_ptr_factory_; |
308 | 308 |
309 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 309 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
310 }; | 310 }; |
311 | 311 |
312 } // namespace net | 312 } // namespace net |
313 | 313 |
314 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 314 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
OLD | NEW |