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

Unified Diff: content/browser/mojo/mojo_application_host.cc

Issue 1877743002: Use token-based initialisation for the utility process MojoApplication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: content/browser/mojo/mojo_application_host.cc
diff --git a/content/browser/mojo/mojo_application_host.cc b/content/browser/mojo/mojo_application_host.cc
index c1103e15bbbc2e19d402bb0107b5203f55b3c63e..c80bf75670af8d413b673ac9b8f5cfa426166fe7 100644
--- a/content/browser/mojo/mojo_application_host.cc
+++ b/content/browser/mojo/mojo_application_host.cc
@@ -10,6 +10,7 @@
#include "content/common/mojo/mojo_messages.h"
#include "content/public/browser/browser_thread.h"
#include "ipc/ipc_sender.h"
+#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
namespace content {
@@ -84,6 +85,37 @@ void MojoApplicationHost::Activate(IPC::Sender* sender,
IPC::GetPlatformFileForTransit(client_file, true)));
}
+std::string MojoApplicationHost::InitWithToken() {
+ DCHECK(!client_handle_.is_valid()) << "Already initialized!";
+ DCHECK(!did_activate_);
+
+ std::string token = mojo::edk::GenerateRandomToken();
+ mojo::ScopedMessagePipeHandle pipe =
+ mojo::edk::CreateParentMessagePipe(token);
+ DCHECK(pipe.is_valid());
+ application_setup_.reset(new ApplicationSetupImpl(
+ &service_registry_,
+ mojo::MakeRequest<mojom::ApplicationSetup>(std::move(pipe))));
+
+ did_activate_ = true;
+ return token;
+}
+
+mojo::ScopedMessagePipeHandle MojoApplicationHost::InitWithPipe() {
+ DCHECK(!client_handle_.is_valid()) << "Already initialized!";
+ DCHECK(!did_activate_);
+
+ mojo::MessagePipe handles;
+ DCHECK(handles.handle0.is_valid());
+ DCHECK(handles.handle1.is_valid());
+ application_setup_.reset(new ApplicationSetupImpl(
+ &service_registry_,
+ mojo::MakeRequest<mojom::ApplicationSetup>(std::move(handles.handle0))));
+
+ did_activate_ = true;
+ return std::move(handles.handle1);
+}
+
void MojoApplicationHost::OverrideIOTaskRunnerForTest(
scoped_refptr<base::TaskRunner> io_task_runner) {
io_task_runner_override_ = io_task_runner;

Powered by Google App Engine
This is Rietveld 408576698