| 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_profile_client.h" | 5 #include "chromeos/dbus/shill_profile_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chromeos/dbus/shill_profile_client_stub.h" | 11 #include "chromeos/dbus/shill_profile_client_stub.h" |
| 12 #include "chromeos/dbus/shill_property_changed_observer.h" | 12 #include "chromeos/dbus/shill_property_changed_observer.h" |
| 13 #include "dbus/bus.h" | 13 #include "dbus/bus.h" |
| 14 #include "dbus/message.h" | 14 #include "dbus/message.h" |
| 15 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
| 16 #include "dbus/values_util.h" | 16 #include "dbus/values_util.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // The ShillProfileClient implementation. | |
| 24 class ShillProfileClientImpl : public ShillProfileClient { | 23 class ShillProfileClientImpl : public ShillProfileClient { |
| 25 public: | 24 public: |
| 26 explicit ShillProfileClientImpl(dbus::Bus* bus); | 25 explicit ShillProfileClientImpl(dbus::Bus* bus); |
| 27 | 26 |
| 28 ///////////////////////////////////// | |
| 29 // ShillProfileClient overrides. | 27 // ShillProfileClient overrides. |
| 30 virtual void AddPropertyChangedObserver( | 28 virtual void AddPropertyChangedObserver( |
| 31 const dbus::ObjectPath& profile_path, | 29 const dbus::ObjectPath& profile_path, |
| 32 ShillPropertyChangedObserver* observer) OVERRIDE { | 30 ShillPropertyChangedObserver* observer) OVERRIDE { |
| 33 GetHelper(profile_path)->AddPropertyChangedObserver(observer); | 31 GetHelper(profile_path)->AddPropertyChangedObserver(observer); |
| 34 } | 32 } |
| 35 | 33 |
| 36 virtual void RemovePropertyChangedObserver( | 34 virtual void RemovePropertyChangedObserver( |
| 37 const dbus::ObjectPath& profile_path, | 35 const dbus::ObjectPath& profile_path, |
| 38 ShillPropertyChangedObserver* observer) OVERRIDE { | 36 ShillPropertyChangedObserver* observer) OVERRIDE { |
| 39 GetHelper(profile_path)->RemovePropertyChangedObserver(observer); | 37 GetHelper(profile_path)->RemovePropertyChangedObserver(observer); |
| 40 } | 38 } |
| 41 virtual void GetProperties( | 39 virtual void GetProperties( |
| 42 const dbus::ObjectPath& profile_path, | 40 const dbus::ObjectPath& profile_path, |
| 43 const DictionaryValueCallbackWithoutStatus& callback, | 41 const DictionaryValueCallbackWithoutStatus& callback, |
| 44 const ErrorCallback& error_callback) OVERRIDE; | 42 const ErrorCallback& error_callback) OVERRIDE; |
| 45 virtual void GetEntry(const dbus::ObjectPath& profile_path, | 43 virtual void GetEntry(const dbus::ObjectPath& profile_path, |
| 46 const std::string& entry_path, | 44 const std::string& entry_path, |
| 47 const DictionaryValueCallbackWithoutStatus& callback, | 45 const DictionaryValueCallbackWithoutStatus& callback, |
| 48 const ErrorCallback& error_callback) OVERRIDE; | 46 const ErrorCallback& error_callback) OVERRIDE; |
| 49 virtual void DeleteEntry(const dbus::ObjectPath& profile_path, | 47 virtual void DeleteEntry(const dbus::ObjectPath& profile_path, |
| 50 const std::string& entry_path, | 48 const std::string& entry_path, |
| 51 const base::Closure& callback, | 49 const base::Closure& callback, |
| 52 const ErrorCallback& error_callback) OVERRIDE; | 50 const ErrorCallback& error_callback) OVERRIDE; |
| 53 | 51 |
| 52 virtual TestInterface* GetTestInterface() OVERRIDE { |
| 53 return NULL; |
| 54 } |
| 55 |
| 54 private: | 56 private: |
| 55 typedef std::map<std::string, ShillClientHelper*> HelperMap; | 57 typedef std::map<std::string, ShillClientHelper*> HelperMap; |
| 56 | 58 |
| 57 // Returns the corresponding ShillClientHelper for the profile. | 59 // Returns the corresponding ShillClientHelper for the profile. |
| 58 ShillClientHelper* GetHelper(const dbus::ObjectPath& profile_path); | 60 ShillClientHelper* GetHelper(const dbus::ObjectPath& profile_path); |
| 59 | 61 |
| 60 dbus::Bus* bus_; | 62 dbus::Bus* bus_; |
| 61 HelperMap helpers_; | 63 HelperMap helpers_; |
| 62 STLValueDeleter<HelperMap> helpers_deleter_; | 64 STLValueDeleter<HelperMap> helpers_deleter_; |
| 63 | 65 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ShillProfileClient* ShillProfileClient::Create( | 132 ShillProfileClient* ShillProfileClient::Create( |
| 131 DBusClientImplementationType type, | 133 DBusClientImplementationType type, |
| 132 dbus::Bus* bus) { | 134 dbus::Bus* bus) { |
| 133 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 135 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 134 return new ShillProfileClientImpl(bus); | 136 return new ShillProfileClientImpl(bus); |
| 135 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 137 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 136 return new ShillProfileClientStub(); | 138 return new ShillProfileClientStub(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 } // namespace chromeos | 141 } // namespace chromeos |
| OLD | NEW |