| OLD | NEW |
| 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 #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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 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 ChannelProxy::MessageFilter, | 29 class IPC_EXPORT SyncMessageFilter : public ChannelProxy::MessageFilter, |
| 30 public Message::Sender { | 30 public Message::Sender { |
| 31 public: | 31 public: |
| 32 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); | 32 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); |
| 33 virtual ~SyncMessageFilter(); | 33 virtual ~SyncMessageFilter(); |
| 34 | 34 |
| 35 // Message::Sender implementation. | 35 // Message::Sender implementation. |
| 36 virtual bool Send(Message* message); | 36 virtual bool Send(Message* message) OVERRIDE; |
| 37 | 37 |
| 38 // ChannelProxy::MessageFilter implementation. | 38 // ChannelProxy::MessageFilter implementation. |
| 39 virtual void OnFilterAdded(Channel* channel); | 39 virtual void OnFilterAdded(Channel* channel) OVERRIDE; |
| 40 virtual void OnChannelError(); | 40 virtual void OnChannelError() OVERRIDE; |
| 41 virtual void OnChannelClosing(); | 41 virtual void OnChannelClosing() OVERRIDE; |
| 42 virtual bool OnMessageReceived(const Message& message); | 42 virtual bool OnMessageReceived(const Message& message) OVERRIDE; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 void SendOnIOThread(Message* message); | 45 void SendOnIOThread(Message* message); |
| 46 // Signal all the pending sends as done, used in an error condition. | 46 // Signal all the pending sends as done, used in an error condition. |
| 47 void SignalAllEvents(); | 47 void SignalAllEvents(); |
| 48 | 48 |
| 49 // The channel to which this filter was added. | 49 // The channel to which this filter was added. |
| 50 Channel* channel_; | 50 Channel* channel_; |
| 51 | 51 |
| 52 // The process's main thread. | 52 // The process's main thread. |
| 53 scoped_refptr<base::MessageLoopProxy> listener_loop_; | 53 scoped_refptr<base::MessageLoopProxy> listener_loop_; |
| 54 | 54 |
| 55 // The message loop where the Channel lives. | 55 // The message loop where the Channel lives. |
| 56 scoped_refptr<base::MessageLoopProxy> io_loop_; | 56 scoped_refptr<base::MessageLoopProxy> io_loop_; |
| 57 | 57 |
| 58 typedef std::set<PendingSyncMsg*> PendingSyncMessages; | 58 typedef std::set<PendingSyncMsg*> PendingSyncMessages; |
| 59 PendingSyncMessages pending_sync_messages_; | 59 PendingSyncMessages pending_sync_messages_; |
| 60 | 60 |
| 61 // Locks data members above. | 61 // Locks data members above. |
| 62 base::Lock lock_; | 62 base::Lock lock_; |
| 63 | 63 |
| 64 base::WaitableEvent* shutdown_event_; | 64 base::WaitableEvent* shutdown_event_; |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); | 66 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace IPC | 69 } // namespace IPC |
| 70 | 70 |
| 71 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 71 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
| OLD | NEW |