Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Unified Diff: content/child/child_thread_impl.cc

Issue 2163883005: WIP: Obtain Bootstrap from utility process Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/common/child_process_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_thread_impl.cc
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
index 3d26cbdf16d307efc26885afcc71b766b8eb3e46..9f16f9157e3d8849cb1176b3b90dcda2f020581e 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -53,6 +53,7 @@
#include "content/child/websocket_message_filter.h"
#include "content/common/child_process_messages.h"
#include "content/common/in_process_child_thread_params.h"
+#include "content/public/common/connection_filter.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/mojo_channel_switches.h"
#include "content/public/common/mojo_shell_connection.h"
@@ -68,6 +69,7 @@
#include "mojo/edk/embedder/named_platform_channel_pair.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/scoped_ipc_support.h"
+#include "services/shell/public/cpp/connection.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "services/shell/public/cpp/interface_registry.h"
#include "services/shell/runner/common/client_util.h"
@@ -257,6 +259,36 @@ void InitializeMojoIPCChannel() {
} // namespace
+class ChildThreadImpl::ChildThreadConnectionFilter
+ : public ConnectionFilter,
+ public shell::InterfaceFactory<IPC::mojom::Bootstrap> {
+ public:
+ explicit ChildThreadConnectionFilter(ChildThreadImpl* impl)
+ : child_thread_impl_(impl) {}
+ ~ChildThreadConnectionFilter() override {}
+
+ private:
+ // ConnectionFilter:
+ bool OnConnect(shell::Connection* connection,
+ shell::Connector* connector) override {
+ connection->GetInterfaceRegistry()->AddInterface<IPC::mojom::Bootstrap>(
+ this);
+ return true;
+ }
+
+ // shell::InterfaceFactory<IPC::mojom::Bootstrap>:
+ void Create(shell::Connection* connection,
+ IPC::mojom::BootstrapRequest request) override {
+ // TODO: bind channel.
+ LOG(WARNING) << "Hello, World!";
+ child_thread_impl_->ConnectMojoChannel(std::move(request));
+ }
+
+ ChildThreadImpl* child_thread_impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChildThreadConnectionFilter);
+};
+
ChildThread* ChildThread::Get() {
return ChildThreadImpl::current();
}
@@ -388,6 +420,13 @@ void ChildThreadImpl::ConnectChannel(bool use_mojo_channel,
channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now);
}
+void ChildThreadImpl::ConnectMojoChannel(IPC::mojom::BootstrapRequest request) {
+ channel_->Init(
+ IPC::ChannelMojo::CreateClientFactory(
+ request.PassMessagePipe(), ChildProcess::current()->io_task_runner()),
+ true);
+}
+
void ChildThreadImpl::Init(const Options& options) {
channel_name_ = options.channel_name;
@@ -431,6 +470,8 @@ void ChildThreadImpl::Init(const Options& options) {
mojo_shell_connection_ = MojoShellConnection::Create(
mojo::MakeRequest<shell::mojom::Service>(std::move(handle)),
GetIOTaskRunner());
+ mojo_shell_connection_->AddConnectionFilter(
+ base::WrapUnique(new ChildThreadConnectionFilter(this)));
// TODO(rockot): Remove this once all child-to-browser interface connections
// are made via a Connector rather than directly through an
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/common/child_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698