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

Side by Side Diff: content/common/mojo/mojo_shell_connection_impl.cc

Issue 1452823003: Bind Application in renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « content/common/mojo/mojo_shell_connection_impl.h ('k') | content/public/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "content/common/mojo/mojo_shell_connection_impl.h" 5 #include "content/common/mojo/mojo_shell_connection_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/threading/thread_local.h" 9 #include "base/threading/thread_local.h"
10 #include "mojo/application/public/cpp/application_delegate.h" 10 #include "mojo/application/public/cpp/application_delegate.h"
(...skipping 13 matching lines...) Expand all
24 } // namespace 24 } // namespace
25 25
26 bool IsRunningInMojoShell() { 26 bool IsRunningInMojoShell() {
27 return base::CommandLine::ForCurrentProcess()->HasSwitch( 27 return base::CommandLine::ForCurrentProcess()->HasSwitch(
28 "mojo-platform-channel-handle"); 28 "mojo-platform-channel-handle");
29 } 29 }
30 30
31 // static 31 // static
32 void MojoShellConnectionImpl::Create() { 32 void MojoShellConnectionImpl::Create() {
33 DCHECK(IsRunningInMojoShell()); 33 DCHECK(IsRunningInMojoShell());
34 CreateWithMessagePipe(mojo::ScopedMessagePipeHandle());
35 }
36
37 // static
38 void MojoShellConnectionImpl::CreateWithMessagePipe(
39 mojo::ScopedMessagePipeHandle handle) {
34 DCHECK(!lazy_tls_ptr.Pointer()->Get()); 40 DCHECK(!lazy_tls_ptr.Pointer()->Get());
35 MojoShellConnectionImpl* connection = new MojoShellConnectionImpl; 41 MojoShellConnectionImpl* connection = new MojoShellConnectionImpl;
36 lazy_tls_ptr.Pointer()->Set(connection); 42 lazy_tls_ptr.Pointer()->Set(connection);
37 connection->WaitForShell(); 43 connection->WaitForShell(handle.Pass());
38 } 44 }
39 45
40 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {} 46 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {}
41 MojoShellConnectionImpl::~MojoShellConnectionImpl() {} 47 MojoShellConnectionImpl::~MojoShellConnectionImpl() {}
42 48
43 void MojoShellConnectionImpl::WaitForShell() { 49 void MojoShellConnectionImpl::WaitForShell(
50 mojo::ScopedMessagePipeHandle handle) {
44 mojo::InterfaceRequest<mojo::Application> application_request; 51 mojo::InterfaceRequest<mojo::Application> application_request;
45 runner_connection_.reset( 52 runner_connection_.reset(mojo::runner::RunnerConnection::ConnectToRunner(
46 mojo::runner::RunnerConnection::ConnectToRunner(&application_request)); 53 &application_request, handle.Pass()));
47 application_impl_.reset(new mojo::ApplicationImpl( 54 application_impl_.reset(new mojo::ApplicationImpl(
48 this, application_request.Pass())); 55 this, application_request.Pass()));
49 application_impl_->WaitForInitialize(); 56 application_impl_->WaitForInitialize();
50 } 57 }
51 58
52 void MojoShellConnectionImpl::Initialize(mojo::ApplicationImpl* application) { 59 void MojoShellConnectionImpl::Initialize(mojo::ApplicationImpl* application) {
53 initialized_ = true; 60 initialized_ = true;
54 } 61 }
55 62
56 bool MojoShellConnectionImpl::ConfigureIncomingConnection( 63 bool MojoShellConnectionImpl::ConfigureIncomingConnection(
(...skipping 29 matching lines...) Expand all
86 // static 93 // static
87 void MojoShellConnection::Destroy() { 94 void MojoShellConnection::Destroy() {
88 // This joins the shell controller thread. 95 // This joins the shell controller thread.
89 delete Get(); 96 delete Get();
90 lazy_tls_ptr.Pointer()->Set(nullptr); 97 lazy_tls_ptr.Pointer()->Set(nullptr);
91 } 98 }
92 99
93 MojoShellConnection::~MojoShellConnection() {} 100 MojoShellConnection::~MojoShellConnection() {}
94 101
95 } // namespace content 102 } // namespace content
OLDNEW
« no previous file with comments | « content/common/mojo/mojo_shell_connection_impl.h ('k') | content/public/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698