network_handler.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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 3// found in the LICENSE file. 4 5#ifndef CHROMEOS_NETWORK_NETWORK_HANDLER_H_ 6#define CHROMEOS_NETWORK_NETWORK_HANDLER_H_ 7 8#include "base/basictypes.h" 9#include "base/memory/ref_counted.h" 10#include "base/memory/scoped_ptr.h" 11#include "base/message_loop/message_loop_proxy.h" 12#include "chromeos/chromeos_export.h" 13 14namespace chromeos { 15 16class ClientCertResolver; 17class GeolocationHandler; 18class ManagedNetworkConfigurationHandler; 19class ManagedNetworkConfigurationHandlerImpl; 20class NetworkActivationHandler; 21class NetworkCertMigrator; 22class NetworkConfigurationHandler; 23class NetworkConnectionHandler; 24class NetworkDeviceHandler; 25class NetworkDeviceHandlerImpl; 26class NetworkProfileHandler; 27class NetworkStateHandler; 28class NetworkSmsHandler; 29 30// Class for handling initialization and access to chromeos network handlers. 31// This class should NOT be used in unit tests. Instead, construct individual 32// classes independently. 33class CHROMEOS_EXPORT NetworkHandler { 34 public: 35 // Sets the global instance. Must be called before any calls to Get(). 36 static void Initialize(); 37 38 // Destroys the global instance. 39 static void Shutdown(); 40 41 // Gets the global instance. Initialize() must be called first. 42 static NetworkHandler* Get(); 43 44 // Returns true if the global instance has been initialized. 45 static bool IsInitialized(); 46 47 // Returns the MessageLoopProxy for posting NetworkHandler calls from 48 // other threads. 49 base::MessageLoopProxy* message_loop() { return message_loop_.get(); } 50 51 // Do not use these accessors within this module; all dependencies should be 52 // explicit so that classes can be constructed explicitly in tests without 53 // NetworkHandler. 54 NetworkStateHandler* network_state_handler(); 55 NetworkDeviceHandler* network_device_handler(); 56 NetworkProfileHandler* network_profile_handler(); 57 NetworkConfigurationHandler* network_configuration_handler(); 58 ManagedNetworkConfigurationHandler* managed_network_configuration_handler(); 59 NetworkActivationHandler* network_activation_handler(); 60 NetworkConnectionHandler* network_connection_handler(); 61 NetworkSmsHandler* network_sms_handler(); 62 GeolocationHandler* geolocation_handler(); 63 64 private: 65 NetworkHandler(); 66 virtual ~NetworkHandler(); 67 68 void Init(); 69 70 // The order of these determines the (inverse) destruction order. 71 scoped_refptr<base::MessageLoopProxy> message_loop_; 72 scoped_ptr<NetworkStateHandler> network_state_handler_; 73 scoped_ptr<NetworkDeviceHandlerImpl> network_device_handler_; 74 scoped_ptr<NetworkProfileHandler> network_profile_handler_; 75 scoped_ptr<NetworkConfigurationHandler> network_configuration_handler_; 76 scoped_ptr<ManagedNetworkConfigurationHandlerImpl> 77 managed_network_configuration_handler_; 78 scoped_ptr<NetworkCertMigrator> network_cert_migrator_; 79 scoped_ptr<ClientCertResolver> client_cert_resolver_; 80 scoped_ptr<NetworkActivationHandler> network_activation_handler_; 81 scoped_ptr<NetworkConnectionHandler> network_connection_handler_; 82 scoped_ptr<NetworkSmsHandler> network_sms_handler_; 83 scoped_ptr<GeolocationHandler> geolocation_handler_; 84 85 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); 86}; 87 88} // namespace chromeos 89 90#endif // CHROMEOS_NETWORK_NETWORK_HANDLER_H_ 91