| 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 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 21 | 21 |
| 22 namespace chromeos { | 22 namespace chromeos { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 NetworkConfigurationHandler* g_configuration_handler_instance = NULL; | |
| 27 | |
| 28 // None of these error messages are user-facing: they should only appear in | 26 // None of these error messages are user-facing: they should only appear in |
| 29 // logs. | 27 // logs. |
| 30 const char kErrorsListTag[] = "errors"; | 28 const char kErrorsListTag[] = "errors"; |
| 31 const char kClearPropertiesFailedError[] = "Error.ClearPropertiesFailed"; | 29 const char kClearPropertiesFailedError[] = "Error.ClearPropertiesFailed"; |
| 32 const char kClearPropertiesFailedErrorMessage[] = "Clear properties failed"; | 30 const char kClearPropertiesFailedErrorMessage[] = "Clear properties failed"; |
| 33 const char kDBusFailedError[] = "Error.DBusFailed"; | 31 const char kDBusFailedError[] = "Error.DBusFailed"; |
| 34 const char kDBusFailedErrorMessage[] = "DBus call failed."; | 32 const char kDBusFailedErrorMessage[] = "DBus call failed."; |
| 35 | 33 |
| 36 void ClearPropertiesCallback( | 34 void ClearPropertiesCallback( |
| 37 const std::vector<std::string>& names, | 35 const std::vector<std::string>& names, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 callback.Run(service_path.value()); | 96 callback.Run(service_path.value()); |
| 99 } | 97 } |
| 100 | 98 |
| 101 void IgnoreObjectPathCallback(const base::Closure& callback, | 99 void IgnoreObjectPathCallback(const base::Closure& callback, |
| 102 const dbus::ObjectPath& object_path) { | 100 const dbus::ObjectPath& object_path) { |
| 103 callback.Run(); | 101 callback.Run(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 } // namespace | 104 } // namespace |
| 107 | 105 |
| 108 // static | |
| 109 void NetworkConfigurationHandler::Initialize() { | |
| 110 CHECK(!g_configuration_handler_instance); | |
| 111 g_configuration_handler_instance = new NetworkConfigurationHandler; | |
| 112 } | |
| 113 | |
| 114 // static | |
| 115 void NetworkConfigurationHandler::Shutdown() { | |
| 116 CHECK(g_configuration_handler_instance); | |
| 117 delete g_configuration_handler_instance; | |
| 118 g_configuration_handler_instance = NULL; | |
| 119 } | |
| 120 | |
| 121 // static | |
| 122 NetworkConfigurationHandler* NetworkConfigurationHandler::Get() { | |
| 123 CHECK(g_configuration_handler_instance) | |
| 124 << "NetworkConfigurationHandler::Get() called before Initialize()"; | |
| 125 return g_configuration_handler_instance; | |
| 126 } | |
| 127 | |
| 128 void NetworkConfigurationHandler::GetProperties( | 106 void NetworkConfigurationHandler::GetProperties( |
| 129 const std::string& service_path, | 107 const std::string& service_path, |
| 130 const network_handler::DictionaryResultCallback& callback, | 108 const network_handler::DictionaryResultCallback& callback, |
| 131 const network_handler::ErrorCallback& error_callback) const { | 109 const network_handler::ErrorCallback& error_callback) const { |
| 132 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( | 110 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( |
| 133 dbus::ObjectPath(service_path), | 111 dbus::ObjectPath(service_path), |
| 134 base::Bind(&RunCallbackWithDictionaryValue, | 112 base::Bind(&RunCallbackWithDictionaryValue, |
| 135 callback, | 113 callback, |
| 136 error_callback, | 114 error_callback, |
| 137 service_path)); | 115 service_path)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 base::Bind(&network_handler::ShillErrorCallbackFunction, | 186 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 209 service_path, error_callback)); | 187 service_path, error_callback)); |
| 210 } | 188 } |
| 211 | 189 |
| 212 NetworkConfigurationHandler::NetworkConfigurationHandler() { | 190 NetworkConfigurationHandler::NetworkConfigurationHandler() { |
| 213 } | 191 } |
| 214 | 192 |
| 215 NetworkConfigurationHandler::~NetworkConfigurationHandler() { | 193 NetworkConfigurationHandler::~NetworkConfigurationHandler() { |
| 216 } | 194 } |
| 217 | 195 |
| 196 // static |
| 197 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest() { |
| 198 return new NetworkConfigurationHandler(); |
| 199 } |
| 200 |
| 218 } // namespace chromeos | 201 } // namespace chromeos |
| OLD | NEW |