Index: ipc/ipc_channel_proxy.h |
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h |
index 9ef8bf35f27e7786f7540874f2ee0e38dae71df9..e9d0270a7e3f0f02e515af9a33fff1b32fc52f22 100644 |
--- a/ipc/ipc_channel_proxy.h |
+++ b/ipc/ipc_channel_proxy.h |
@@ -55,6 +55,16 @@ class SendCallbackHelper; |
// The consumer of IPC::ChannelProxy is responsible for allocating the Thread |
// instance where the IPC::Channel will be created and operated. |
// |
+// Thread-safe send |
+// |
+// A particular |Channel| implementation has thread-safe |Send()| |
+// implementation. If it is supported, ChannelProxy bypasses inter-thread |
+// messaging and calls |Send()| immediately. The |channel_| variable is touched |
+// from multiple threads in this case, so |ChannelProxy::channel_lifetime_lock_| |
+// is used to protect it. |
+// This lock overhead is paid only if the underlying channel supports the |
+// thread-safe send. |
+// |
class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
public: |
// Initializes a channel proxy. The channel_handle and mode parameters are |
@@ -193,6 +203,11 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
void OnDispatchError(); |
void OnDispatchBadMessage(const Message& message); |
+ // Sends |message| from appropriate thread. |
+ void Send(Message* message); |
+ void SendFromThisThread(Message* message); |
+ void ClearChannel(); |
+ |
scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; |
Listener* listener_; |
@@ -203,6 +218,7 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
// Note, channel_ may be set on the Listener thread or the IPC thread. |
// But once it has been set, it must only be read or cleared on the IPC |
// thread. |
+ // Here is one exception, which is thread-safe send. See the class comment. |
scoped_ptr<Channel> channel_; |
std::string channel_id_; |
bool channel_connected_called_; |
@@ -217,6 +233,13 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
// Lock for pending_filters_. |
base::Lock pending_filters_lock_; |
+ // Lock for |channel_| value. This is only relevant in the context of |
+ // thread-safe send. |
+ base::Lock channel_lifetime_lock_; |
+ // Indicates the thread-safe send availability. This is constant once |
+ // |channel_| is set. |
+ bool channel_send_thread_safe_; |
+ |
// Cached copy of the peer process ID. Set on IPC but read on both IPC and |
// listener threads. |
base::ProcessId peer_pid_; |