| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chromeos/network/network_configuration_handler.h" | 5 #include "chromeos/network/network_configuration_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chromeos/dbus/dbus_method_call_status.h" | 15 #include "chromeos/dbus/dbus_method_call_status.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chromeos/dbus/shill_manager_client.h" | 17 #include "chromeos/dbus/shill_manager_client.h" |
| 18 #include "chromeos/dbus/shill_service_client.h" | 18 #include "chromeos/dbus/shill_service_client.h" |
| 19 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| 22 | 22 |
| 23 static NetworkConfigurationHandler* g_network_configuration_handler = NULL; | |
| 24 | |
| 25 namespace { | 23 namespace { |
| 26 | 24 |
| 27 const char kLogModule[] = "NetworkConfigurationHandler"; | 25 const char kLogModule[] = "NetworkConfigurationHandler"; |
| 28 | 26 |
| 27 NetworkConfigurationHandler* g_configuration_handler_instance = NULL; |
| 28 |
| 29 // None of these error messages are user-facing: they should only appear in | 29 // None of these error messages are user-facing: they should only appear in |
| 30 // logs. | 30 // logs. |
| 31 const char kErrorsListTag[] = "errors"; | 31 const char kErrorsListTag[] = "errors"; |
| 32 const char kClearPropertiesFailedError[] = "Error.ClearPropertiesFailed"; | 32 const char kClearPropertiesFailedError[] = "Error.ClearPropertiesFailed"; |
| 33 const char kClearPropertiesFailedErrorMessage[] = "Clear properties failed"; | 33 const char kClearPropertiesFailedErrorMessage[] = "Clear properties failed"; |
| 34 const char kDBusFailedError[] = "Error.DBusFailed"; | 34 const char kDBusFailedError[] = "Error.DBusFailed"; |
| 35 const char kDBusFailedErrorMessage[] = "DBus call failed."; | 35 const char kDBusFailedErrorMessage[] = "DBus call failed."; |
| 36 | 36 |
| 37 void ClearPropertiesCallback( | 37 void ClearPropertiesCallback( |
| 38 const std::vector<std::string>& names, | 38 const std::vector<std::string>& names, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 void RunCreateNetworkCallback( | 96 void RunCreateNetworkCallback( |
| 97 const network_handler::StringResultCallback& callback, | 97 const network_handler::StringResultCallback& callback, |
| 98 const dbus::ObjectPath& service_path) { | 98 const dbus::ObjectPath& service_path) { |
| 99 callback.Run(service_path.value()); | 99 callback.Run(service_path.value()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace | 102 } // namespace |
| 103 | 103 |
| 104 NetworkConfigurationHandler::NetworkConfigurationHandler() { | |
| 105 } | |
| 106 | |
| 107 NetworkConfigurationHandler::~NetworkConfigurationHandler() { | |
| 108 } | |
| 109 | |
| 110 // static | 104 // static |
| 111 void NetworkConfigurationHandler::Initialize() { | 105 void NetworkConfigurationHandler::Initialize() { |
| 112 CHECK(!g_network_configuration_handler); | 106 CHECK(!g_configuration_handler_instance); |
| 113 g_network_configuration_handler = new NetworkConfigurationHandler(); | 107 g_configuration_handler_instance = new NetworkConfigurationHandler; |
| 114 } | 108 } |
| 115 | 109 |
| 116 // static | 110 // static |
| 117 void NetworkConfigurationHandler::Shutdown() { | 111 void NetworkConfigurationHandler::Shutdown() { |
| 118 CHECK(g_network_configuration_handler); | 112 CHECK(g_configuration_handler_instance); |
| 119 delete g_network_configuration_handler; | 113 delete g_configuration_handler_instance; |
| 120 g_network_configuration_handler = NULL; | 114 g_configuration_handler_instance = NULL; |
| 121 } | 115 } |
| 122 | 116 |
| 123 // static | 117 // static |
| 124 NetworkConfigurationHandler* NetworkConfigurationHandler::Get() { | 118 NetworkConfigurationHandler* NetworkConfigurationHandler::Get() { |
| 125 CHECK(g_network_configuration_handler) | 119 CHECK(g_configuration_handler_instance) |
| 126 << "NetworkConfigurationHandler::Get() called before Initialize()"; | 120 << "NetworkConfigurationHandler::Get() called before Initialize()"; |
| 127 return g_network_configuration_handler; | 121 return g_configuration_handler_instance; |
| 128 } | 122 } |
| 129 | 123 |
| 130 void NetworkConfigurationHandler::GetProperties( | 124 void NetworkConfigurationHandler::GetProperties( |
| 131 const std::string& service_path, | 125 const std::string& service_path, |
| 132 const network_handler::DictionaryResultCallback& callback, | 126 const network_handler::DictionaryResultCallback& callback, |
| 133 const network_handler::ErrorCallback& error_callback) const { | 127 const network_handler::ErrorCallback& error_callback) const { |
| 134 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( | 128 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( |
| 135 dbus::ObjectPath(service_path), | 129 dbus::ObjectPath(service_path), |
| 136 base::Bind(&RunCallbackWithDictionaryValue, | 130 base::Bind(&RunCallbackWithDictionaryValue, |
| 137 callback, | 131 callback, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 const std::string& service_path, | 199 const std::string& service_path, |
| 206 const base::Closure& callback, | 200 const base::Closure& callback, |
| 207 const network_handler::ErrorCallback& error_callback) const { | 201 const network_handler::ErrorCallback& error_callback) const { |
| 208 DBusThreadManager::Get()->GetShillServiceClient()->Remove( | 202 DBusThreadManager::Get()->GetShillServiceClient()->Remove( |
| 209 dbus::ObjectPath(service_path), | 203 dbus::ObjectPath(service_path), |
| 210 callback, | 204 callback, |
| 211 base::Bind(&network_handler::ShillErrorCallbackFunction, | 205 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 212 kLogModule, service_path, error_callback)); | 206 kLogModule, service_path, error_callback)); |
| 213 } | 207 } |
| 214 | 208 |
| 209 NetworkConfigurationHandler::NetworkConfigurationHandler() { |
| 210 } |
| 211 |
| 212 NetworkConfigurationHandler::~NetworkConfigurationHandler() { |
| 213 } |
| 214 |
| 215 } // namespace chromeos | 215 } // namespace chromeos |
| OLD | NEW |