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

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

Issue 1454773002: Play better with C++11 library features from /chromeos (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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_profile_client.h" 5 #include "chromeos/dbus/shill_profile_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/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/dbus/shill_property_changed_observer.h" 15 #include "chromeos/dbus/shill_property_changed_observer.h"
14 #include "dbus/bus.h" 16 #include "dbus/bus.h"
15 #include "dbus/message.h" 17 #include "dbus/message.h"
16 #include "dbus/object_path.h" 18 #include "dbus/object_path.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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const std::string& entry_path, 52 const std::string& entry_path,
51 const base::Closure& callback, 53 const base::Closure& callback,
52 const ErrorCallback& error_callback) override; 54 const ErrorCallback& error_callback) override;
53 55
54 TestInterface* GetTestInterface() override { return NULL; } 56 TestInterface* GetTestInterface() override { return NULL; }
55 57
56 protected: 58 protected:
57 void Init(dbus::Bus* bus) override { bus_ = bus; } 59 void Init(dbus::Bus* bus) override { bus_ = bus; }
58 60
59 private: 61 private:
60 typedef base::ScopedPtrMap<std::string, scoped_ptr<ShillClientHelper>> 62 using HelperMap = std::map<std::string, scoped_ptr<ShillClientHelper>>;
61 HelperMap;
62 63
63 // Returns the corresponding ShillClientHelper for the profile. 64 // Returns the corresponding ShillClientHelper for the profile.
64 ShillClientHelper* GetHelper(const dbus::ObjectPath& profile_path); 65 ShillClientHelper* GetHelper(const dbus::ObjectPath& profile_path);
65 66
66 dbus::Bus* bus_; 67 dbus::Bus* bus_;
67 HelperMap helpers_; 68 HelperMap helpers_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(ShillProfileClientImpl); 70 DISALLOW_COPY_AND_ASSIGN(ShillProfileClientImpl);
70 }; 71 };
71 72
72 ShillProfileClientImpl::ShillProfileClientImpl() : bus_(NULL) { 73 ShillProfileClientImpl::ShillProfileClientImpl() : bus_(NULL) {
73 } 74 }
74 75
75 ShillClientHelper* ShillProfileClientImpl::GetHelper( 76 ShillClientHelper* ShillProfileClientImpl::GetHelper(
76 const dbus::ObjectPath& profile_path) { 77 const dbus::ObjectPath& profile_path) {
77 HelperMap::const_iterator it = helpers_.find(profile_path.value()); 78 HelperMap::const_iterator it = helpers_.find(profile_path.value());
78 if (it != helpers_.end()) 79 if (it != helpers_.end())
79 return it->second; 80 return it->second.get();
80 81
81 // There is no helper for the profile, create it. 82 // There is no helper for the profile, create it.
82 dbus::ObjectProxy* object_proxy = 83 dbus::ObjectProxy* object_proxy =
83 bus_->GetObjectProxy(shill::kFlimflamServiceName, profile_path); 84 bus_->GetObjectProxy(shill::kFlimflamServiceName, profile_path);
84 scoped_ptr<ShillClientHelper> helper(new ShillClientHelper(object_proxy)); 85 scoped_ptr<ShillClientHelper> helper(new ShillClientHelper(object_proxy));
85 helper->MonitorPropertyChanged(shill::kFlimflamProfileInterface); 86 helper->MonitorPropertyChanged(shill::kFlimflamProfileInterface);
86 ShillClientHelper* helper_ptr = helper.get(); 87 ShillClientHelper* helper_ptr = helper.get();
87 helpers_.insert(profile_path.value(), helper.Pass()); 88 helpers_[profile_path.value()] = std::move(helper);
88 return helper_ptr; 89 return helper_ptr;
89 } 90 }
90 91
91 void ShillProfileClientImpl::GetProperties( 92 void ShillProfileClientImpl::GetProperties(
92 const dbus::ObjectPath& profile_path, 93 const dbus::ObjectPath& profile_path,
93 const DictionaryValueCallbackWithoutStatus& callback, 94 const DictionaryValueCallbackWithoutStatus& callback,
94 const ErrorCallback& error_callback) { 95 const ErrorCallback& error_callback) {
95 dbus::MethodCall method_call(shill::kFlimflamProfileInterface, 96 dbus::MethodCall method_call(shill::kFlimflamProfileInterface,
96 shill::kGetPropertiesFunction); 97 shill::kGetPropertiesFunction);
97 GetHelper(profile_path)->CallDictionaryValueMethodWithErrorCallback( 98 GetHelper(profile_path)->CallDictionaryValueMethodWithErrorCallback(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ShillProfileClient* ShillProfileClient::Create() { 135 ShillProfileClient* ShillProfileClient::Create() {
135 return new ShillProfileClientImpl(); 136 return new ShillProfileClientImpl();
136 } 137 }
137 138
138 // static 139 // static
139 std::string ShillProfileClient::GetSharedProfilePath() { 140 std::string ShillProfileClient::GetSharedProfilePath() {
140 return std::string(kSharedProfilePath); 141 return std::string(kSharedProfilePath);
141 } 142 }
142 143
143 } // namespace chromeos 144 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_ipconfig_client.cc ('k') | chromeos/network/managed_network_configuration_handler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698