OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROMEOS_NETWORK_NETWORK_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
11 | 12 |
13 namespace base { | |
14 class SequencedTaskRunner; | |
15 } | |
16 | |
12 namespace chromeos { | 17 namespace chromeos { |
13 | 18 |
14 class CertLoader; | 19 class CertLoader; |
15 class GeolocationHandler; | 20 class GeolocationHandler; |
16 class ManagedNetworkConfigurationHandler; | 21 class ManagedNetworkConfigurationHandler; |
17 class NetworkConfigurationHandler; | 22 class NetworkConfigurationHandler; |
18 class NetworkConnectionHandler; | 23 class NetworkConnectionHandler; |
19 class NetworkProfileHandler; | 24 class NetworkProfileHandler; |
20 class NetworkStateHandler; | 25 class NetworkStateHandler; |
21 | 26 |
22 // Class for handling initialization and access to chromeos network handlers. | 27 // Class for handling initialization and access to chromeos network handlers. |
23 // This class should NOT be used in unit tests. Instead, construct individual | 28 // This class should NOT be used in unit tests. Instead, construct individual |
24 // classes independently. | 29 // classes independently. |
25 class CHROMEOS_EXPORT NetworkHandler { | 30 class CHROMEOS_EXPORT NetworkHandler { |
26 public: | 31 public: |
27 // Sets the global instance. Must be called before any calls to Get(). | 32 // Sets the global instance. Must be called before any calls to Get(). |
28 static void Initialize(); | 33 // |io_task_runner| is used to initialize CertLoader. |
34 static void Initialize( | |
35 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | |
Ryan Sleevi
2013/06/10 17:33:57
nit: you call it crypto_task_runner in the CertLoa
| |
29 | 36 |
30 // Sets the global instance for testing. | 37 // Sets the global instance for testing. |
31 static void InitializeForTest(); | 38 static void InitializeForTest(); |
32 | 39 |
33 // Destroys the global instance. | 40 // Destroys the global instance. |
34 static void Shutdown(); | 41 static void Shutdown(); |
35 | 42 |
36 // Gets the global instance. Initialize() must be called first. | 43 // Gets the global instance. Initialize() must be called first. |
37 static NetworkHandler* Get(); | 44 static NetworkHandler* Get(); |
38 | 45 |
39 // Returns true if the global instance has been initialized. | 46 // Returns true if the global instance has been initialized. |
40 static bool IsInitialized(); | 47 static bool IsInitialized(); |
41 | 48 |
42 // Do not use these accessors within this module; all dependencies should be | 49 // Do not use these accessors within this module; all dependencies should be |
43 // explicit so that classes can be constructed explicitly in tests without | 50 // explicit so that classes can be constructed explicitly in tests without |
44 // NetworkHandler. | 51 // NetworkHandler. |
45 CertLoader* cert_loader(); | 52 CertLoader* cert_loader(); |
46 NetworkStateHandler* network_state_handler(); | 53 NetworkStateHandler* network_state_handler(); |
47 NetworkProfileHandler* network_profile_handler(); | 54 NetworkProfileHandler* network_profile_handler(); |
48 NetworkConfigurationHandler* network_configuration_handler(); | 55 NetworkConfigurationHandler* network_configuration_handler(); |
49 ManagedNetworkConfigurationHandler* managed_network_configuration_handler(); | 56 ManagedNetworkConfigurationHandler* managed_network_configuration_handler(); |
50 NetworkConnectionHandler* network_connection_handler(); | 57 NetworkConnectionHandler* network_connection_handler(); |
51 GeolocationHandler* geolocation_handler(); | 58 GeolocationHandler* geolocation_handler(); |
52 | 59 |
53 private: | 60 private: |
54 NetworkHandler(); | 61 NetworkHandler(); |
55 virtual ~NetworkHandler(); | 62 virtual ~NetworkHandler(); |
56 | 63 |
57 void Init(); | 64 void Init(const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
58 | 65 |
59 // The order of these determines the (inverse) destruction order. | 66 // The order of these determines the (inverse) destruction order. |
60 scoped_ptr<CertLoader> cert_loader_; | 67 scoped_ptr<CertLoader> cert_loader_; |
61 scoped_ptr<NetworkStateHandler> network_state_handler_; | 68 scoped_ptr<NetworkStateHandler> network_state_handler_; |
62 scoped_ptr<NetworkProfileHandler> network_profile_handler_; | 69 scoped_ptr<NetworkProfileHandler> network_profile_handler_; |
63 scoped_ptr<NetworkConfigurationHandler> network_configuration_handler_; | 70 scoped_ptr<NetworkConfigurationHandler> network_configuration_handler_; |
64 scoped_ptr<ManagedNetworkConfigurationHandler> | 71 scoped_ptr<ManagedNetworkConfigurationHandler> |
65 managed_network_configuration_handler_; | 72 managed_network_configuration_handler_; |
66 scoped_ptr<NetworkConnectionHandler> network_connection_handler_; | 73 scoped_ptr<NetworkConnectionHandler> network_connection_handler_; |
67 scoped_ptr<GeolocationHandler> geolocation_handler_; | 74 scoped_ptr<GeolocationHandler> geolocation_handler_; |
68 | 75 |
69 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); | 76 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); |
70 }; | 77 }; |
71 | 78 |
72 } // namespace chromeos | 79 } // namespace chromeos |
73 | 80 |
74 #endif // CHROMEOS_NETWORK_NETWORK_HANDLER_H_ | 81 #endif // CHROMEOS_NETWORK_NETWORK_HANDLER_H_ |
OLD | NEW |