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

Side by Side Diff: dbus/bus.cc

Issue 12022004: D-Bus: ObjectProxy remove function for Bus object. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Calls made from the right thread. Created 7 years, 11 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
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 // TODO(satorux): 5 // TODO(satorux):
6 // - Handle "disconnected" signal. 6 // - Handle "disconnected" signal.
7 7
8 #include "dbus/bus.h" 8 #include "dbus/bus.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return iter->second; 228 return iter->second;
229 } 229 }
230 230
231 scoped_refptr<ObjectProxy> object_proxy = 231 scoped_refptr<ObjectProxy> object_proxy =
232 new ObjectProxy(this, service_name, object_path, options); 232 new ObjectProxy(this, service_name, object_path, options);
233 object_proxy_table_[key] = object_proxy; 233 object_proxy_table_[key] = object_proxy;
234 234
235 return object_proxy.get(); 235 return object_proxy.get();
236 } 236 }
237 237
238 bool Bus::RemoveObjectProxy(const std::string& service_name,
239 const ObjectPath& object_path,
240 OnRemoveObjectProxyCallback callback) {
241 return RemoveObjectProxyWithOptions(service_name, object_path,
242 ObjectProxy::DEFAULT_OPTIONS,
243 callback);
244 }
245
246 bool Bus::RemoveObjectProxyWithOptions(const std::string& service_name,
247 const dbus::ObjectPath& object_path,
248 int options,
249 OnRemoveObjectProxyCallback callback) {
250 bool result;
251 AssertOnOriginThread();
252
253 // Check if we have the requested object proxy.
254 const ObjectProxyTable::key_type key(service_name + object_path.value(),
255 options);
256 ObjectProxyTable::iterator iter = object_proxy_table_.find(key);
257 if (iter != object_proxy_table_.end()) {
258 // Object is present. Remove it now and Detach in the DBus thread.
259 result = true;
260 PostTaskToDBusThread(FROM_HERE, base::Bind(
261 &Bus::RemoveObjectProxyInternal,
262 this, iter->second, service_name, object_path, options, callback));
263
264 object_proxy_table_.erase(iter);
265 } else {
Haruki Sato 2013/01/23 09:34:05 maybe returns in this if clause make it simpler? e
deymo 2013/01/23 19:23:46 Done.
266 result = false;
267 }
268 return result;
269 }
270
271 void Bus::RemoveObjectProxyInternal(
272 scoped_refptr<dbus::ObjectProxy> object_proxy,
273 const std::string& service_name,
274 const dbus::ObjectPath& object_path,
275 int options,
276 OnRemoveObjectProxyCallback callback) {
277 AssertOnDBusThread();
278
279 object_proxy.get()->Detach();
280
281 PostTaskToOriginThread(FROM_HERE,
282 base::Bind(&Bus::OnRemoveObjectProxy,
283 this,
284 callback,
285 service_name,
286 object_path,
287 options));
288 }
289
290 void Bus::OnRemoveObjectProxy(OnRemoveObjectProxyCallback callback,
291 const std::string& service_name,
292 const dbus::ObjectPath& object_path,
293 int options) {
294 AssertOnOriginThread();
295
296 callback.Run(service_name, object_path, options);
297 }
298
238 ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) { 299 ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) {
239 AssertOnOriginThread(); 300 AssertOnOriginThread();
240 301
241 // Check if we already have the requested exported object. 302 // Check if we already have the requested exported object.
242 ExportedObjectTable::iterator iter = exported_object_table_.find(object_path); 303 ExportedObjectTable::iterator iter = exported_object_table_.find(object_path);
243 if (iter != exported_object_table_.end()) { 304 if (iter != exported_object_table_.end()) {
244 return iter->second; 305 return iter->second;
245 } 306 }
246 307
247 scoped_refptr<ExportedObject> exported_object = 308 scoped_refptr<ExportedObject> exported_object =
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 904 }
844 905
845 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, 906 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection,
846 DBusDispatchStatus status, 907 DBusDispatchStatus status,
847 void* data) { 908 void* data) {
848 Bus* self = static_cast<Bus*>(data); 909 Bus* self = static_cast<Bus*>(data);
849 self->OnDispatchStatusChanged(connection, status); 910 self->OnDispatchStatusChanged(connection, status);
850 } 911 }
851 912
852 } // namespace dbus 913 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | dbus/bus_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698