Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chromeos/dbus/shill_ipconfig_client.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/modem_messaging_client.cc ('k') | chromeos/dbus/shill_profile_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/scoped_ptr_map.h"
9 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chromeos/dbus/shill_property_changed_observer.h" 12 #include "chromeos/dbus/shill_property_changed_observer.h"
12 #include "dbus/bus.h" 13 #include "dbus/bus.h"
13 #include "dbus/message.h" 14 #include "dbus/message.h"
14 #include "dbus/object_path.h" 15 #include "dbus/object_path.h"
15 #include "dbus/object_proxy.h" 16 #include "dbus/object_proxy.h"
16 #include "dbus/values_util.h" 17 #include "dbus/values_util.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
(...skipping 30 matching lines...) Expand all
50 const std::string& name, 51 const std::string& name,
51 const VoidDBusMethodCallback& callback) override; 52 const VoidDBusMethodCallback& callback) override;
52 void Remove(const dbus::ObjectPath& ipconfig_path, 53 void Remove(const dbus::ObjectPath& ipconfig_path,
53 const VoidDBusMethodCallback& callback) override; 54 const VoidDBusMethodCallback& callback) override;
54 ShillIPConfigClient::TestInterface* GetTestInterface() override; 55 ShillIPConfigClient::TestInterface* GetTestInterface() override;
55 56
56 protected: 57 protected:
57 void Init(dbus::Bus* bus) override { bus_ = bus; } 58 void Init(dbus::Bus* bus) override { bus_ = bus; }
58 59
59 private: 60 private:
60 typedef std::map<std::string, ShillClientHelper*> HelperMap; 61 typedef base::ScopedPtrMap<std::string, scoped_ptr<ShillClientHelper>>
62 HelperMap;
61 63
62 // Returns the corresponding ShillClientHelper for the profile. 64 // Returns the corresponding ShillClientHelper for the profile.
63 ShillClientHelper* GetHelper(const dbus::ObjectPath& ipconfig_path) { 65 ShillClientHelper* GetHelper(const dbus::ObjectPath& ipconfig_path) {
64 HelperMap::iterator it = helpers_.find(ipconfig_path.value()); 66 HelperMap::const_iterator it = helpers_.find(ipconfig_path.value());
65 if (it != helpers_.end()) 67 if (it != helpers_.end())
66 return it->second; 68 return it->second;
67 69
68 // There is no helper for the profile, create it. 70 // There is no helper for the profile, create it.
69 dbus::ObjectProxy* object_proxy = 71 dbus::ObjectProxy* object_proxy =
70 bus_->GetObjectProxy(shill::kFlimflamServiceName, ipconfig_path); 72 bus_->GetObjectProxy(shill::kFlimflamServiceName, ipconfig_path);
71 ShillClientHelper* helper = new ShillClientHelper(object_proxy); 73 scoped_ptr<ShillClientHelper> helper(new ShillClientHelper(object_proxy));
72 helper->MonitorPropertyChanged(shill::kFlimflamIPConfigInterface); 74 helper->MonitorPropertyChanged(shill::kFlimflamIPConfigInterface);
73 helpers_.insert(HelperMap::value_type(ipconfig_path.value(), helper)); 75 ShillClientHelper* helper_ptr = helper.get();
74 return helper; 76 helpers_.insert(ipconfig_path.value(), helper.Pass());
77 return helper_ptr;
75 } 78 }
76 79
77 dbus::Bus* bus_; 80 dbus::Bus* bus_;
78 HelperMap helpers_; 81 HelperMap helpers_;
79 STLValueDeleter<HelperMap> helpers_deleter_;
80 82
81 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientImpl); 83 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClientImpl);
82 }; 84 };
83 85
84 ShillIPConfigClientImpl::ShillIPConfigClientImpl() 86 ShillIPConfigClientImpl::ShillIPConfigClientImpl() : bus_(NULL) {
85 : bus_(NULL),
86 helpers_deleter_(&helpers_) {
87 } 87 }
88 88
89 void ShillIPConfigClientImpl::GetProperties( 89 void ShillIPConfigClientImpl::GetProperties(
90 const dbus::ObjectPath& ipconfig_path, 90 const dbus::ObjectPath& ipconfig_path,
91 const DictionaryValueCallback& callback) { 91 const DictionaryValueCallback& callback) {
92 dbus::MethodCall method_call(shill::kFlimflamIPConfigInterface, 92 dbus::MethodCall method_call(shill::kFlimflamIPConfigInterface,
93 shill::kGetPropertiesFunction); 93 shill::kGetPropertiesFunction);
94 GetHelper(ipconfig_path)->CallDictionaryValueMethod(&method_call, callback); 94 GetHelper(ipconfig_path)->CallDictionaryValueMethod(&method_call, callback);
95 } 95 }
96 96
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ShillIPConfigClient::ShillIPConfigClient() {} 173 ShillIPConfigClient::ShillIPConfigClient() {}
174 174
175 ShillIPConfigClient::~ShillIPConfigClient() {} 175 ShillIPConfigClient::~ShillIPConfigClient() {}
176 176
177 // static 177 // static
178 ShillIPConfigClient* ShillIPConfigClient::Create() { 178 ShillIPConfigClient* ShillIPConfigClient::Create() {
179 return new ShillIPConfigClientImpl(); 179 return new ShillIPConfigClientImpl();
180 } 180 }
181 181
182 } // namespace chromeos 182 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/modem_messaging_client.cc ('k') | chromeos/dbus/shill_profile_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698