| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "dbus/object_manager.h" | 5 #include "dbus/object_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 LOG(ERROR) << "Rejecting a message from a wrong sender."; | 282 LOG(ERROR) << "Rejecting a message from a wrong sender."; |
| 283 UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 1); | 283 UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 1); |
| 284 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 284 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 285 } | 285 } |
| 286 | 286 |
| 287 const ObjectPath path = signal->GetPath(); | 287 const ObjectPath path = signal->GetPath(); |
| 288 | 288 |
| 289 if (bus_->HasDBusThread()) { | 289 if (bus_->HasDBusThread()) { |
| 290 // Post a task to run the method in the origin thread. Transfer ownership of | 290 // Post a task to run the method in the origin thread. Transfer ownership of |
| 291 // |signal| to NotifyPropertiesChanged, which will handle the clean up. | 291 // |signal| to NotifyPropertiesChanged, which will handle the clean up. |
| 292 Signal* released_signal = signal.release(); | |
| 293 bus_->GetOriginTaskRunner()->PostTask( | 292 bus_->GetOriginTaskRunner()->PostTask( |
| 294 FROM_HERE, | 293 FROM_HERE, |
| 295 base::Bind(&ObjectManager::NotifyPropertiesChanged, | 294 base::Bind(&ObjectManager::NotifyPropertiesChanged, |
| 296 this, path, | 295 this, path, |
| 297 released_signal)); | 296 base::Passed(&signal))); |
| 298 } else { | 297 } else { |
| 299 // If the D-Bus thread is not used, just call the callback on the | 298 // If the D-Bus thread is not used, just call the callback on the |
| 300 // current thread. Transfer the ownership of |signal| to | 299 // current thread. Transfer the ownership of |signal| to |
| 301 // NotifyPropertiesChanged. | 300 // NotifyPropertiesChanged. |
| 302 NotifyPropertiesChanged(path, signal.release()); | 301 NotifyPropertiesChanged(path, signal.Pass()); |
| 303 } | 302 } |
| 304 | 303 |
| 305 // We don't return DBUS_HANDLER_RESULT_HANDLED for signals because other | 304 // We don't return DBUS_HANDLER_RESULT_HANDLED for signals because other |
| 306 // objects may be interested in them. (e.g. Signals from org.freedesktop.DBus) | 305 // objects may be interested in them. (e.g. Signals from org.freedesktop.DBus) |
| 307 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 306 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 308 } | 307 } |
| 309 | 308 |
| 310 void ObjectManager::NotifyPropertiesChanged( | 309 void ObjectManager::NotifyPropertiesChanged( |
| 311 const dbus::ObjectPath object_path, | 310 const dbus::ObjectPath object_path, |
| 312 Signal* signal) { | 311 scoped_ptr<Signal> signal) { |
| 313 DCHECK(bus_); | 312 DCHECK(bus_); |
| 314 bus_->AssertOnOriginThread(); | 313 bus_->AssertOnOriginThread(); |
| 315 | 314 |
| 316 NotifyPropertiesChangedHelper(object_path, signal); | 315 NotifyPropertiesChangedHelper(object_path, signal.get()); |
| 317 | 316 |
| 318 // Delete the message on the D-Bus thread. See comments in HandleMessage. | 317 // Delete the message on the D-Bus thread. See comments in HandleMessage. |
| 319 bus_->GetDBusTaskRunner()->PostTask( | 318 bus_->GetDBusTaskRunner()->PostTask( |
| 320 FROM_HERE, | 319 FROM_HERE, |
| 321 base::Bind(&base::DeletePointer<Signal>, signal)); | 320 base::Bind(&base::DeletePointer<Signal>, base::Passed(&signal))); |
| 322 } | 321 } |
| 323 | 322 |
| 324 void ObjectManager::NotifyPropertiesChangedHelper( | 323 void ObjectManager::NotifyPropertiesChangedHelper( |
| 325 const dbus::ObjectPath object_path, | 324 const dbus::ObjectPath object_path, |
| 326 Signal* signal) { | 325 Signal* signal) { |
| 327 DCHECK(bus_); | 326 DCHECK(bus_); |
| 328 bus_->AssertOnOriginThread(); | 327 bus_->AssertOnOriginThread(); |
| 329 | 328 |
| 330 MessageReader reader(signal); | 329 MessageReader reader(signal); |
| 331 std::string interface; | 330 std::string interface; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 RemoveInterface(object_path, *iiter); | 517 RemoveInterface(object_path, *iiter); |
| 519 } | 518 } |
| 520 | 519 |
| 521 } | 520 } |
| 522 | 521 |
| 523 if (!new_owner.empty()) | 522 if (!new_owner.empty()) |
| 524 GetManagedObjects(); | 523 GetManagedObjects(); |
| 525 } | 524 } |
| 526 | 525 |
| 527 } // namespace dbus | 526 } // namespace dbus |
| OLD | NEW |