Chromium Code Reviews| Index: ipc/ipc_sync_channel.cc |
| diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc |
| index 0d61e08ce945b01e27fd3005b138c1bfbc5c7eee..842e04e74c6f33038a7415c205af3df1c8c53137 100644 |
| --- a/ipc/ipc_sync_channel.cc |
| +++ b/ipc/ipc_sync_channel.cc |
| @@ -88,9 +88,9 @@ class SyncChannel::ReceivedSyncMsgQueue : |
| outer_state_(sync_msg_queue_->top_send_done_event_watcher_), |
| event_(context->GetSendDoneEvent()), |
| callback_( |
| - base::Bind(&SyncChannel::SyncContext::OnSendDoneEventSignaled, |
| - context, |
| - run_loop)) { |
| + base::BindOnce(&SyncChannel::SyncContext::OnSendDoneEventSignaled, |
| + context, |
| + run_loop)) { |
| sync_msg_queue_->top_send_done_event_watcher_ = this; |
| if (outer_state_) |
| outer_state_->StopWatching(); |
| @@ -104,14 +104,23 @@ class SyncChannel::ReceivedSyncMsgQueue : |
| } |
| private: |
| - void StartWatching() { watcher_.StartWatching(event_, callback_); } |
| + void Run(WaitableEvent* event) { |
| + DCHECK(callback_); |
| + std::move(callback_).Run(event); |
| + } |
| + |
| + void StartWatching() { |
| + watcher_.StartWatching(event_, base::BindOnce(&NestedSendDoneWatcher::Run, |
| + base::Unretained(this))); |
|
dcheng
2017/04/14 21:56:59
Out of curiosity, why do we need this intermediate
tzik
2017/04/17 08:28:34
StartWatching/StopWatching may be called more than
|
| + } |
| + |
| void StopWatching() { watcher_.StopWatching(); } |
| ReceivedSyncMsgQueue* const sync_msg_queue_; |
| NestedSendDoneWatcher* const outer_state_; |
| base::WaitableEvent* const event_; |
| - const base::WaitableEventWatcher::EventCallback callback_; |
| + base::WaitableEventWatcher::EventCallback callback_; |
| base::WaitableEventWatcher watcher_; |
| DISALLOW_COPY_AND_ASSIGN(NestedSendDoneWatcher); |