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

Side by Side Diff: ipc/ipc_sync_message_filter.h

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

Powered by Google App Engine
This is Rietveld 408576698