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 // 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 361 } |
362 | 362 |
363 void Bus::ShutdownOnDBusThreadAndBlock() { | 363 void Bus::ShutdownOnDBusThreadAndBlock() { |
364 AssertOnOriginThread(); | 364 AssertOnOriginThread(); |
365 DCHECK(dbus_thread_message_loop_proxy_.get()); | 365 DCHECK(dbus_thread_message_loop_proxy_.get()); |
366 | 366 |
367 PostTaskToDBusThread(FROM_HERE, base::Bind( | 367 PostTaskToDBusThread(FROM_HERE, base::Bind( |
368 &Bus::ShutdownOnDBusThreadAndBlockInternal, | 368 &Bus::ShutdownOnDBusThreadAndBlockInternal, |
369 this)); | 369 this)); |
370 | 370 |
| 371 // http://crbug.com/125222 |
| 372 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 373 |
371 // Wait until the shutdown is complete on the D-Bus thread. | 374 // Wait until the shutdown is complete on the D-Bus thread. |
372 // The shutdown should not hang, but set timeout just in case. | 375 // The shutdown should not hang, but set timeout just in case. |
373 const int kTimeoutSecs = 3; | 376 const int kTimeoutSecs = 3; |
374 const base::TimeDelta timeout(base::TimeDelta::FromSeconds(kTimeoutSecs)); | 377 const base::TimeDelta timeout(base::TimeDelta::FromSeconds(kTimeoutSecs)); |
375 const bool signaled = on_shutdown_.TimedWait(timeout); | 378 const bool signaled = on_shutdown_.TimedWait(timeout); |
376 LOG_IF(ERROR, !signaled) << "Failed to shutdown the bus"; | 379 LOG_IF(ERROR, !signaled) << "Failed to shutdown the bus"; |
377 } | 380 } |
378 | 381 |
379 void Bus::RequestOwnership(const std::string& service_name, | 382 void Bus::RequestOwnership(const std::string& service_name, |
380 OnOwnershipCallback on_ownership_callback) { | 383 OnOwnershipCallback on_ownership_callback) { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 } | 830 } |
828 | 831 |
829 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, | 832 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, |
830 DBusDispatchStatus status, | 833 DBusDispatchStatus status, |
831 void* data) { | 834 void* data) { |
832 Bus* self = static_cast<Bus*>(data); | 835 Bus* self = static_cast<Bus*>(data); |
833 return self->OnDispatchStatusChanged(connection, status); | 836 return self->OnDispatchStatusChanged(connection, status); |
834 } | 837 } |
835 | 838 |
836 } // namespace dbus | 839 } // namespace dbus |
OLD | NEW |