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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 AddRef(); // Balanced on Complete(). | 117 AddRef(); // Balanced on Complete(). |
118 } | 118 } |
119 | 119 |
120 // Returns true if the timeout is ready to be monitored. | 120 // Returns true if the timeout is ready to be monitored. |
121 bool IsReadyToBeMonitored() { | 121 bool IsReadyToBeMonitored() { |
122 return dbus_timeout_get_enabled(raw_timeout_); | 122 return dbus_timeout_get_enabled(raw_timeout_); |
123 } | 123 } |
124 | 124 |
125 // Starts monitoring the timeout. | 125 // Starts monitoring the timeout. |
126 void StartMonitoring(Bus* bus) { | 126 void StartMonitoring(Bus* bus) { |
127 bus->PostDelayedTaskToDBusThread(FROM_HERE, | 127 bus->GetDBusTaskRunner()->PostDelayedTask( |
128 base::Bind(&Timeout::HandleTimeout, | 128 FROM_HERE, |
129 this), | 129 base::Bind(&Timeout::HandleTimeout, this), |
130 GetInterval()); | 130 GetInterval()); |
131 monitoring_is_active_ = true; | 131 monitoring_is_active_ = true; |
132 } | 132 } |
133 | 133 |
134 // Stops monitoring the timeout. | 134 // Stops monitoring the timeout. |
135 void StopMonitoring() { | 135 void StopMonitoring() { |
136 // We cannot take back the delayed task we posted in | 136 // We cannot take back the delayed task we posted in |
137 // StartMonitoring(), so we just mark the monitoring is inactive now. | 137 // StartMonitoring(), so we just mark the monitoring is inactive now. |
138 monitoring_is_active_ = false; | 138 monitoring_is_active_ = false; |
139 } | 139 } |
140 | 140 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 int options, | 259 int options, |
260 const base::Closure& callback) { | 260 const base::Closure& callback) { |
261 AssertOnOriginThread(); | 261 AssertOnOriginThread(); |
262 | 262 |
263 // Check if we have the requested object proxy. | 263 // Check if we have the requested object proxy. |
264 const ObjectProxyTable::key_type key(service_name + object_path.value(), | 264 const ObjectProxyTable::key_type key(service_name + object_path.value(), |
265 options); | 265 options); |
266 ObjectProxyTable::iterator iter = object_proxy_table_.find(key); | 266 ObjectProxyTable::iterator iter = object_proxy_table_.find(key); |
267 if (iter != object_proxy_table_.end()) { | 267 if (iter != object_proxy_table_.end()) { |
268 // Object is present. Remove it now and Detach in the DBus thread. | 268 // Object is present. Remove it now and Detach in the DBus thread. |
269 PostTaskToDBusThread(FROM_HERE, base::Bind( | 269 GetDBusTaskRunner()->PostTask( |
270 &Bus::RemoveObjectProxyInternal, | 270 FROM_HERE, |
271 this, iter->second, callback)); | 271 base::Bind(&Bus::RemoveObjectProxyInternal, |
| 272 this, iter->second, callback)); |
272 | 273 |
273 object_proxy_table_.erase(iter); | 274 object_proxy_table_.erase(iter); |
274 return true; | 275 return true; |
275 } | 276 } |
276 return false; | 277 return false; |
277 } | 278 } |
278 | 279 |
279 void Bus::RemoveObjectProxyInternal(scoped_refptr<ObjectProxy> object_proxy, | 280 void Bus::RemoveObjectProxyInternal(scoped_refptr<ObjectProxy> object_proxy, |
280 const base::Closure& callback) { | 281 const base::Closure& callback) { |
281 AssertOnDBusThread(); | 282 AssertOnDBusThread(); |
282 | 283 |
283 object_proxy.get()->Detach(); | 284 object_proxy.get()->Detach(); |
284 | 285 |
285 PostTaskToOriginThread(FROM_HERE, callback); | 286 GetOriginTaskRunner()->PostTask(FROM_HERE, callback); |
286 } | 287 } |
287 | 288 |
288 ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) { | 289 ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) { |
289 AssertOnOriginThread(); | 290 AssertOnOriginThread(); |
290 | 291 |
291 // Check if we already have the requested exported object. | 292 // Check if we already have the requested exported object. |
292 ExportedObjectTable::iterator iter = exported_object_table_.find(object_path); | 293 ExportedObjectTable::iterator iter = exported_object_table_.find(object_path); |
293 if (iter != exported_object_table_.end()) { | 294 if (iter != exported_object_table_.end()) { |
294 return iter->second.get(); | 295 return iter->second.get(); |
295 } | 296 } |
(...skipping 15 matching lines...) Expand all Loading... |
311 return; | 312 return; |
312 | 313 |
313 scoped_refptr<ExportedObject> exported_object = iter->second; | 314 scoped_refptr<ExportedObject> exported_object = iter->second; |
314 exported_object_table_.erase(iter); | 315 exported_object_table_.erase(iter); |
315 | 316 |
316 // Post the task to perform the final unregistration to the D-Bus thread. | 317 // Post the task to perform the final unregistration to the D-Bus thread. |
317 // Since the registration also happens on the D-Bus thread in | 318 // Since the registration also happens on the D-Bus thread in |
318 // TryRegisterObjectPath(), and the task runner we post to is a | 319 // TryRegisterObjectPath(), and the task runner we post to is a |
319 // SequencedTaskRunner, there is a guarantee that this will happen before any | 320 // SequencedTaskRunner, there is a guarantee that this will happen before any |
320 // future registration call. | 321 // future registration call. |
321 PostTaskToDBusThread(FROM_HERE, | 322 GetDBusTaskRunner()->PostTask( |
322 base::Bind(&Bus::UnregisterExportedObjectInternal, | 323 FROM_HERE, |
323 this, exported_object)); | 324 base::Bind(&Bus::UnregisterExportedObjectInternal, |
| 325 this, exported_object)); |
324 } | 326 } |
325 | 327 |
326 void Bus::UnregisterExportedObjectInternal( | 328 void Bus::UnregisterExportedObjectInternal( |
327 scoped_refptr<ExportedObject> exported_object) { | 329 scoped_refptr<ExportedObject> exported_object) { |
328 AssertOnDBusThread(); | 330 AssertOnDBusThread(); |
329 | 331 |
330 exported_object->Unregister(); | 332 exported_object->Unregister(); |
331 } | 333 } |
332 | 334 |
333 ObjectManager* Bus::GetObjectManager(const std::string& service_name, | 335 ObjectManager* Bus::GetObjectManager(const std::string& service_name, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 480 } |
479 | 481 |
480 connection_ = NULL; | 482 connection_ = NULL; |
481 shutdown_completed_ = true; | 483 shutdown_completed_ = true; |
482 } | 484 } |
483 | 485 |
484 void Bus::ShutdownOnDBusThreadAndBlock() { | 486 void Bus::ShutdownOnDBusThreadAndBlock() { |
485 AssertOnOriginThread(); | 487 AssertOnOriginThread(); |
486 DCHECK(dbus_task_runner_.get()); | 488 DCHECK(dbus_task_runner_.get()); |
487 | 489 |
488 PostTaskToDBusThread(FROM_HERE, base::Bind( | 490 GetDBusTaskRunner()->PostTask( |
489 &Bus::ShutdownOnDBusThreadAndBlockInternal, | 491 FROM_HERE, |
490 this)); | 492 base::Bind(&Bus::ShutdownOnDBusThreadAndBlockInternal, this)); |
491 | 493 |
492 // http://crbug.com/125222 | 494 // http://crbug.com/125222 |
493 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 495 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
494 | 496 |
495 // Wait until the shutdown is complete on the D-Bus thread. | 497 // Wait until the shutdown is complete on the D-Bus thread. |
496 // The shutdown should not hang, but set timeout just in case. | 498 // The shutdown should not hang, but set timeout just in case. |
497 const int kTimeoutSecs = 3; | 499 const int kTimeoutSecs = 3; |
498 const base::TimeDelta timeout(base::TimeDelta::FromSeconds(kTimeoutSecs)); | 500 const base::TimeDelta timeout(base::TimeDelta::FromSeconds(kTimeoutSecs)); |
499 const bool signaled = on_shutdown_.TimedWait(timeout); | 501 const bool signaled = on_shutdown_.TimedWait(timeout); |
500 LOG_IF(ERROR, !signaled) << "Failed to shutdown the bus"; | 502 LOG_IF(ERROR, !signaled) << "Failed to shutdown the bus"; |
501 } | 503 } |
502 | 504 |
503 void Bus::RequestOwnership(const std::string& service_name, | 505 void Bus::RequestOwnership(const std::string& service_name, |
504 ServiceOwnershipOptions options, | 506 ServiceOwnershipOptions options, |
505 OnOwnershipCallback on_ownership_callback) { | 507 OnOwnershipCallback on_ownership_callback) { |
506 AssertOnOriginThread(); | 508 AssertOnOriginThread(); |
507 | 509 |
508 PostTaskToDBusThread(FROM_HERE, base::Bind( | 510 GetDBusTaskRunner()->PostTask( |
509 &Bus::RequestOwnershipInternal, | 511 FROM_HERE, |
510 this, service_name, options, on_ownership_callback)); | 512 base::Bind(&Bus::RequestOwnershipInternal, |
| 513 this, service_name, options, on_ownership_callback)); |
511 } | 514 } |
512 | 515 |
513 void Bus::RequestOwnershipInternal(const std::string& service_name, | 516 void Bus::RequestOwnershipInternal(const std::string& service_name, |
514 ServiceOwnershipOptions options, | 517 ServiceOwnershipOptions options, |
515 OnOwnershipCallback on_ownership_callback) { | 518 OnOwnershipCallback on_ownership_callback) { |
516 AssertOnDBusThread(); | 519 AssertOnDBusThread(); |
517 | 520 |
518 bool success = Connect(); | 521 bool success = Connect(); |
519 if (success) | 522 if (success) |
520 success = RequestOwnershipAndBlock(service_name, options); | 523 success = RequestOwnershipAndBlock(service_name, options); |
521 | 524 |
522 PostTaskToOriginThread(FROM_HERE, | 525 GetOriginTaskRunner()->PostTask(FROM_HERE, |
523 base::Bind(on_ownership_callback, | 526 base::Bind(on_ownership_callback, |
524 service_name, | 527 service_name, |
525 success)); | 528 success)); |
526 } | 529 } |
527 | 530 |
528 bool Bus::RequestOwnershipAndBlock(const std::string& service_name, | 531 bool Bus::RequestOwnershipAndBlock(const std::string& service_name, |
529 ServiceOwnershipOptions options) { | 532 ServiceOwnershipOptions options) { |
530 DCHECK(connection_); | 533 DCHECK(connection_); |
531 // dbus_bus_request_name() is a blocking call. | 534 // dbus_bus_request_name() is a blocking call. |
532 AssertOnDBusThread(); | 535 AssertOnDBusThread(); |
533 | 536 |
534 // Check if we already own the service name. | 537 // Check if we already own the service name. |
535 if (owned_service_names_.find(service_name) != owned_service_names_.end()) { | 538 if (owned_service_names_.find(service_name) != owned_service_names_.end()) { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 // if the connection is lost. Otherwise we will miss "Disconnected" signal. | 786 // if the connection is lost. Otherwise we will miss "Disconnected" signal. |
784 // (crbug.com/174431) | 787 // (crbug.com/174431) |
785 if (dbus_connection_get_dispatch_status(connection_) == | 788 if (dbus_connection_get_dispatch_status(connection_) == |
786 DBUS_DISPATCH_DATA_REMAINS) { | 789 DBUS_DISPATCH_DATA_REMAINS) { |
787 while (dbus_connection_dispatch(connection_) == | 790 while (dbus_connection_dispatch(connection_) == |
788 DBUS_DISPATCH_DATA_REMAINS) { | 791 DBUS_DISPATCH_DATA_REMAINS) { |
789 } | 792 } |
790 } | 793 } |
791 } | 794 } |
792 | 795 |
793 void Bus::PostTaskToDBusThreadAndReply( | 796 base::TaskRunner* Bus::GetDBusTaskRunner() { |
794 const tracked_objects::Location& from_here, | 797 if (dbus_task_runner_.get()) |
795 const base::Closure& task, | 798 return dbus_task_runner_.get(); |
796 const base::Closure& reply) { | 799 else |
797 AssertOnOriginThread(); | 800 return GetOriginTaskRunner(); |
798 | |
799 if (dbus_task_runner_.get()) { | |
800 if (!dbus_task_runner_->PostTaskAndReply(from_here, task, reply)) { | |
801 LOG(WARNING) << "Failed to post a task to the D-Bus thread message loop"; | |
802 } | |
803 } else { | |
804 DCHECK(origin_task_runner_.get()); | |
805 if (!origin_task_runner_->PostTaskAndReply(from_here, task, reply)) { | |
806 LOG(WARNING) << "Failed to post a task to the origin message loop"; | |
807 } | |
808 } | |
809 } | 801 } |
810 | 802 |
811 void Bus::PostTaskToOriginThread(const tracked_objects::Location& from_here, | 803 base::TaskRunner* Bus::GetOriginTaskRunner() { |
812 const base::Closure& task) { | |
813 DCHECK(origin_task_runner_.get()); | 804 DCHECK(origin_task_runner_.get()); |
814 if (!origin_task_runner_->PostTask(from_here, task)) { | 805 return origin_task_runner_.get(); |
815 LOG(WARNING) << "Failed to post a task to the origin message loop"; | |
816 } | |
817 } | |
818 | |
819 void Bus::PostTaskToDBusThread(const tracked_objects::Location& from_here, | |
820 const base::Closure& task) { | |
821 if (dbus_task_runner_.get()) { | |
822 if (!dbus_task_runner_->PostTask(from_here, task)) { | |
823 LOG(WARNING) << "Failed to post a task to the D-Bus thread message loop"; | |
824 } | |
825 } else { | |
826 DCHECK(origin_task_runner_.get()); | |
827 if (!origin_task_runner_->PostTask(from_here, task)) { | |
828 LOG(WARNING) << "Failed to post a task to the origin message loop"; | |
829 } | |
830 } | |
831 } | |
832 | |
833 void Bus::PostDelayedTaskToDBusThread( | |
834 const tracked_objects::Location& from_here, | |
835 const base::Closure& task, | |
836 base::TimeDelta delay) { | |
837 if (dbus_task_runner_.get()) { | |
838 if (!dbus_task_runner_->PostDelayedTask( | |
839 from_here, task, delay)) { | |
840 LOG(WARNING) << "Failed to post a task to the D-Bus thread message loop"; | |
841 } | |
842 } else { | |
843 DCHECK(origin_task_runner_.get()); | |
844 if (!origin_task_runner_->PostDelayedTask(from_here, task, delay)) { | |
845 LOG(WARNING) << "Failed to post a task to the origin message loop"; | |
846 } | |
847 } | |
848 } | 806 } |
849 | 807 |
850 bool Bus::HasDBusThread() { | 808 bool Bus::HasDBusThread() { |
851 return dbus_task_runner_.get() != NULL; | 809 return dbus_task_runner_.get() != NULL; |
852 } | 810 } |
853 | 811 |
854 void Bus::AssertOnOriginThread() { | 812 void Bus::AssertOnOriginThread() { |
855 DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId()); | 813 DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId()); |
856 } | 814 } |
857 | 815 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 std::string service_owner; | 859 std::string service_owner; |
902 if (!reader.PopString(&service_owner)) | 860 if (!reader.PopString(&service_owner)) |
903 service_owner.clear(); | 861 service_owner.clear(); |
904 return service_owner; | 862 return service_owner; |
905 } | 863 } |
906 | 864 |
907 void Bus::GetServiceOwner(const std::string& service_name, | 865 void Bus::GetServiceOwner(const std::string& service_name, |
908 const GetServiceOwnerCallback& callback) { | 866 const GetServiceOwnerCallback& callback) { |
909 AssertOnOriginThread(); | 867 AssertOnOriginThread(); |
910 | 868 |
911 PostTaskToDBusThread( | 869 GetDBusTaskRunner()->PostTask( |
912 FROM_HERE, | 870 FROM_HERE, |
913 base::Bind(&Bus::GetServiceOwnerInternal, this, service_name, callback)); | 871 base::Bind(&Bus::GetServiceOwnerInternal, this, service_name, callback)); |
914 } | 872 } |
915 | 873 |
916 void Bus::GetServiceOwnerInternal(const std::string& service_name, | 874 void Bus::GetServiceOwnerInternal(const std::string& service_name, |
917 const GetServiceOwnerCallback& callback) { | 875 const GetServiceOwnerCallback& callback) { |
918 AssertOnDBusThread(); | 876 AssertOnDBusThread(); |
919 | 877 |
920 std::string service_owner; | 878 std::string service_owner; |
921 if (Connect()) | 879 if (Connect()) |
922 service_owner = GetServiceOwnerAndBlock(service_name, SUPPRESS_ERRORS); | 880 service_owner = GetServiceOwnerAndBlock(service_name, SUPPRESS_ERRORS); |
923 PostTaskToOriginThread(FROM_HERE, base::Bind(callback, service_owner)); | 881 GetOriginTaskRunner()->PostTask(FROM_HERE, |
| 882 base::Bind(callback, service_owner)); |
924 } | 883 } |
925 | 884 |
926 void Bus::ListenForServiceOwnerChange( | 885 void Bus::ListenForServiceOwnerChange( |
927 const std::string& service_name, | 886 const std::string& service_name, |
928 const GetServiceOwnerCallback& callback) { | 887 const GetServiceOwnerCallback& callback) { |
929 AssertOnOriginThread(); | 888 AssertOnOriginThread(); |
930 DCHECK(!service_name.empty()); | 889 DCHECK(!service_name.empty()); |
931 DCHECK(!callback.is_null()); | 890 DCHECK(!callback.is_null()); |
932 | 891 |
933 PostTaskToDBusThread(FROM_HERE, | 892 GetDBusTaskRunner()->PostTask( |
934 base::Bind(&Bus::ListenForServiceOwnerChangeInternal, | 893 FROM_HERE, |
935 this, service_name, callback)); | 894 base::Bind(&Bus::ListenForServiceOwnerChangeInternal, |
| 895 this, service_name, callback)); |
936 } | 896 } |
937 | 897 |
938 void Bus::ListenForServiceOwnerChangeInternal( | 898 void Bus::ListenForServiceOwnerChangeInternal( |
939 const std::string& service_name, | 899 const std::string& service_name, |
940 const GetServiceOwnerCallback& callback) { | 900 const GetServiceOwnerCallback& callback) { |
941 AssertOnDBusThread(); | 901 AssertOnDBusThread(); |
942 DCHECK(!service_name.empty()); | 902 DCHECK(!service_name.empty()); |
943 DCHECK(!callback.is_null()); | 903 DCHECK(!callback.is_null()); |
944 | 904 |
945 if (!Connect() || !SetUpAsyncOperations()) | 905 if (!Connect() || !SetUpAsyncOperations()) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 callbacks.push_back(callback); | 939 callbacks.push_back(callback); |
980 } | 940 } |
981 | 941 |
982 void Bus::UnlistenForServiceOwnerChange( | 942 void Bus::UnlistenForServiceOwnerChange( |
983 const std::string& service_name, | 943 const std::string& service_name, |
984 const GetServiceOwnerCallback& callback) { | 944 const GetServiceOwnerCallback& callback) { |
985 AssertOnOriginThread(); | 945 AssertOnOriginThread(); |
986 DCHECK(!service_name.empty()); | 946 DCHECK(!service_name.empty()); |
987 DCHECK(!callback.is_null()); | 947 DCHECK(!callback.is_null()); |
988 | 948 |
989 PostTaskToDBusThread(FROM_HERE, | 949 GetDBusTaskRunner()->PostTask( |
990 base::Bind(&Bus::UnlistenForServiceOwnerChangeInternal, | 950 FROM_HERE, |
991 this, service_name, callback)); | 951 base::Bind(&Bus::UnlistenForServiceOwnerChangeInternal, |
| 952 this, service_name, callback)); |
992 } | 953 } |
993 | 954 |
994 void Bus::UnlistenForServiceOwnerChangeInternal( | 955 void Bus::UnlistenForServiceOwnerChangeInternal( |
995 const std::string& service_name, | 956 const std::string& service_name, |
996 const GetServiceOwnerCallback& callback) { | 957 const GetServiceOwnerCallback& callback) { |
997 AssertOnDBusThread(); | 958 AssertOnDBusThread(); |
998 DCHECK(!service_name.empty()); | 959 DCHECK(!service_name.empty()); |
999 DCHECK(!callback.is_null()); | 960 DCHECK(!callback.is_null()); |
1000 | 961 |
1001 ServiceOwnerChangedListenerMap::iterator it = | 962 ServiceOwnerChangedListenerMap::iterator it = |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 | 1057 |
1097 void Bus::OnDispatchStatusChanged(DBusConnection* connection, | 1058 void Bus::OnDispatchStatusChanged(DBusConnection* connection, |
1098 DBusDispatchStatus status) { | 1059 DBusDispatchStatus status) { |
1099 DCHECK_EQ(connection, connection_); | 1060 DCHECK_EQ(connection, connection_); |
1100 AssertOnDBusThread(); | 1061 AssertOnDBusThread(); |
1101 | 1062 |
1102 // We cannot call ProcessAllIncomingDataIfAny() here, as calling | 1063 // We cannot call ProcessAllIncomingDataIfAny() here, as calling |
1103 // dbus_connection_dispatch() inside DBusDispatchStatusFunction is | 1064 // dbus_connection_dispatch() inside DBusDispatchStatusFunction is |
1104 // prohibited by the D-Bus library. Hence, we post a task here instead. | 1065 // prohibited by the D-Bus library. Hence, we post a task here instead. |
1105 // See comments for dbus_connection_set_dispatch_status_function(). | 1066 // See comments for dbus_connection_set_dispatch_status_function(). |
1106 PostTaskToDBusThread(FROM_HERE, | 1067 GetDBusTaskRunner()->PostTask(FROM_HERE, |
1107 base::Bind(&Bus::ProcessAllIncomingDataIfAny, | 1068 base::Bind(&Bus::ProcessAllIncomingDataIfAny, |
1108 this)); | 1069 this)); |
1109 } | 1070 } |
1110 | 1071 |
1111 void Bus::OnConnectionDisconnected(DBusConnection* connection) { | 1072 void Bus::OnConnectionDisconnected(DBusConnection* connection) { |
1112 AssertOnDBusThread(); | 1073 AssertOnDBusThread(); |
1113 | 1074 |
1114 if (!on_disconnected_closure_.is_null()) | 1075 if (!on_disconnected_closure_.is_null()) |
1115 PostTaskToOriginThread(FROM_HERE, on_disconnected_closure_); | 1076 GetOriginTaskRunner()->PostTask(FROM_HERE, on_disconnected_closure_); |
1116 | 1077 |
1117 if (!connection) | 1078 if (!connection) |
1118 return; | 1079 return; |
1119 DCHECK(!dbus_connection_get_is_connected(connection)); | 1080 DCHECK(!dbus_connection_get_is_connected(connection)); |
1120 | 1081 |
1121 ShutdownAndBlock(); | 1082 ShutdownAndBlock(); |
1122 } | 1083 } |
1123 | 1084 |
1124 void Bus::OnServiceOwnerChanged(DBusMessage* message) { | 1085 void Bus::OnServiceOwnerChanged(DBusMessage* message) { |
1125 DCHECK(message); | 1086 DCHECK(message); |
(...skipping 21 matching lines...) Expand all Loading... |
1147 return; | 1108 return; |
1148 } | 1109 } |
1149 | 1110 |
1150 ServiceOwnerChangedListenerMap::const_iterator it = | 1111 ServiceOwnerChangedListenerMap::const_iterator it = |
1151 service_owner_changed_listener_map_.find(service_name); | 1112 service_owner_changed_listener_map_.find(service_name); |
1152 if (it == service_owner_changed_listener_map_.end()) | 1113 if (it == service_owner_changed_listener_map_.end()) |
1153 return; | 1114 return; |
1154 | 1115 |
1155 const std::vector<GetServiceOwnerCallback>& callbacks = it->second; | 1116 const std::vector<GetServiceOwnerCallback>& callbacks = it->second; |
1156 for (size_t i = 0; i < callbacks.size(); ++i) { | 1117 for (size_t i = 0; i < callbacks.size(); ++i) { |
1157 PostTaskToOriginThread(FROM_HERE, | 1118 GetOriginTaskRunner()->PostTask(FROM_HERE, |
1158 base::Bind(callbacks[i], new_owner)); | 1119 base::Bind(callbacks[i], new_owner)); |
1159 } | 1120 } |
1160 } | 1121 } |
1161 | 1122 |
1162 // static | 1123 // static |
1163 dbus_bool_t Bus::OnAddWatchThunk(DBusWatch* raw_watch, void* data) { | 1124 dbus_bool_t Bus::OnAddWatchThunk(DBusWatch* raw_watch, void* data) { |
1164 Bus* self = static_cast<Bus*>(data); | 1125 Bus* self = static_cast<Bus*>(data); |
1165 return self->OnAddWatch(raw_watch); | 1126 return self->OnAddWatch(raw_watch); |
1166 } | 1127 } |
1167 | 1128 |
1168 // static | 1129 // static |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 kNameOwnerChangedSignal)) { | 1189 kNameOwnerChangedSignal)) { |
1229 Bus* self = static_cast<Bus*>(data); | 1190 Bus* self = static_cast<Bus*>(data); |
1230 self->OnServiceOwnerChanged(message); | 1191 self->OnServiceOwnerChanged(message); |
1231 } | 1192 } |
1232 // Always return unhandled to let others, e.g. ObjectProxies, handle the same | 1193 // Always return unhandled to let others, e.g. ObjectProxies, handle the same |
1233 // signal. | 1194 // signal. |
1234 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 1195 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
1235 } | 1196 } |
1236 | 1197 |
1237 } // namespace dbus | 1198 } // namespace dbus |
OLD | NEW |