| 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 22 matching lines...) Expand all Loading... |
| 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 |
| 37 // tracks if a server supports SPDY or not). | 37 // tracks if a server supports SPDY or not). |
| 38 // | 38 // |
| 39 // This class interacts with both the pref thread, where notifications of pref | 39 // This class interacts with both the pref thread, where notifications of pref |
| 40 // changes are received from, and the network thread, which owns it, and it | 40 // changes are received from, and the network thread, which owns it, and it |
| 41 // persists the changes from network stack whether server supports SPDY or not. | 41 // persists the changes from network stack whether server supports SPDY or not. |
| 42 // | 42 // |
| 43 // It must be constructed on the pref thread, to set up |pref_task_runner_| and | 43 // There are two SingleThreadTaskRunners: |
| 44 // the prefs listeners. | 44 // |pref_task_runner_| should be bound with the pref thread and is used to post |
| 45 // cache update to the pref thread; |
| 46 // |network_task_runner_| should be bound with the network thread and is used |
| 47 // to post pref update to the cache thread. |
| 48 // |
| 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. |
| 45 // | 51 // |
| 46 // ShutdownOnPrefThread must be called from pref thread before destruction, to | 52 // ShutdownOnPrefThread must be called from pref thread before destruction, to |
| 47 // release the prefs listeners on the pref thread. | 53 // release the prefs listeners on the pref thread. |
| 48 // | 54 // |
| 49 // 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 |
| 50 // network thread, so the destruction order must guarantee that if |this| | 56 // network thread, so the destruction order must guarantee that if |this| |
| 51 // 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 |
| 52 // 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. |
| 53 // 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, |
| 54 // and grab a WeakPtr. | 60 // and grab a WeakPtr. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 virtual void StartListeningForUpdates(const base::Closure& callback) = 0; | 80 virtual void StartListeningForUpdates(const base::Closure& callback) = 0; |
| 75 virtual void StopListeningForUpdates() = 0; | 81 virtual void StopListeningForUpdates() = 0; |
| 76 }; | 82 }; |
| 77 | 83 |
| 78 // Create an instance of the HttpServerPropertiesManager. | 84 // Create an instance of the HttpServerPropertiesManager. |
| 79 // | 85 // |
| 80 // Ownership of the PrefDelegate pointer is taken by this class. This is | 86 // 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 | 87 // 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. | 88 // the test uses gmock and it doesn't forward move semantics properly. |
| 83 // | 89 // |
| 84 // Must be constructed on the Pref thread. | 90 // There are two SingleThreadTaskRunners: |
| 91 // |pref_task_runner| should be bound with the pref thread and is used to post |
| 92 // cache update to the pref thread; |
| 93 // |network_task_runner| should be bound with the network thread and is used |
| 94 // to post pref update to the cache thread. |
| 85 HttpServerPropertiesManager( | 95 HttpServerPropertiesManager( |
| 86 PrefDelegate* pref_delegate, | 96 PrefDelegate* pref_delegate, |
| 97 scoped_refptr<base::SingleThreadTaskRunner> pref_task_runner, |
| 87 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); | 98 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); |
| 88 ~HttpServerPropertiesManager() override; | 99 ~HttpServerPropertiesManager() override; |
| 89 | 100 |
| 90 // Initialize on Network thread. | 101 // Initialize on Network thread. |
| 91 void InitializeOnNetworkThread(); | 102 void InitializeOnNetworkThread(); |
| 92 | 103 |
| 93 // 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. |
| 94 void ShutdownOnPrefThread(); | 105 void ShutdownOnPrefThread(); |
| 95 | 106 |
| 96 // 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. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Used to get |weak_ptr_| to self on the network thread. | 316 // Used to get |weak_ptr_| to self on the network thread. |
| 306 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> | 317 std::unique_ptr<base::WeakPtrFactory<HttpServerPropertiesManager>> |
| 307 network_weak_ptr_factory_; | 318 network_weak_ptr_factory_; |
| 308 | 319 |
| 309 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 320 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
| 310 }; | 321 }; |
| 311 | 322 |
| 312 } // namespace net | 323 } // namespace net |
| 313 | 324 |
| 314 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 325 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| OLD | NEW |