Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1137)

Side by Side Diff: ipc/ipc_sync_message_filter.cc

Issue 8539036: base:Bind: Convert ipc/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_sync_channel_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/location.h" 8 #include "base/location.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
10 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
11 #include "ipc/ipc_sync_message.h" 12 #include "ipc/ipc_sync_message.h"
12 13
13 using base::MessageLoopProxy; 14 using base::MessageLoopProxy;
14 15
15 namespace IPC { 16 namespace IPC {
16 17
(...skipping 10 matching lines...) Expand all
27 { 28 {
28 base::AutoLock auto_lock(lock_); 29 base::AutoLock auto_lock(lock_);
29 if (!io_loop_) { 30 if (!io_loop_) {
30 delete message; 31 delete message;
31 return false; 32 return false;
32 } 33 }
33 } 34 }
34 35
35 if (!message->is_sync()) { 36 if (!message->is_sync()) {
36 io_loop_->PostTask( 37 io_loop_->PostTask(
37 FROM_HERE, 38 FROM_HERE, base::Bind(&SyncMessageFilter::SendOnIOThread, this, message));
38 NewRunnableMethod(this, &SyncMessageFilter::SendOnIOThread, message));
39 return true; 39 return true;
40 } 40 }
41 41
42 base::WaitableEvent done_event(true, false); 42 base::WaitableEvent done_event(true, false);
43 PendingSyncMsg pending_message( 43 PendingSyncMsg pending_message(
44 SyncMessage::GetMessageId(*message), 44 SyncMessage::GetMessageId(*message),
45 reinterpret_cast<SyncMessage*>(message)->GetReplyDeserializer(), 45 reinterpret_cast<SyncMessage*>(message)->GetReplyDeserializer(),
46 &done_event); 46 &done_event);
47 47
48 { 48 {
49 base::AutoLock auto_lock(lock_); 49 base::AutoLock auto_lock(lock_);
50 // Can't use this class on the main thread or else it can lead to deadlocks. 50 // Can't use this class on the main thread or else it can lead to deadlocks.
51 // Also by definition, can't use this on IO thread since we're blocking it. 51 // Also by definition, can't use this on IO thread since we're blocking it.
52 DCHECK(MessageLoopProxy::current() != listener_loop_); 52 DCHECK(MessageLoopProxy::current() != listener_loop_);
53 DCHECK(MessageLoopProxy::current() != io_loop_); 53 DCHECK(MessageLoopProxy::current() != io_loop_);
54 pending_sync_messages_.insert(&pending_message); 54 pending_sync_messages_.insert(&pending_message);
55 } 55 }
56 56
57 io_loop_->PostTask( 57 io_loop_->PostTask(
58 FROM_HERE, 58 FROM_HERE, base::Bind(&SyncMessageFilter::SendOnIOThread, this, message));
59 NewRunnableMethod(this, &SyncMessageFilter::SendOnIOThread, message));
60 59
61 base::WaitableEvent* events[2] = { shutdown_event_, &done_event }; 60 base::WaitableEvent* events[2] = { shutdown_event_, &done_event };
62 base::WaitableEvent::WaitMany(events, 2); 61 base::WaitableEvent::WaitMany(events, 2);
63 62
64 { 63 {
65 base::AutoLock auto_lock(lock_); 64 base::AutoLock auto_lock(lock_);
66 delete pending_message.deserializer; 65 delete pending_message.deserializer;
67 pending_sync_messages_.erase(&pending_message); 66 pending_sync_messages_.erase(&pending_message);
68 } 67 }
69 68
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 119 }
121 (*iter)->done_event->Signal(); 120 (*iter)->done_event->Signal();
122 return true; 121 return true;
123 } 122 }
124 } 123 }
125 124
126 return false; 125 return false;
127 } 126 }
128 127
129 } // namespace IPC 128 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_sync_channel_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698