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_ipconfig_client.h" | 5 #include "chromeos/dbus/shill_ipconfig_client.h" |
6 | 6 |
| 7 #include <map> |
| 8 #include <utility> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/containers/scoped_ptr_map.h" | |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
11 #include "base/values.h" | 13 #include "base/values.h" |
12 #include "chromeos/dbus/shill_property_changed_observer.h" | 14 #include "chromeos/dbus/shill_property_changed_observer.h" |
13 #include "dbus/bus.h" | 15 #include "dbus/bus.h" |
14 #include "dbus/message.h" | 16 #include "dbus/message.h" |
15 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
16 #include "dbus/object_proxy.h" | 18 #include "dbus/object_proxy.h" |
17 #include "dbus/values_util.h" | 19 #include "dbus/values_util.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const std::string& name, | 53 const std::string& name, |
52 const VoidDBusMethodCallback& callback) override; | 54 const VoidDBusMethodCallback& callback) override; |
53 void Remove(const dbus::ObjectPath& ipconfig_path, | 55 void Remove(const dbus::ObjectPath& ipconfig_path, |
54 const VoidDBusMethodCallback& callback) override; | 56 const VoidDBusMethodCallback& callback) override; |
55 ShillIPConfigClient::TestInterface* GetTestInterface() override; | 57 ShillIPConfigClient::TestInterface* GetTestInterface() override; |
56 | 58 |
57 protected: | 59 protected: |
58 void Init(dbus::Bus* bus) override { bus_ = bus; } | 60 void Init(dbus::Bus* bus) override { bus_ = bus; } |
59 | 61 |
60 private: | 62 private: |
61 typedef base::ScopedPtrMap<std::string, scoped_ptr<ShillClientHelper>> | 63 using HelperMap = std::map<std::string, scoped_ptr<ShillClientHelper>>; |
62 HelperMap; | |
63 | 64 |
64 // Returns the corresponding ShillClientHelper for the profile. | 65 // Returns the corresponding ShillClientHelper for the profile. |
65 ShillClientHelper* GetHelper(const dbus::ObjectPath& ipconfig_path) { | 66 ShillClientHelper* GetHelper(const dbus::ObjectPath& ipconfig_path) { |
66 HelperMap::const_iterator it = helpers_.find(ipconfig_path.value()); | 67 HelperMap::const_iterator it = helpers_.find(ipconfig_path.value()); |
67 if (it != helpers_.end()) | 68 if (it != helpers_.end()) |
68 return it->second; | 69 return it->second.get(); |
69 | 70 |
70 // There is no helper for the profile, create it. | 71 // There is no helper for the profile, create it. |
71 dbus::ObjectProxy* object_proxy = | 72 dbus::ObjectProxy* object_proxy = |
72 bus_->GetObjectProxy(shill::kFlimflamServiceName, ipconfig_path); | 73 bus_->GetObjectProxy(shill::kFlimflamServiceName, ipconfig_path); |
73 scoped_ptr<ShillClientHelper> helper(new ShillClientHelper(object_proxy)); | 74 scoped_ptr<ShillClientHelper> helper(new ShillClientHelper(object_proxy)); |
74 helper->MonitorPropertyChanged(shill::kFlimflamIPConfigInterface); | 75 helper->MonitorPropertyChanged(shill::kFlimflamIPConfigInterface); |
75 ShillClientHelper* helper_ptr = helper.get(); | 76 ShillClientHelper* helper_ptr = helper.get(); |
76 helpers_.insert(ipconfig_path.value(), helper.Pass()); | 77 helpers_[ipconfig_path.value()] = std::move(helper); |
77 return helper_ptr; | 78 return helper_ptr; |
78 } | 79 } |
79 | 80 |
80 dbus::Bus* bus_; | 81 dbus::Bus* bus_; |
81 HelperMap helpers_; | 82 HelperMap helpers_; |
82 | 83 |
83 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientImpl); | 84 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientImpl); |
84 }; | 85 }; |
85 | 86 |
86 ShillIPConfigClientImpl::ShillIPConfigClientImpl() : bus_(NULL) { | 87 ShillIPConfigClientImpl::ShillIPConfigClientImpl() : bus_(NULL) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 ShillIPConfigClient::ShillIPConfigClient() {} | 174 ShillIPConfigClient::ShillIPConfigClient() {} |
174 | 175 |
175 ShillIPConfigClient::~ShillIPConfigClient() {} | 176 ShillIPConfigClient::~ShillIPConfigClient() {} |
176 | 177 |
177 // static | 178 // static |
178 ShillIPConfigClient* ShillIPConfigClient::Create() { | 179 ShillIPConfigClient* ShillIPConfigClient::Create() { |
179 return new ShillIPConfigClientImpl(); | 180 return new ShillIPConfigClientImpl(); |
180 } | 181 } |
181 | 182 |
182 } // namespace chromeos | 183 } // namespace chromeos |
OLD | NEW |