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

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

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 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/shill_profile_client.h ('k') | chromeos/dbus/shill_profile_client_unittest.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/flimflam_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 "dbus/bus.h" 11 #include "dbus/bus.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 #include "dbus/object_path.h" 13 #include "dbus/object_path.h"
14 #include "dbus/values_util.h" 14 #include "dbus/values_util.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 15 #include "third_party/cros_system_api/dbus/service_constants.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 namespace { 19 namespace {
20 20
21 // The FlimflamProfileClient implementation. 21 // The ShillProfileClient implementation.
22 class FlimflamProfileClientImpl : public FlimflamProfileClient { 22 class ShillProfileClientImpl : public ShillProfileClient {
23 public: 23 public:
24 explicit FlimflamProfileClientImpl(dbus::Bus* bus); 24 explicit ShillProfileClientImpl(dbus::Bus* bus);
25 25
26 // FlimflamProfileClient overrides: 26 // ShillProfileClient overrides:
27 virtual void SetPropertyChangedHandler( 27 virtual void SetPropertyChangedHandler(
28 const dbus::ObjectPath& profile_path, 28 const dbus::ObjectPath& profile_path,
29 const PropertyChangedHandler& handler) OVERRIDE; 29 const PropertyChangedHandler& handler) OVERRIDE;
30 virtual void ResetPropertyChangedHandler( 30 virtual void ResetPropertyChangedHandler(
31 const dbus::ObjectPath& profile_path) OVERRIDE; 31 const dbus::ObjectPath& profile_path) OVERRIDE;
32 virtual void GetProperties(const dbus::ObjectPath& profile_path, 32 virtual void GetProperties(const dbus::ObjectPath& profile_path,
33 const DictionaryValueCallback& callback) OVERRIDE; 33 const DictionaryValueCallback& callback) OVERRIDE;
34 virtual void GetEntry(const dbus::ObjectPath& profile_path, 34 virtual void GetEntry(const dbus::ObjectPath& profile_path,
35 const std::string& entry_path, 35 const std::string& entry_path,
36 const DictionaryValueCallback& callback) OVERRIDE; 36 const DictionaryValueCallback& callback) OVERRIDE;
37 virtual void DeleteEntry(const dbus::ObjectPath& profile_path, 37 virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
38 const std::string& entry_path, 38 const std::string& entry_path,
39 const VoidDBusMethodCallback& callback) OVERRIDE; 39 const VoidDBusMethodCallback& callback) OVERRIDE;
40 40
41 private: 41 private:
42 typedef std::map<std::string, FlimflamClientHelper*> HelperMap; 42 typedef std::map<std::string, ShillClientHelper*> HelperMap;
43 43
44 // Returns the corresponding FlimflamClientHelper for the profile. 44 // Returns the corresponding ShillClientHelper for the profile.
45 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& profile_path); 45 ShillClientHelper* GetHelper(const dbus::ObjectPath& profile_path);
46 46
47 dbus::Bus* bus_; 47 dbus::Bus* bus_;
48 HelperMap helpers_; 48 HelperMap helpers_;
49 STLValueDeleter<HelperMap> helpers_deleter_; 49 STLValueDeleter<HelperMap> helpers_deleter_;
50 50
51 DISALLOW_COPY_AND_ASSIGN(FlimflamProfileClientImpl); 51 DISALLOW_COPY_AND_ASSIGN(ShillProfileClientImpl);
52 }; 52 };
53 53
54 FlimflamProfileClientImpl::FlimflamProfileClientImpl(dbus::Bus* bus) 54 ShillProfileClientImpl::ShillProfileClientImpl(dbus::Bus* bus)
55 : bus_(bus), 55 : bus_(bus),
56 helpers_deleter_(&helpers_) { 56 helpers_deleter_(&helpers_) {
57 } 57 }
58 58
59 FlimflamClientHelper* FlimflamProfileClientImpl::GetHelper( 59 ShillClientHelper* ShillProfileClientImpl::GetHelper(
60 const dbus::ObjectPath& profile_path) { 60 const dbus::ObjectPath& profile_path) {
61 HelperMap::iterator it = helpers_.find(profile_path.value()); 61 HelperMap::iterator it = helpers_.find(profile_path.value());
62 if (it != helpers_.end()) 62 if (it != helpers_.end())
63 return it->second; 63 return it->second;
64 64
65 // There is no helper for the profile, create it. 65 // There is no helper for the profile, create it.
66 dbus::ObjectProxy* object_proxy = 66 dbus::ObjectProxy* object_proxy =
67 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, profile_path); 67 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, profile_path);
68 FlimflamClientHelper* helper = new FlimflamClientHelper(bus_, object_proxy); 68 ShillClientHelper* helper = new ShillClientHelper(bus_, object_proxy);
69 helper->MonitorPropertyChanged(flimflam::kFlimflamProfileInterface); 69 helper->MonitorPropertyChanged(flimflam::kFlimflamProfileInterface);
70 helpers_.insert(HelperMap::value_type(profile_path.value(), helper)); 70 helpers_.insert(HelperMap::value_type(profile_path.value(), helper));
71 return helper; 71 return helper;
72 } 72 }
73 73
74 void FlimflamProfileClientImpl::SetPropertyChangedHandler( 74 void ShillProfileClientImpl::SetPropertyChangedHandler(
75 const dbus::ObjectPath& profile_path, 75 const dbus::ObjectPath& profile_path,
76 const PropertyChangedHandler& handler) { 76 const PropertyChangedHandler& handler) {
77 GetHelper(profile_path)->SetPropertyChangedHandler(handler); 77 GetHelper(profile_path)->SetPropertyChangedHandler(handler);
78 } 78 }
79 79
80 void FlimflamProfileClientImpl::ResetPropertyChangedHandler( 80 void ShillProfileClientImpl::ResetPropertyChangedHandler(
81 const dbus::ObjectPath& profile_path) { 81 const dbus::ObjectPath& profile_path) {
82 GetHelper(profile_path)->ResetPropertyChangedHandler(); 82 GetHelper(profile_path)->ResetPropertyChangedHandler();
83 } 83 }
84 84
85 void FlimflamProfileClientImpl::GetProperties( 85 void ShillProfileClientImpl::GetProperties(
86 const dbus::ObjectPath& profile_path, 86 const dbus::ObjectPath& profile_path,
87 const DictionaryValueCallback& callback) { 87 const DictionaryValueCallback& callback) {
88 dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface, 88 dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
89 flimflam::kGetPropertiesFunction); 89 flimflam::kGetPropertiesFunction);
90 GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback); 90 GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback);
91 } 91 }
92 92
93 void FlimflamProfileClientImpl::GetEntry( 93 void ShillProfileClientImpl::GetEntry(
94 const dbus::ObjectPath& profile_path, 94 const dbus::ObjectPath& profile_path,
95 const std::string& entry_path, 95 const std::string& entry_path,
96 const DictionaryValueCallback& callback) { 96 const DictionaryValueCallback& callback) {
97 dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface, 97 dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
98 flimflam::kGetEntryFunction); 98 flimflam::kGetEntryFunction);
99 dbus::MessageWriter writer(&method_call); 99 dbus::MessageWriter writer(&method_call);
100 writer.AppendString(entry_path); 100 writer.AppendString(entry_path);
101 GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback); 101 GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback);
102 } 102 }
103 103
104 void FlimflamProfileClientImpl::DeleteEntry( 104 void ShillProfileClientImpl::DeleteEntry(
105 const dbus::ObjectPath& profile_path, 105 const dbus::ObjectPath& profile_path,
106 const std::string& entry_path, 106 const std::string& entry_path,
107 const VoidDBusMethodCallback& callback) { 107 const VoidDBusMethodCallback& callback) {
108 dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface, 108 dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
109 flimflam::kDeleteEntryFunction); 109 flimflam::kDeleteEntryFunction);
110 dbus::MessageWriter writer(&method_call); 110 dbus::MessageWriter writer(&method_call);
111 writer.AppendString(entry_path); 111 writer.AppendString(entry_path);
112 GetHelper(profile_path)->CallVoidMethod(&method_call, callback); 112 GetHelper(profile_path)->CallVoidMethod(&method_call, callback);
113 } 113 }
114 114
115 // A stub implementation of FlimflamProfileClient. 115 // A stub implementation of ShillProfileClient.
116 class FlimflamProfileClientStubImpl : public FlimflamProfileClient { 116 class ShillProfileClientStubImpl : public ShillProfileClient {
117 public: 117 public:
118 FlimflamProfileClientStubImpl() : weak_ptr_factory_(this) {} 118 ShillProfileClientStubImpl() : weak_ptr_factory_(this) {}
119 119
120 virtual ~FlimflamProfileClientStubImpl() {} 120 virtual ~ShillProfileClientStubImpl() {}
121 121
122 // FlimflamProfileClient override. 122 // ShillProfileClient override.
123 virtual void SetPropertyChangedHandler( 123 virtual void SetPropertyChangedHandler(
124 const dbus::ObjectPath& profile_path, 124 const dbus::ObjectPath& profile_path,
125 const PropertyChangedHandler& handler) OVERRIDE {} 125 const PropertyChangedHandler& handler) OVERRIDE {}
126 126
127 // FlimflamProfileClient override. 127 // ShillProfileClient override.
128 virtual void ResetPropertyChangedHandler( 128 virtual void ResetPropertyChangedHandler(
129 const dbus::ObjectPath& profile_path) OVERRIDE {} 129 const dbus::ObjectPath& profile_path) OVERRIDE {}
130 130
131 // FlimflamProfileClient override. 131 // ShillProfileClient override.
132 virtual void GetProperties(const dbus::ObjectPath& profile_path, 132 virtual void GetProperties(const dbus::ObjectPath& profile_path,
133 const DictionaryValueCallback& callback) OVERRIDE { 133 const DictionaryValueCallback& callback) OVERRIDE {
134 MessageLoop::current()->PostTask( 134 MessageLoop::current()->PostTask(
135 FROM_HERE, 135 FROM_HERE,
136 base::Bind(&FlimflamProfileClientStubImpl::PassEmptyDictionaryValue, 136 base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue,
137 weak_ptr_factory_.GetWeakPtr(), 137 weak_ptr_factory_.GetWeakPtr(),
138 callback)); 138 callback));
139 } 139 }
140 140
141 // FlimflamProfileClient override. 141 // ShillProfileClient override.
142 virtual void GetEntry(const dbus::ObjectPath& profile_path, 142 virtual void GetEntry(const dbus::ObjectPath& profile_path,
143 const std::string& entry_path, 143 const std::string& entry_path,
144 const DictionaryValueCallback& callback) OVERRIDE { 144 const DictionaryValueCallback& callback) OVERRIDE {
145 MessageLoop::current()->PostTask( 145 MessageLoop::current()->PostTask(
146 FROM_HERE, 146 FROM_HERE,
147 base::Bind(&FlimflamProfileClientStubImpl::PassEmptyDictionaryValue, 147 base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue,
148 weak_ptr_factory_.GetWeakPtr(), 148 weak_ptr_factory_.GetWeakPtr(),
149 callback)); 149 callback));
150 } 150 }
151 151
152 // FlimflamProfileClient override. 152 // ShillProfileClient override.
153 virtual void DeleteEntry(const dbus::ObjectPath& profile_path, 153 virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
154 const std::string& entry_path, 154 const std::string& entry_path,
155 const VoidDBusMethodCallback& callback) OVERRIDE { 155 const VoidDBusMethodCallback& callback) OVERRIDE {
156 MessageLoop::current()->PostTask(FROM_HERE, 156 MessageLoop::current()->PostTask(FROM_HERE,
157 base::Bind(callback, 157 base::Bind(callback,
158 DBUS_METHOD_CALL_SUCCESS)); 158 DBUS_METHOD_CALL_SUCCESS));
159 } 159 }
160 160
161 private: 161 private:
162 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const { 162 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const {
163 base::DictionaryValue dictionary; 163 base::DictionaryValue dictionary;
164 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); 164 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary);
165 } 165 }
166 166
167 // Note: This should remain the last member so it'll be destroyed and 167 // Note: This should remain the last member so it'll be destroyed and
168 // invalidate its weak pointers before any other members are destroyed. 168 // invalidate its weak pointers before any other members are destroyed.
169 base::WeakPtrFactory<FlimflamProfileClientStubImpl> weak_ptr_factory_; 169 base::WeakPtrFactory<ShillProfileClientStubImpl> weak_ptr_factory_;
170 170
171 DISALLOW_COPY_AND_ASSIGN(FlimflamProfileClientStubImpl); 171 DISALLOW_COPY_AND_ASSIGN(ShillProfileClientStubImpl);
172 }; 172 };
173 173
174 } // namespace 174 } // namespace
175 175
176 FlimflamProfileClient::FlimflamProfileClient() {} 176 ShillProfileClient::ShillProfileClient() {}
177 177
178 FlimflamProfileClient::~FlimflamProfileClient() {} 178 ShillProfileClient::~ShillProfileClient() {}
179 179
180 // static 180 // static
181 FlimflamProfileClient* FlimflamProfileClient::Create( 181 ShillProfileClient* ShillProfileClient::Create(
182 DBusClientImplementationType type, 182 DBusClientImplementationType type,
183 dbus::Bus* bus) { 183 dbus::Bus* bus) {
184 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 184 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
185 return new FlimflamProfileClientImpl(bus); 185 return new ShillProfileClientImpl(bus);
186 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 186 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
187 return new FlimflamProfileClientStubImpl(); 187 return new ShillProfileClientStubImpl();
188 } 188 }
189 189
190 } // namespace chromeos 190 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_profile_client.h ('k') | chromeos/dbus/shill_profile_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698