OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 #include "chromeos/network/network_handler.h" |
| 6 |
| 7 #include "chromeos/dbus/dbus_thread_manager.h" |
| 8 #include "chromeos/login/login_state.h" |
| 9 #include "chromeos/network/cert_loader.h" |
| 10 #include "chromeos/network/geolocation_handler.h" |
| 11 #include "chromeos/network/managed_network_configuration_handler.h" |
| 12 #include "chromeos/network/network_configuration_handler.h" |
| 13 #include "chromeos/network/network_connection_handler.h" |
| 14 #include "chromeos/network/network_event_log.h" |
| 15 #include "chromeos/network/network_profile_handler.h" |
| 16 #include "chromeos/network/network_profile_observer.h" |
| 17 #include "chromeos/network/network_state_handler.h" |
| 18 #include "chromeos/network/network_state_handler_observer.h" |
| 19 |
| 20 namespace chromeos { |
| 21 |
| 22 static NetworkHandler* g_network_handler = NULL; |
| 23 |
| 24 class NetworkHandler::LoginStateInitializer { |
| 25 public: |
| 26 LoginStateInitializer() { |
| 27 LoginState::Initialize(); |
| 28 } |
| 29 ~LoginStateInitializer() { |
| 30 LoginState::Shutdown(); |
| 31 } |
| 32 }; |
| 33 |
| 34 NetworkHandler::NetworkHandler() { |
| 35 CHECK(DBusThreadManager::IsInitialized()); |
| 36 |
| 37 if (!LoginState::IsInitialized()) |
| 38 login_state_initializer_.reset(new LoginStateInitializer()); |
| 39 |
| 40 network_event_log::Initialize(); |
| 41 |
| 42 cert_loader_.reset(new CertLoader); |
| 43 network_state_handler_.reset(new NetworkStateHandler()); |
| 44 network_profile_handler_.reset(new NetworkProfileHandler()); |
| 45 network_configuration_handler_.reset(new NetworkConfigurationHandler()); |
| 46 managed_network_configuration_handler_.reset( |
| 47 new ManagedNetworkConfigurationHandler()); |
| 48 network_connection_handler_.reset(new NetworkConnectionHandler()); |
| 49 geolocation_handler_.reset(new GeolocationHandler()); |
| 50 } |
| 51 |
| 52 NetworkHandler::~NetworkHandler() { |
| 53 network_event_log::Shutdown(); |
| 54 } |
| 55 |
| 56 void NetworkHandler::Init() { |
| 57 network_state_handler_->InitShillPropertyHandler(); |
| 58 managed_network_configuration_handler_->Init( |
| 59 network_state_handler_.get(), |
| 60 network_profile_handler_.get(), |
| 61 network_configuration_handler_.get()); |
| 62 network_connection_handler_->Init( |
| 63 network_state_handler_.get(), |
| 64 network_configuration_handler_.get()); |
| 65 geolocation_handler_->Init(); |
| 66 } |
| 67 |
| 68 // static |
| 69 void NetworkHandler::Initialize() { |
| 70 CHECK(!g_network_handler); |
| 71 g_network_handler = new NetworkHandler(); |
| 72 g_network_handler->Init(); |
| 73 } |
| 74 |
| 75 // static |
| 76 void NetworkHandler::Shutdown() { |
| 77 CHECK(g_network_handler); |
| 78 delete g_network_handler; |
| 79 g_network_handler = NULL; |
| 80 } |
| 81 |
| 82 // static |
| 83 NetworkHandler* NetworkHandler::Get() { |
| 84 CHECK(g_network_handler) |
| 85 << "NetworkHandler::Get() called before Initialize()"; |
| 86 return g_network_handler; |
| 87 } |
| 88 |
| 89 // static |
| 90 bool NetworkHandler::IsInitialized() { |
| 91 return g_network_handler; |
| 92 } |
| 93 |
| 94 CertLoader* NetworkHandler::cert_loader() { |
| 95 return cert_loader_.get(); |
| 96 } |
| 97 |
| 98 NetworkStateHandler* NetworkHandler::network_state_handler() { |
| 99 return network_state_handler_.get(); |
| 100 } |
| 101 |
| 102 NetworkProfileHandler* NetworkHandler::network_profile_handler() { |
| 103 return network_profile_handler_.get(); |
| 104 } |
| 105 |
| 106 NetworkConfigurationHandler* NetworkHandler::network_configuration_handler() { |
| 107 return network_configuration_handler_.get(); |
| 108 } |
| 109 |
| 110 ManagedNetworkConfigurationHandler* |
| 111 NetworkHandler::managed_network_configuration_handler() { |
| 112 return managed_network_configuration_handler_.get(); |
| 113 } |
| 114 |
| 115 NetworkConnectionHandler* NetworkHandler::network_connection_handler() { |
| 116 return network_connection_handler_.get(); |
| 117 } |
| 118 |
| 119 GeolocationHandler* NetworkHandler::geolocation_handler() { |
| 120 return geolocation_handler_.get(); |
| 121 } |
| 122 |
| 123 } // namespace chromeos |
OLD | NEW |