summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2015-07-30 17:04:42 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-31 00:05:37 +0000
commitbcc7961519e151bf05e09b19e2eabc36b279e335 (patch)
treed05fed1f9a9d2c94488b4bd69ea52cce17de9703 /ipc
parent44667692bb1627770816c3866edb538ebf2f4946 (diff)
downloadchromium_src-bcc7961519e151bf05e09b19e2eabc36b279e335.zip
chromium_src-bcc7961519e151bf05e09b19e2eabc36b279e335.tar.gz
chromium_src-bcc7961519e151bf05e09b19e2eabc36b279e335.tar.bz2
ipc: Allow ChannelProxy to be set as a channel endpoint.
BUG=493414 Review URL: https://codereview.chromium.org/1270543004 Cr-Commit-Position: refs/heads/master@{#341231}
Diffstat (limited to 'ipc')
-rw-r--r--ipc/attachment_broker_unprivileged.cc9
-rw-r--r--ipc/attachment_broker_unprivileged.h2
-rw-r--r--ipc/ipc_channel_proxy.cc8
-rw-r--r--ipc/ipc_channel_proxy.h10
4 files changed, 28 insertions, 1 deletions
diff --git a/ipc/attachment_broker_unprivileged.cc b/ipc/attachment_broker_unprivileged.cc
index f12cfe2..45aeae8 100644
--- a/ipc/attachment_broker_unprivileged.cc
+++ b/ipc/attachment_broker_unprivileged.cc
@@ -5,6 +5,7 @@
#include "ipc/attachment_broker_unprivileged.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_channel_proxy.h"
namespace IPC {
@@ -21,4 +22,12 @@ void AttachmentBrokerUnprivileged::DesignateBrokerCommunicationChannel(
channel->set_attachment_broker_endpoint(true);
}
+void AttachmentBrokerUnprivileged::DesignateBrokerCommunicationChannel(
+ IPC::ChannelProxy* proxy) {
+ DCHECK(proxy);
+ DCHECK(!sender_);
+ sender_ = proxy;
+ proxy->SetAttachmentBrokerEndpoint(true);
+}
+
} // namespace IPC
diff --git a/ipc/attachment_broker_unprivileged.h b/ipc/attachment_broker_unprivileged.h
index a543736..96d3d3e 100644
--- a/ipc/attachment_broker_unprivileged.h
+++ b/ipc/attachment_broker_unprivileged.h
@@ -11,6 +11,7 @@
namespace IPC {
class Channel;
+class ChannelProxy;
class Sender;
// This abstract subclass of AttachmentBroker is intended for use in
@@ -23,6 +24,7 @@ class IPC_EXPORT AttachmentBrokerUnprivileged : public IPC::AttachmentBroker {
// In each unprivileged process, exactly one channel should be used to
// communicate brokerable attachments with the broker process.
void DesignateBrokerCommunicationChannel(IPC::Channel* channel);
+ void DesignateBrokerCommunicationChannel(IPC::ChannelProxy* proxy);
protected:
IPC::Sender* get_sender() { return sender_; }
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index e8e3d28..44fa42b 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -32,7 +32,8 @@ ChannelProxy::Context::Context(
channel_connected_called_(false),
channel_send_thread_safe_(false),
message_filter_router_(new MessageFilterRouter()),
- peer_pid_(base::kNullProcessId) {
+ peer_pid_(base::kNullProcessId),
+ attachment_broker_endpoint_(false) {
DCHECK(ipc_task_runner_.get());
// The Listener thread where Messages are handled must be a separate thread
// to avoid oversubscribing the IO thread. If you trigger this error, you
@@ -58,6 +59,7 @@ void ChannelProxy::Context::CreateChannel(scoped_ptr<ChannelFactory> factory) {
channel_id_ = factory->GetName();
channel_ = factory->BuildChannel(this);
channel_send_thread_safe_ = channel_->IsSendThreadSafe();
+ channel_->set_attachment_broker_endpoint(attachment_broker_endpoint_);
}
bool ChannelProxy::Context::TryFilters(const Message& message) {
@@ -504,6 +506,10 @@ base::ScopedFD ChannelProxy::TakeClientFileDescriptor() {
}
#endif
+void ChannelProxy::SetAttachmentBrokerEndpoint(bool is_endpoint) {
+ context()->set_attachment_broker_endpoint(is_endpoint);
+}
+
//-----------------------------------------------------------------------------
} // namespace IPC
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index 5d1402e..6ff5cc2 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -157,6 +157,8 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
base::ScopedFD TakeClientFileDescriptor();
#endif
+ void SetAttachmentBrokerEndpoint(bool is_endpoint);
+
protected:
class Context;
// A subclass uses this constructor if it needs to add more information
@@ -217,6 +219,10 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
// Create the Channel
void CreateChannel(scoped_ptr<ChannelFactory> factory);
+ void set_attachment_broker_endpoint(bool is_endpoint) {
+ attachment_broker_endpoint_ = is_endpoint;
+ }
+
// Methods called on the IO thread.
void OnSendMessage(scoped_ptr<Message> message_ptr);
void OnAddFilter();
@@ -266,6 +272,10 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
// Cached copy of the peer process ID. Set on IPC but read on both IPC and
// listener threads.
base::ProcessId peer_pid_;
+
+ // Whether this channel is used as an endpoint for sending and receiving
+ // brokerable attachment messages to/from the broker process.
+ bool attachment_broker_endpoint_;
};
Context* context() { return context_.get(); }