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