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 #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 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // This MessageFilter allows sending synchronous IPC messages from a thread | 24 // This MessageFilter allows sending synchronous IPC messages from a thread |
25 // other than the listener thread associated with the SyncChannel. It does not | 25 // other than the listener thread associated with the SyncChannel. It does not |
26 // support fancy features that SyncChannel does, such as handling recursion or | 26 // support fancy features that SyncChannel does, such as handling recursion or |
27 // receiving messages while waiting for a response. Note that this object can | 27 // receiving messages while waiting for a response. Note that this object can |
28 // be used to send simultaneous synchronous messages from different threads. | 28 // be used to send simultaneous synchronous messages from different threads. |
29 class IPC_EXPORT SyncMessageFilter : public MessageFilter, public Sender { | 29 class IPC_EXPORT SyncMessageFilter : public MessageFilter, public Sender { |
30 public: | 30 public: |
31 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); | 31 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); |
32 | 32 |
33 // MessageSender implementation. | 33 // MessageSender implementation. |
34 bool Send(Message* message) override; | 34 virtual bool Send(Message* message) override; |
35 | 35 |
36 // MessageFilter implementation. | 36 // MessageFilter implementation. |
37 void OnFilterAdded(Sender* sender) override; | 37 virtual void OnFilterAdded(Sender* sender) override; |
38 void OnChannelError() override; | 38 virtual void OnChannelError() override; |
39 void OnChannelClosing() override; | 39 virtual void OnChannelClosing() override; |
40 bool OnMessageReceived(const Message& message) override; | 40 virtual bool OnMessageReceived(const Message& message) override; |
41 | 41 |
42 protected: | 42 protected: |
43 ~SyncMessageFilter() override; | 43 virtual ~SyncMessageFilter(); |
44 | 44 |
45 private: | 45 private: |
46 void SendOnIOThread(Message* message); | 46 void SendOnIOThread(Message* message); |
47 // Signal all the pending sends as done, used in an error condition. | 47 // Signal all the pending sends as done, used in an error condition. |
48 void SignalAllEvents(); | 48 void SignalAllEvents(); |
49 | 49 |
50 // The channel to which this filter was added. | 50 // The channel to which this filter was added. |
51 Sender* sender_; | 51 Sender* sender_; |
52 | 52 |
53 // The process's main thread. | 53 // The process's main thread. |
54 scoped_refptr<base::MessageLoopProxy> listener_loop_; | 54 scoped_refptr<base::MessageLoopProxy> listener_loop_; |
55 | 55 |
56 // The message loop where the Channel lives. | 56 // The message loop where the Channel lives. |
57 scoped_refptr<base::MessageLoopProxy> io_loop_; | 57 scoped_refptr<base::MessageLoopProxy> io_loop_; |
58 | 58 |
59 typedef std::set<PendingSyncMsg*> PendingSyncMessages; | 59 typedef std::set<PendingSyncMsg*> PendingSyncMessages; |
60 PendingSyncMessages pending_sync_messages_; | 60 PendingSyncMessages pending_sync_messages_; |
61 | 61 |
62 // Locks data members above. | 62 // Locks data members above. |
63 base::Lock lock_; | 63 base::Lock lock_; |
64 | 64 |
65 base::WaitableEvent* shutdown_event_; | 65 base::WaitableEvent* shutdown_event_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); | 67 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace IPC | 70 } // namespace IPC |
71 | 71 |
72 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 72 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
OLD | NEW |