| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SENDER_H__ | 5 #ifndef IPC_IPC_SYNC_SENDER_H__ |
| 6 #define IPC_IPC_SYNC_SENDER_H__ | 6 #define IPC_IPC_SYNC_SENDER_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // This is similar to ChannelProxy, with the added feature of supporting sending | 28 // This is similar to ChannelProxy, with the added feature of supporting sending |
| 29 // synchronous messages. | 29 // synchronous messages. |
| 30 // Note that care must be taken that the lifetime of the ipc_thread argument | 30 // Note that care must be taken that the lifetime of the ipc_thread argument |
| 31 // is more than this object. If the message loop goes away while this object | 31 // is more than this object. If the message loop goes away while this object |
| 32 // is running and it's used to send a message, then it will use the invalid | 32 // is running and it's used to send a message, then it will use the invalid |
| 33 // message loop pointer to proxy it to the ipc thread. | 33 // message loop pointer to proxy it to the ipc thread. |
| 34 class SyncChannel : public ChannelProxy, | 34 class SyncChannel : public ChannelProxy, |
| 35 public base::WaitableEventWatcher::Delegate { | 35 public base::WaitableEventWatcher::Delegate { |
| 36 public: | 36 public: |
| 37 SyncChannel(const std::string& channel_id, Channel::Mode mode, | 37 SyncChannel(const std::string& channel_id, |
| 38 Channel::Listener* listener, MessageFilter* filter, | 38 Channel::Mode mode, |
| 39 MessageLoop* ipc_message_loop, bool create_pipe_now, | 39 Channel::Listener* listener, |
| 40 MessageLoop* ipc_message_loop, |
| 41 bool create_pipe_now, |
| 40 base::WaitableEvent* shutdown_event); | 42 base::WaitableEvent* shutdown_event); |
| 41 virtual ~SyncChannel(); | 43 virtual ~SyncChannel(); |
| 42 | 44 |
| 43 virtual bool Send(Message* message); | 45 virtual bool Send(Message* message); |
| 44 virtual bool SendWithTimeout(Message* message, int timeout_ms); | 46 virtual bool SendWithTimeout(Message* message, int timeout_ms); |
| 45 | 47 |
| 46 // Whether we allow sending messages with no time-out. | 48 // Whether we allow sending messages with no time-out. |
| 47 void set_sync_messages_with_no_timeout_allowed(bool value) { | 49 void set_sync_messages_with_no_timeout_allowed(bool value) { |
| 48 sync_messages_with_no_timeout_allowed_ = value; | 50 sync_messages_with_no_timeout_allowed_ = value; |
| 49 } | 51 } |
| 50 | 52 |
| 51 protected: | 53 protected: |
| 52 class ReceivedSyncMsgQueue; | 54 class ReceivedSyncMsgQueue; |
| 53 friend class ReceivedSyncMsgQueue; | 55 friend class ReceivedSyncMsgQueue; |
| 54 | 56 |
| 55 // SyncContext holds the per object data for SyncChannel, so that SyncChannel | 57 // SyncContext holds the per object data for SyncChannel, so that SyncChannel |
| 56 // can be deleted while it's being used in a different thread. See | 58 // can be deleted while it's being used in a different thread. See |
| 57 // ChannelProxy::Context for more information. | 59 // ChannelProxy::Context for more information. |
| 58 class SyncContext : public Context, | 60 class SyncContext : public Context, |
| 59 public base::WaitableEventWatcher::Delegate { | 61 public base::WaitableEventWatcher::Delegate { |
| 60 public: | 62 public: |
| 61 SyncContext(Channel::Listener* listener, | 63 SyncContext(Channel::Listener* listener, |
| 62 MessageFilter* filter, | |
| 63 MessageLoop* ipc_thread, | 64 MessageLoop* ipc_thread, |
| 64 base::WaitableEvent* shutdown_event); | 65 base::WaitableEvent* shutdown_event); |
| 65 | 66 |
| 66 // Adds information about an outgoing sync message to the context so that | 67 // Adds information about an outgoing sync message to the context so that |
| 67 // we know how to deserialize the reply. | 68 // we know how to deserialize the reply. |
| 68 void Push(SyncMessage* sync_msg); | 69 void Push(SyncMessage* sync_msg); |
| 69 | 70 |
| 70 // Cleanly remove the top deserializer (and throw it away). Returns the | 71 // Cleanly remove the top deserializer (and throw it away). Returns the |
| 71 // result of the Send call for that message. | 72 // result of the Send call for that message. |
| 72 bool Pop(); | 73 bool Pop(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 147 |
| 147 // Used to signal events between the IPC and listener threads. | 148 // Used to signal events between the IPC and listener threads. |
| 148 base::WaitableEventWatcher dispatch_watcher_; | 149 base::WaitableEventWatcher dispatch_watcher_; |
| 149 | 150 |
| 150 DISALLOW_COPY_AND_ASSIGN(SyncChannel); | 151 DISALLOW_COPY_AND_ASSIGN(SyncChannel); |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace IPC | 154 } // namespace IPC |
| 154 | 155 |
| 155 #endif // IPC_IPC_SYNC_SENDER_H__ | 156 #endif // IPC_IPC_SYNC_SENDER_H__ |
| OLD | NEW |