Chromium Code Reviews| 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_service_client.h" | 5 #include "chromeos/dbus/shill_service_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 // "org.freedesktop.DBus.Error.UnknownMethod". crbug.com/130660 | 33 // "org.freedesktop.DBus.Error.UnknownMethod". crbug.com/130660 |
| 34 if (error_name == DBUS_ERROR_UNKNOWN_METHOD) | 34 if (error_name == DBUS_ERROR_UNKNOWN_METHOD) |
| 35 VLOG(1) << log_string; | 35 VLOG(1) << log_string; |
| 36 else | 36 else |
| 37 LOG(ERROR) << log_string; | 37 LOG(ERROR) << log_string; |
| 38 | 38 |
| 39 base::DictionaryValue empty_dictionary; | 39 base::DictionaryValue empty_dictionary; |
| 40 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); | 40 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // ShillClientHelper callback wrappers. | |
| 44 // For each one of the different callback types in ShillClientHelper, we define | |
| 45 // a wrapper that attachs a clousure to the given callback. It allows to call a | |
|
stevenjb
2013/02/06 01:05:53
s/It allows to/This allows it to/
deymo
2013/02/06 05:44:45
Done.
| |
| 46 // second callback (the clousure) after the first callback is called. This is | |
| 47 // used to get a notification in the ShillServiceClient when a MethodCall | |
| 48 // returns. | |
| 49 | |
| 50 // * Wrapper for DictionaryValueCallback. | |
| 51 void RunDictionaryValueCallback( | |
| 52 base::ScopedClosureRunner* closure_runner, | |
| 53 const ShillClientHelper::DictionaryValueCallback& callback, | |
| 54 DBusMethodCallStatus call_status, | |
| 55 const DictionaryValue& argument) { | |
| 56 callback.Run(call_status, argument); | |
| 57 } | |
| 58 | |
| 59 ShillClientHelper::DictionaryValueCallback | |
| 60 AttachClosureToDictionaryValueCallabck( | |
|
stevenjb
2013/02/06 01:05:53
s/abck/back
deymo
2013/02/06 05:44:45
=)
| |
| 61 const ShillClientHelper::DictionaryValueCallback& callback, | |
| 62 const base::Closure& closure) { | |
| 63 return base::Bind(&RunDictionaryValueCallback, | |
| 64 base::Owned(new base::ScopedClosureRunner(closure)), callback); | |
| 65 } | |
| 66 | |
| 67 // * Wrapper for ListValueCallback | |
| 68 void RunListValueCallback( | |
| 69 base::ScopedClosureRunner* closure_runner, | |
| 70 const ShillClientHelper::ListValueCallback& callback, | |
| 71 const ListValue& argument) { | |
| 72 callback.Run(argument); | |
| 73 } | |
| 74 | |
| 75 ShillClientHelper::ListValueCallback AttachClosureToListValueCallback( | |
| 76 const ShillClientHelper::ListValueCallback& callback, | |
| 77 const base::Closure& closure) { | |
| 78 return base::Bind(&RunListValueCallback, | |
| 79 base::Owned(new base::ScopedClosureRunner(closure)), callback); | |
| 80 } | |
| 81 | |
| 82 // * Wrapper for ErrorCallback | |
| 83 void RunErrorCallback( | |
| 84 base::ScopedClosureRunner* closure_runner, | |
| 85 const ShillClientHelper::ErrorCallback& callback, | |
| 86 const std::string& error_name, | |
| 87 const std::string& error_message) { | |
| 88 callback.Run(error_name, error_message); | |
| 89 } | |
| 90 | |
| 91 ShillClientHelper::ErrorCallback AttachClosureToErrorCallback( | |
| 92 const ShillClientHelper::ErrorCallback& callback, | |
| 93 const base::Closure& closure) { | |
| 94 return base::Bind(&RunErrorCallback, | |
| 95 base::Owned(new base::ScopedClosureRunner(closure)), callback); | |
| 96 } | |
| 97 | |
| 98 // * Wrapper for Closure | |
| 99 void RunClosure(base::ScopedClosureRunner* closure_runner, | |
| 100 const base::Closure& callback) { | |
| 101 callback.Run(); | |
| 102 } | |
| 103 | |
| 104 base::Closure AttachClosureToClosure( | |
| 105 const base::Closure& callback, | |
| 106 const base::Closure& closure) { | |
| 107 return base::Bind(&RunClosure, | |
| 108 base::Owned(new base::ScopedClosureRunner(closure)), callback); | |
| 109 } | |
| 110 | |
| 43 // The ShillServiceClient implementation. | 111 // The ShillServiceClient implementation. |
| 44 class ShillServiceClientImpl : public ShillServiceClient { | 112 class ShillServiceClientImpl : public ShillServiceClient { |
| 45 public: | 113 public: |
| 46 explicit ShillServiceClientImpl(dbus::Bus* bus) | 114 explicit ShillServiceClientImpl(dbus::Bus* bus) |
| 47 : bus_(bus), | 115 : bus_(bus), |
| 48 helpers_deleter_(&helpers_) { | 116 helpers_deleter_(&helpers_), |
| 117 weak_ptr_factory_(this) { | |
| 49 } | 118 } |
| 50 | 119 |
| 51 ///////////////////////////////////// | 120 ///////////////////////////////////// |
| 52 // ShillServiceClient overrides. | 121 // ShillServiceClient overrides. |
| 53 virtual void AddPropertyChangedObserver( | 122 virtual void AddPropertyChangedObserver( |
| 54 const dbus::ObjectPath& service_path, | 123 const dbus::ObjectPath& service_path, |
| 55 ShillPropertyChangedObserver* observer) OVERRIDE { | 124 ShillPropertyChangedObserver* observer) OVERRIDE { |
| 56 GetHelper(service_path)->AddPropertyChangedObserver(observer); | 125 GetHelper(service_path)->AddPropertyChangedObserver(observer); |
| 57 } | 126 } |
| 58 | 127 |
| 59 virtual void RemovePropertyChangedObserver( | 128 virtual void RemovePropertyChangedObserver( |
| 60 const dbus::ObjectPath& service_path, | 129 const dbus::ObjectPath& service_path, |
| 61 ShillPropertyChangedObserver* observer) OVERRIDE { | 130 ShillPropertyChangedObserver* observer) OVERRIDE { |
| 62 GetHelper(service_path)->RemovePropertyChangedObserver(observer); | 131 GetHelper(service_path)->RemovePropertyChangedObserver(observer); |
| 63 } | 132 } |
| 64 | 133 |
| 65 virtual void GetProperties(const dbus::ObjectPath& service_path, | 134 virtual void GetProperties(const dbus::ObjectPath& service_path, |
| 66 const DictionaryValueCallback& callback) OVERRIDE { | 135 const DictionaryValueCallback& callback) OVERRIDE { |
| 67 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 136 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 68 flimflam::kGetPropertiesFunction); | 137 flimflam::kGetPropertiesFunction); |
| 69 GetHelper(service_path)->CallDictionaryValueMethodWithErrorCallback( | 138 GetHelper(service_path)->CallDictionaryValueMethodWithErrorCallback( |
| 70 &method_call, | 139 &method_call, |
| 71 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS), | 140 base::Bind( |
| 72 base::Bind(&OnGetPropertiesError, service_path, callback)); | 141 AttachClosureToDictionaryValueCallabck(callback, |
| 142 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 143 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 144 DBUS_METHOD_CALL_SUCCESS), | |
| 145 AttachClosureToErrorCallback( | |
| 146 base::Bind(&OnGetPropertiesError, service_path, callback), | |
| 147 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 148 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
|
stevenjb
2013/02/06 01:05:53
Rather than passing HelperStatusUpdate in each of
deymo
2013/02/06 05:44:45
If we do that we still need to pass the service_pa
stevenjb
2013/02/06 17:10:20
That sounds like it would be fine. It's definitely
| |
| 73 } | 149 } |
| 74 | 150 |
| 75 virtual void SetProperty(const dbus::ObjectPath& service_path, | 151 virtual void SetProperty(const dbus::ObjectPath& service_path, |
| 76 const std::string& name, | 152 const std::string& name, |
| 77 const base::Value& value, | 153 const base::Value& value, |
| 78 const base::Closure& callback, | 154 const base::Closure& callback, |
| 79 const ErrorCallback& error_callback) OVERRIDE { | 155 const ErrorCallback& error_callback) OVERRIDE { |
| 80 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 156 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 81 flimflam::kSetPropertyFunction); | 157 flimflam::kSetPropertyFunction); |
| 82 dbus::MessageWriter writer(&method_call); | 158 dbus::MessageWriter writer(&method_call); |
| 83 writer.AppendString(name); | 159 writer.AppendString(name); |
| 84 ShillClientHelper::AppendValueDataAsVariant(&writer, value); | 160 ShillClientHelper::AppendValueDataAsVariant(&writer, value); |
| 85 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 161 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 86 callback, | 162 &method_call, |
| 87 error_callback); | 163 AttachClosureToClosure(callback, |
|
hashimoto
2013/02/06 03:29:06
I think ScopedClosureRunner runs the closure on it
deymo
2013/02/06 05:44:45
Yes, the ScopedClosureRunner will run allways... b
| |
| 164 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 165 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 166 AttachClosureToErrorCallback(error_callback, | |
| 167 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 168 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 88 } | 169 } |
| 89 | 170 |
| 90 virtual void ClearProperty(const dbus::ObjectPath& service_path, | 171 virtual void ClearProperty(const dbus::ObjectPath& service_path, |
| 91 const std::string& name, | 172 const std::string& name, |
| 92 const base::Closure& callback, | 173 const base::Closure& callback, |
| 93 const ErrorCallback& error_callback) OVERRIDE { | 174 const ErrorCallback& error_callback) OVERRIDE { |
| 94 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 175 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 95 flimflam::kClearPropertyFunction); | 176 flimflam::kClearPropertyFunction); |
| 96 dbus::MessageWriter writer(&method_call); | 177 dbus::MessageWriter writer(&method_call); |
| 97 writer.AppendString(name); | 178 writer.AppendString(name); |
| 98 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 179 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 99 callback, | 180 &method_call, |
| 100 error_callback); | 181 AttachClosureToClosure(callback, |
| 182 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 183 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 184 AttachClosureToErrorCallback(error_callback, | |
| 185 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 186 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 101 } | 187 } |
| 102 | 188 |
| 103 | 189 |
| 104 virtual void ClearProperties(const dbus::ObjectPath& service_path, | 190 virtual void ClearProperties(const dbus::ObjectPath& service_path, |
| 105 const std::vector<std::string>& names, | 191 const std::vector<std::string>& names, |
| 106 const ListValueCallback& callback, | 192 const ListValueCallback& callback, |
| 107 const ErrorCallback& error_callback) OVERRIDE { | 193 const ErrorCallback& error_callback) OVERRIDE { |
| 108 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 194 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 109 shill::kClearPropertiesFunction); | 195 shill::kClearPropertiesFunction); |
| 110 dbus::MessageWriter writer(&method_call); | 196 dbus::MessageWriter writer(&method_call); |
| 111 writer.AppendArrayOfStrings(names); | 197 writer.AppendArrayOfStrings(names); |
| 112 GetHelper(service_path)->CallListValueMethodWithErrorCallback( | 198 GetHelper(service_path)->CallListValueMethodWithErrorCallback( |
| 113 &method_call, | 199 &method_call, |
| 114 callback, | 200 AttachClosureToListValueCallback(callback, |
| 115 error_callback); | 201 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, |
| 202 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 203 AttachClosureToErrorCallback(error_callback, | |
| 204 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 205 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 116 } | 206 } |
| 117 | 207 |
| 118 virtual void Connect(const dbus::ObjectPath& service_path, | 208 virtual void Connect(const dbus::ObjectPath& service_path, |
| 119 const base::Closure& callback, | 209 const base::Closure& callback, |
| 120 const ErrorCallback& error_callback) OVERRIDE { | 210 const ErrorCallback& error_callback) OVERRIDE { |
| 121 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 211 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 122 flimflam::kConnectFunction); | 212 flimflam::kConnectFunction); |
| 123 GetHelper(service_path)->CallVoidMethodWithErrorCallback( | 213 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 124 &method_call, callback, error_callback); | 214 &method_call, |
| 215 AttachClosureToClosure(callback, | |
| 216 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 217 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 218 AttachClosureToErrorCallback(error_callback, | |
| 219 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 220 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 125 } | 221 } |
| 126 | 222 |
| 127 virtual void Disconnect(const dbus::ObjectPath& service_path, | 223 virtual void Disconnect(const dbus::ObjectPath& service_path, |
| 128 const base::Closure& callback, | 224 const base::Closure& callback, |
| 129 const ErrorCallback& error_callback) OVERRIDE { | 225 const ErrorCallback& error_callback) OVERRIDE { |
| 130 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 226 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 131 flimflam::kDisconnectFunction); | 227 flimflam::kDisconnectFunction); |
| 132 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 228 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 133 callback, | 229 &method_call, |
| 134 error_callback); | 230 AttachClosureToClosure(callback, |
| 231 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 232 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 233 AttachClosureToErrorCallback(error_callback, | |
| 234 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 235 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 135 } | 236 } |
| 136 | 237 |
| 137 virtual void Remove(const dbus::ObjectPath& service_path, | 238 virtual void Remove(const dbus::ObjectPath& service_path, |
| 138 const base::Closure& callback, | 239 const base::Closure& callback, |
| 139 const ErrorCallback& error_callback) OVERRIDE { | 240 const ErrorCallback& error_callback) OVERRIDE { |
| 140 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 241 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 141 flimflam::kRemoveServiceFunction); | 242 flimflam::kRemoveServiceFunction); |
| 142 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 243 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 143 callback, | 244 &method_call, |
| 144 error_callback); | 245 AttachClosureToClosure(callback, |
| 246 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 247 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 248 AttachClosureToErrorCallback(error_callback, | |
| 249 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 250 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 145 } | 251 } |
| 146 | 252 |
| 147 virtual void ActivateCellularModem( | 253 virtual void ActivateCellularModem( |
| 148 const dbus::ObjectPath& service_path, | 254 const dbus::ObjectPath& service_path, |
| 149 const std::string& carrier, | 255 const std::string& carrier, |
| 150 const base::Closure& callback, | 256 const base::Closure& callback, |
| 151 const ErrorCallback& error_callback) OVERRIDE { | 257 const ErrorCallback& error_callback) OVERRIDE { |
| 152 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 258 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 153 flimflam::kActivateCellularModemFunction); | 259 flimflam::kActivateCellularModemFunction); |
| 154 dbus::MessageWriter writer(&method_call); | 260 dbus::MessageWriter writer(&method_call); |
| 155 writer.AppendString(carrier); | 261 writer.AppendString(carrier); |
| 156 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 262 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 157 callback, | 263 &method_call, |
| 158 error_callback); | 264 AttachClosureToClosure(callback, |
| 265 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 266 weak_ptr_factory_.GetWeakPtr(), service_path)), | |
| 267 AttachClosureToErrorCallback(error_callback, | |
| 268 base::Bind(&ShillServiceClientImpl::HelperStatusUpdated, | |
| 269 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
| 159 } | 270 } |
| 160 | 271 |
| 161 virtual bool CallActivateCellularModemAndBlock( | 272 virtual bool CallActivateCellularModemAndBlock( |
| 162 const dbus::ObjectPath& service_path, | 273 const dbus::ObjectPath& service_path, |
| 163 const std::string& carrier) OVERRIDE { | 274 const std::string& carrier) OVERRIDE { |
| 164 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, | 275 dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, |
| 165 flimflam::kActivateCellularModemFunction); | 276 flimflam::kActivateCellularModemFunction); |
| 166 dbus::MessageWriter writer(&method_call); | 277 dbus::MessageWriter writer(&method_call); |
| 167 writer.AppendString(carrier); | 278 writer.AppendString(carrier); |
| 168 return GetHelper(service_path)->CallVoidMethodAndBlock(&method_call); | 279 bool result = GetHelper(service_path)->CallVoidMethodAndBlock(&method_call); |
| 280 HelperStatusUpdated(service_path); | |
| 281 return result; | |
| 169 } | 282 } |
| 170 | 283 |
| 171 virtual ShillServiceClient::TestInterface* GetTestInterface() OVERRIDE { | 284 virtual ShillServiceClient::TestInterface* GetTestInterface() OVERRIDE { |
| 172 return NULL; | 285 return NULL; |
| 173 } | 286 } |
| 174 | 287 |
| 175 private: | 288 private: |
| 176 typedef std::map<std::string, ShillClientHelper*> HelperMap; | 289 typedef std::map<std::string, ShillClientHelper*> HelperMap; |
| 177 | 290 |
| 178 // Returns the corresponding ShillClientHelper for the profile. | 291 // Returns the corresponding ShillClientHelper for the profile. |
| 179 ShillClientHelper* GetHelper(const dbus::ObjectPath& service_path) { | 292 ShillClientHelper* GetHelper(const dbus::ObjectPath& service_path) { |
| 180 HelperMap::iterator it = helpers_.find(service_path.value()); | 293 HelperMap::iterator it = helpers_.find(service_path.value()); |
| 181 if (it != helpers_.end()) | 294 if (it != helpers_.end()) |
| 182 return it->second; | 295 return it->second; |
| 183 | 296 |
| 184 // There is no helper for the profile, create it. | 297 // There is no helper for the profile, create it. |
| 185 dbus::ObjectProxy* object_proxy = | 298 dbus::ObjectProxy* object_proxy = |
| 186 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, service_path); | 299 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, service_path); |
| 187 ShillClientHelper* helper = new ShillClientHelper(bus_, object_proxy); | 300 ShillClientHelper* helper = new ShillClientHelper(bus_, object_proxy); |
| 188 helper->MonitorPropertyChanged(flimflam::kFlimflamServiceInterface); | 301 helper->MonitorPropertyChanged(flimflam::kFlimflamServiceInterface); |
| 189 helpers_.insert(HelperMap::value_type(service_path.value(), helper)); | 302 helpers_.insert(HelperMap::value_type(service_path.value(), helper)); |
| 190 return helper; | 303 return helper; |
| 191 } | 304 } |
| 192 | 305 |
| 306 // This function should be called every time the IsObserved or the | |
| 307 // IsWaitingResponse helper's properties may have changed. If both are | |
| 308 // false, the cached helper can be safely removed and this function removes | |
| 309 // it in such case. | |
|
stevenjb
2013/02/06 01:05:53
nit: s/and this function removes it in such case//
| |
| 310 void HelperStatusUpdated(const dbus::ObjectPath& service_path) { | |
|
hashimoto
2013/02/06 03:29:06
nit: This method should better named MaybeRemoveHe
deymo
2013/02/06 05:44:45
I think the name should be more like "OnHelperStat
hashimoto
2013/02/07 05:20:31
Callback methods are named "OnXXX" when it is hard
| |
| 311 HelperMap::iterator it = helpers_.find(service_path.value()); | |
| 312 if (it == helpers_.end()) | |
| 313 return; | |
| 314 | |
| 315 ShillClientHelper* const helper = it->second; | |
| 316 if (!helper->IsObserved() and !helper->IsWaitingResponse()) { | |
|
hashimoto
2013/02/06 03:29:06
nit: s/and/&&/
deymo
2013/02/06 05:44:45
Very expressive method names + too much time codin
| |
| 317 helpers_.erase(it); | |
| 318 delete helper; | |
| 319 bus_->RemoveObjectProxy(flimflam::kFlimflamServiceName, service_path, | |
| 320 base::Bind(&base::DoNothing)); | |
| 321 } | |
| 322 } | |
| 323 | |
| 193 dbus::Bus* bus_; | 324 dbus::Bus* bus_; |
| 194 HelperMap helpers_; | 325 HelperMap helpers_; |
| 195 STLValueDeleter<HelperMap> helpers_deleter_; | 326 STLValueDeleter<HelperMap> helpers_deleter_; |
| 196 | 327 |
| 328 // Note: This should remain the last member so it'll be destroyed and | |
| 329 // invalidate its weak pointers before any other members are destroyed. | |
| 330 base::WeakPtrFactory<ShillServiceClientImpl> weak_ptr_factory_; | |
| 331 | |
| 197 DISALLOW_COPY_AND_ASSIGN(ShillServiceClientImpl); | 332 DISALLOW_COPY_AND_ASSIGN(ShillServiceClientImpl); |
| 198 }; | 333 }; |
| 199 | 334 |
| 200 // A stub implementation of ShillServiceClient. | 335 // A stub implementation of ShillServiceClient. |
| 201 class ShillServiceClientStubImpl : public ShillServiceClient, | 336 class ShillServiceClientStubImpl : public ShillServiceClient, |
| 202 public ShillServiceClient::TestInterface { | 337 public ShillServiceClient::TestInterface { |
| 203 public: | 338 public: |
| 204 ShillServiceClientStubImpl() : weak_ptr_factory_(this) { | 339 ShillServiceClientStubImpl() : weak_ptr_factory_(this) { |
| 205 SetDefaultProperties(); | 340 SetDefaultProperties(); |
| 206 } | 341 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 ShillServiceClient* ShillServiceClient::Create( | 665 ShillServiceClient* ShillServiceClient::Create( |
| 531 DBusClientImplementationType type, | 666 DBusClientImplementationType type, |
| 532 dbus::Bus* bus) { | 667 dbus::Bus* bus) { |
| 533 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 668 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 534 return new ShillServiceClientImpl(bus); | 669 return new ShillServiceClientImpl(bus); |
| 535 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 670 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 536 return new ShillServiceClientStubImpl(); | 671 return new ShillServiceClientStubImpl(); |
| 537 } | 672 } |
| 538 | 673 |
| 539 } // namespace chromeos | 674 } // namespace chromeos |
| OLD | NEW |