| 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/dbus/shill_service_client.h" | 5 #include "chromeos/dbus/shill_service_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 "Failed to call org.chromium.shill.Service.GetProperties for: " + | 29 "Failed to call org.chromium.shill.Service.GetProperties for: " + |
| 30 service_path.value() + ": " + error_name + ": " + error_message; | 30 service_path.value() + ": " + error_name + ": " + error_message; |
| 31 | 31 |
| 32 // Suppress ERROR log if error name is | 32 // Suppress ERROR log if error name is |
| 33 // "org.freedesktop.DBus.Error.UnknownMethod". crbug.com/130660 | 33 // "org.freedesktop.DBus.Error.UnknownMethod". crbug.com/130660 |
| 34 if (error_name == DBUS_ERROR_UNKNOWN_METHOD) | 34 if (error_name == DBUS_ERROR_UNKNOWN_METHOD) |
| 35 VLOG(1) << log_string; | 35 VLOG(1) << log_string; |
| 36 else | 36 else |
| 37 LOG(ERROR) << log_string; | 37 LOG(ERROR) << log_string; |
| 38 | 38 |
| 39 base::DictionaryValue empty_dictionary; | 39 scoped_ptr<base::DictionaryValue> empty_dictionary(new base::DictionaryValue); |
| 40 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); | 40 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary.Pass()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // The ShillServiceClient implementation. | 43 // The ShillServiceClient implementation. |
| 44 class ShillServiceClientImpl : public ShillServiceClient { | 44 class ShillServiceClientImpl : public ShillServiceClient { |
| 45 public: | 45 public: |
| 46 explicit ShillServiceClientImpl(dbus::Bus* bus) | 46 explicit ShillServiceClientImpl(dbus::Bus* bus) |
| 47 : bus_(bus), | 47 : bus_(bus), |
| 48 helpers_deleter_(&helpers_) { | 48 helpers_deleter_(&helpers_) { |
| 49 } | 49 } |
| 50 | 50 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 SetServiceProperty("stub_cellular1", | 349 SetServiceProperty("stub_cellular1", |
| 350 flimflam::kNetworkTechnologyProperty, | 350 flimflam::kNetworkTechnologyProperty, |
| 351 technology_value); | 351 technology_value); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void PassStubDictionaryValue(const dbus::ObjectPath& service_path, | 354 void PassStubDictionaryValue(const dbus::ObjectPath& service_path, |
| 355 const DictionaryValueCallback& callback) { | 355 const DictionaryValueCallback& callback) { |
| 356 base::DictionaryValue* dict = NULL; | 356 base::DictionaryValue* dict = NULL; |
| 357 if (!stub_services_.GetDictionaryWithoutPathExpansion( | 357 if (!stub_services_.GetDictionaryWithoutPathExpansion( |
| 358 service_path.value(), &dict)) { | 358 service_path.value(), &dict)) { |
| 359 base::DictionaryValue empty_dictionary; | 359 scoped_ptr<base::DictionaryValue> empty(new base::DictionaryValue); |
| 360 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); | 360 callback.Run(DBUS_METHOD_CALL_FAILURE, empty.Pass()); |
| 361 return; | 361 return; |
| 362 } | 362 } |
| 363 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dict); | 363 scoped_ptr<base::DictionaryValue> result_copy(dict->DeepCopy()); |
| 364 callback.Run(DBUS_METHOD_CALL_SUCCESS, result_copy.Pass()); |
| 364 } | 365 } |
| 365 | 366 |
| 366 void NotifyObserversPropertyChanged(const dbus::ObjectPath& service_path, | 367 void NotifyObserversPropertyChanged(const dbus::ObjectPath& service_path, |
| 367 const std::string& property) { | 368 const std::string& property) { |
| 368 base::DictionaryValue* dict = NULL; | 369 base::DictionaryValue* dict = NULL; |
| 369 std::string path = service_path.value(); | 370 std::string path = service_path.value(); |
| 370 if (!stub_services_.GetDictionaryWithoutPathExpansion(path, &dict)) { | 371 if (!stub_services_.GetDictionaryWithoutPathExpansion(path, &dict)) { |
| 371 LOG(ERROR) << "Notify for unknown service: " << path; | 372 LOG(ERROR) << "Notify for unknown service: " << path; |
| 372 return; | 373 return; |
| 373 } | 374 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 ShillServiceClient* ShillServiceClient::Create( | 414 ShillServiceClient* ShillServiceClient::Create( |
| 414 DBusClientImplementationType type, | 415 DBusClientImplementationType type, |
| 415 dbus::Bus* bus) { | 416 dbus::Bus* bus) { |
| 416 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 417 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 417 return new ShillServiceClientImpl(bus); | 418 return new ShillServiceClientImpl(bus); |
| 418 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 419 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 419 return new ShillServiceClientStubImpl(); | 420 return new ShillServiceClientStubImpl(); |
| 420 } | 421 } |
| 421 | 422 |
| 422 } // namespace chromeos | 423 } // namespace chromeos |
| OLD | NEW |