| 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_message_filter.h" | 5 #include "ipc/ipc_sync_message_filter.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/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 pending_messages_.push_back(message); | 23 pending_messages_.push_back(message); |
| 24 return true; | 24 return true; |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 io_task_runner_->PostTask( | 27 io_task_runner_->PostTask( |
| 28 FROM_HERE, | 28 FROM_HERE, |
| 29 base::Bind(&SyncMessageFilter::SendOnIOThread, this, message)); | 29 base::Bind(&SyncMessageFilter::SendOnIOThread, this, message)); |
| 30 return true; | 30 return true; |
| 31 } | 31 } |
| 32 | 32 |
| 33 base::WaitableEvent done_event(true, false); | 33 base::WaitableEvent done_event( |
| 34 base::WaitableEvent::ResetPolicy::MANUAL, |
| 35 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 34 PendingSyncMsg pending_message( | 36 PendingSyncMsg pending_message( |
| 35 SyncMessage::GetMessageId(*message), | 37 SyncMessage::GetMessageId(*message), |
| 36 static_cast<SyncMessage*>(message)->GetReplyDeserializer(), | 38 static_cast<SyncMessage*>(message)->GetReplyDeserializer(), |
| 37 &done_event); | 39 &done_event); |
| 38 | 40 |
| 39 { | 41 { |
| 40 base::AutoLock auto_lock(lock_); | 42 base::AutoLock auto_lock(lock_); |
| 41 // Can't use this class on the main thread or else it can lead to deadlocks. | 43 // Can't use this class on the main thread or else it can lead to deadlocks. |
| 42 // Also by definition, can't use this on IO thread since we're blocking it. | 44 // Also by definition, can't use this on IO thread since we're blocking it. |
| 43 if (base::ThreadTaskRunnerHandle::IsSet()) { | 45 if (base::ThreadTaskRunnerHandle::IsSet()) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 for (PendingSyncMessages::iterator iter = pending_sync_messages_.begin(); | 161 for (PendingSyncMessages::iterator iter = pending_sync_messages_.begin(); |
| 160 iter != pending_sync_messages_.end(); ++iter) { | 162 iter != pending_sync_messages_.end(); ++iter) { |
| 161 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"), | 163 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"), |
| 162 "SyncMessageFilter::SignalAllEvents", | 164 "SyncMessageFilter::SignalAllEvents", |
| 163 (*iter)->done_event); | 165 (*iter)->done_event); |
| 164 (*iter)->done_event->Signal(); | 166 (*iter)->done_event->Signal(); |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace IPC | 170 } // namespace IPC |
| OLD | NEW |