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

Side by Side Diff: ipc/ipc_sync_message_filter.h

Issue 2077653002: Revert IPC SyncChannel to base::WaitableEvent waiting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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
« no previous file with comments | « ipc/ipc_sync_message.cc ('k') | ipc/ipc_sync_message_filter.cc » ('j') | 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) 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 #ifndef IPC_IPC_SYNC_MESSAGE_FILTER_H_ 5 #ifndef IPC_IPC_SYNC_MESSAGE_FILTER_H_
6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_ 6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/synchronization/waitable_event_watcher.h"
15 #include "ipc/ipc_sender.h" 14 #include "ipc/ipc_sender.h"
16 #include "ipc/ipc_sync_message.h" 15 #include "ipc/ipc_sync_message.h"
17 #include "ipc/message_filter.h" 16 #include "ipc/message_filter.h"
18 #include "ipc/mojo_event.h"
19 17
20 namespace base { 18 namespace base {
21 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
22 class WaitableEvent; 20 class WaitableEvent;
23 } 21 }
24 22
25 namespace IPC { 23 namespace IPC {
26 class SyncChannel; 24 class SyncChannel;
27 25
28 // This MessageFilter allows sending synchronous IPC messages from a thread 26 // This MessageFilter allows sending synchronous IPC messages from a thread
(...skipping 22 matching lines...) Expand all
51 friend class SyncChannel; 49 friend class SyncChannel;
52 50
53 void set_is_channel_send_thread_safe(bool is_channel_send_thread_safe) { 51 void set_is_channel_send_thread_safe(bool is_channel_send_thread_safe) {
54 is_channel_send_thread_safe_ = is_channel_send_thread_safe; 52 is_channel_send_thread_safe_ = is_channel_send_thread_safe;
55 } 53 }
56 54
57 void SendOnIOThread(Message* message); 55 void SendOnIOThread(Message* message);
58 // Signal all the pending sends as done, used in an error condition. 56 // Signal all the pending sends as done, used in an error condition.
59 void SignalAllEvents(); 57 void SignalAllEvents();
60 58
61 void OnShutdownEventSignaled(base::WaitableEvent* event);
62
63 // The channel to which this filter was added. 59 // The channel to which this filter was added.
64 Sender* sender_; 60 Sender* sender_;
65 61
66 // Indicates if |sender_|'s Send method is thread-safe. 62 // Indicates if |sender_|'s Send method is thread-safe.
67 bool is_channel_send_thread_safe_; 63 bool is_channel_send_thread_safe_;
68 64
69 // The process's main thread. 65 // The process's main thread.
70 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; 66 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_;
71 67
72 // The message loop where the Channel lives. 68 // The message loop where the Channel lives.
73 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 69 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
74 70
75 typedef std::set<PendingSyncMsg*> PendingSyncMessages; 71 typedef std::set<PendingSyncMsg*> PendingSyncMessages;
76 PendingSyncMessages pending_sync_messages_; 72 PendingSyncMessages pending_sync_messages_;
77 73
78 // Messages waiting to be delivered after IO initialization. 74 // Messages waiting to be delivered after IO initialization.
79 std::vector<std::unique_ptr<Message>> pending_messages_; 75 ScopedVector<Message> pending_messages_;
80 76
81 // Locks data members above. 77 // Locks data members above.
82 base::Lock lock_; 78 base::Lock lock_;
83 79
84 base::WaitableEvent* const shutdown_event_; 80 base::WaitableEvent* shutdown_event_;
85
86 // Used to asynchronously watch |shutdown_event_| on the IO thread and forward
87 // to |shutdown_mojo_event_| (see below.)
88 base::WaitableEventWatcher shutdown_watcher_;
89
90 // A Mojo event which can be watched for shutdown. Signals are forwarded to
91 // this event asynchronously from |shutdown_event_|.
92 MojoEvent shutdown_mojo_event_;
93 81
94 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); 82 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter);
95 }; 83 };
96 84
97 } // namespace IPC 85 } // namespace IPC
98 86
99 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ 87 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_
OLDNEW
« no previous file with comments | « ipc/ipc_sync_message.cc ('k') | ipc/ipc_sync_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698