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 "dbus/bus.h" | 5 #include "dbus/bus.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 // It is safe and necessary to call dbus_connection_get_dispatch_status even | 768 // It is safe and necessary to call dbus_connection_get_dispatch_status even |
769 // if the connection is lost. Otherwise we will miss "Disconnected" signal. | 769 // if the connection is lost. Otherwise we will miss "Disconnected" signal. |
770 // (crbug.com/174431) | 770 // (crbug.com/174431) |
771 if (dbus_connection_get_dispatch_status(connection_) == | 771 if (dbus_connection_get_dispatch_status(connection_) == |
772 DBUS_DISPATCH_DATA_REMAINS) { | 772 DBUS_DISPATCH_DATA_REMAINS) { |
773 while (dbus_connection_dispatch(connection_) == | 773 while (dbus_connection_dispatch(connection_) == |
774 DBUS_DISPATCH_DATA_REMAINS); | 774 DBUS_DISPATCH_DATA_REMAINS); |
775 } | 775 } |
776 } | 776 } |
777 | 777 |
| 778 void Bus::PostTaskToDBusThreadAndReply( |
| 779 const tracked_objects::Location& from_here, |
| 780 const base::Closure& task, |
| 781 const base::Closure& reply) { |
| 782 AssertOnOriginThread(); |
| 783 |
| 784 if (dbus_task_runner_.get()) { |
| 785 if (!dbus_task_runner_->PostTaskAndReply(from_here, task, reply)) { |
| 786 LOG(WARNING) << "Failed to post a task to the D-Bus thread message loop"; |
| 787 } |
| 788 } else { |
| 789 DCHECK(origin_task_runner_.get()); |
| 790 if (!origin_task_runner_->PostTaskAndReply(from_here, task, reply)) { |
| 791 LOG(WARNING) << "Failed to post a task to the origin message loop"; |
| 792 } |
| 793 } |
| 794 } |
| 795 |
778 void Bus::PostTaskToOriginThread(const tracked_objects::Location& from_here, | 796 void Bus::PostTaskToOriginThread(const tracked_objects::Location& from_here, |
779 const base::Closure& task) { | 797 const base::Closure& task) { |
780 DCHECK(origin_task_runner_.get()); | 798 DCHECK(origin_task_runner_.get()); |
781 if (!origin_task_runner_->PostTask(from_here, task)) { | 799 if (!origin_task_runner_->PostTask(from_here, task)) { |
782 LOG(WARNING) << "Failed to post a task to the origin message loop"; | 800 LOG(WARNING) << "Failed to post a task to the origin message loop"; |
783 } | 801 } |
784 } | 802 } |
785 | 803 |
786 void Bus::PostTaskToDBusThread(const tracked_objects::Location& from_here, | 804 void Bus::PostTaskToDBusThread(const tracked_objects::Location& from_here, |
787 const base::Closure& task) { | 805 const base::Closure& task) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 kDisconnectedSignal)) { | 1046 kDisconnectedSignal)) { |
1029 Bus* self = static_cast<Bus*>(data); | 1047 Bus* self = static_cast<Bus*>(data); |
1030 self->AssertOnDBusThread(); | 1048 self->AssertOnDBusThread(); |
1031 self->OnConnectionDisconnected(connection); | 1049 self->OnConnectionDisconnected(connection); |
1032 return DBUS_HANDLER_RESULT_HANDLED; | 1050 return DBUS_HANDLER_RESULT_HANDLED; |
1033 } | 1051 } |
1034 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 1052 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
1035 } | 1053 } |
1036 | 1054 |
1037 } // namespace dbus | 1055 } // namespace dbus |
OLD | NEW |