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