| 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 "ipc/ipc_sync_channel.h" | 5 #include "ipc/ipc_sync_channel.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/synchronization/waitable_event_watcher.h" | 12 #include "base/synchronization/waitable_event_watcher.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/threading/thread_local.h" | 14 #include "base/threading/thread_local.h" |
| 15 #include "ipc/ipc_sync_message.h" | 15 #include "ipc/ipc_sync_message.h" |
| 16 | 16 |
| 17 #include <csignal> |
| 18 using std::raise; |
| 17 using base::TimeDelta; | 19 using base::TimeDelta; |
| 18 using base::TimeTicks; | 20 using base::TimeTicks; |
| 19 using base::WaitableEvent; | 21 using base::WaitableEvent; |
| 20 | 22 |
| 21 namespace IPC { | 23 namespace IPC { |
| 22 // When we're blocked in a Send(), we need to process incoming synchronous | 24 // When we're blocked in a Send(), we need to process incoming synchronous |
| 23 // messages right away because it could be blocking our reply (either | 25 // messages right away because it could be blocking our reply (either |
| 24 // directly from the same object we're calling, or indirectly through one or | 26 // directly from the same object we're calling, or indirectly through one or |
| 25 // more other channels). That means that in SyncContext's OnMessageReceived, | 27 // more other channels). That means that in SyncContext's OnMessageReceived, |
| 26 // we need to process sync message right away if we're blocked. However a | 28 // we need to process sync message right away if we're blocked. However a |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 // Ideally we only want to watch this object when running a nested message | 544 // Ideally we only want to watch this object when running a nested message |
| 543 // loop. However, we don't know when it exits if there's another nested | 545 // loop. However, we don't know when it exits if there's another nested |
| 544 // message loop running under it or not, so we wouldn't know whether to | 546 // message loop running under it or not, so we wouldn't know whether to |
| 545 // stop or keep watching. So we always watch it, and create the event as | 547 // stop or keep watching. So we always watch it, and create the event as |
| 546 // manual reset since the object watcher might otherwise reset the event | 548 // manual reset since the object watcher might otherwise reset the event |
| 547 // when we're doing a WaitMany. | 549 // when we're doing a WaitMany. |
| 548 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); | 550 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); |
| 549 } | 551 } |
| 550 | 552 |
| 551 } // namespace IPC | 553 } // namespace IPC |
| OLD | NEW |