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

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

Issue 1685183004: Bootstrap Mojo IPC independent of Chrome IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: and fix posix Created 4 years, 10 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 unified diff | Download patch
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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/threading/thread_local.h" 12 #include "base/threading/thread_local.h"
13 #include "mojo/converters/network/network_type_converters.h" 13 #include "mojo/converters/network/network_type_converters.h"
14 #include "mojo/shell/public/cpp/shell_client.h" 14 #include "mojo/shell/public/cpp/shell_client.h"
15 #include "mojo/shell/public/cpp/shell_connection.h" 15 #include "mojo/shell/public/cpp/shell_connection.h"
16 #include "mojo/shell/runner/child/runner_connection.h" 16 #include "mojo/shell/runner/child/runner_connection.h"
17 17
18 namespace content { 18 namespace content {
19 namespace { 19 namespace {
20
20 using MojoShellConnectionPtr = 21 using MojoShellConnectionPtr =
21 base::ThreadLocalPointer<MojoShellConnectionImpl>; 22 base::ThreadLocalPointer<MojoShellConnectionImpl>;
22 23
23 // Env is thread local so that aura may be used on multiple threads. 24 // Env is thread local so that aura may be used on multiple threads.
24 base::LazyInstance<MojoShellConnectionPtr>::Leaky lazy_tls_ptr = 25 base::LazyInstance<MojoShellConnectionPtr>::Leaky lazy_tls_ptr =
25 LAZY_INSTANCE_INITIALIZER; 26 LAZY_INSTANCE_INITIALIZER;
26 27
27 } // namespace 28 } // namespace
28 29
29 bool IsRunningInMojoShell() { 30 bool IsRunningInMojoShell() {
(...skipping 29 matching lines...) Expand all
59 60
60 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {} 61 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {}
61 MojoShellConnectionImpl::~MojoShellConnectionImpl() { 62 MojoShellConnectionImpl::~MojoShellConnectionImpl() {
62 STLDeleteElements(&listeners_); 63 STLDeleteElements(&listeners_);
63 } 64 }
64 65
65 void MojoShellConnectionImpl::WaitForShell( 66 void MojoShellConnectionImpl::WaitForShell(
66 mojo::ScopedMessagePipeHandle handle) { 67 mojo::ScopedMessagePipeHandle handle) {
67 mojo::ShellClientRequest request; 68 mojo::ShellClientRequest request;
68 runner_connection_.reset(mojo::shell::RunnerConnection::ConnectToRunner( 69 runner_connection_.reset(mojo::shell::RunnerConnection::ConnectToRunner(
69 &request, std::move(handle))); 70 &request, std::move(handle), false /* exit_on_error */));
71 if (!runner_connection_) {
72 DLOG(ERROR) << "Unable to connect to the Mojo shell.";
73 delete this;
74 lazy_tls_ptr.Pointer()->Set(nullptr);
75 return;
76 }
70 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); 77 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request)));
71 shell_connection_->WaitForInitialize(); 78 shell_connection_->WaitForInitialize();
72 } 79 }
73 80
74 void MojoShellConnectionImpl::Initialize(mojo::Shell* shell, 81 void MojoShellConnectionImpl::Initialize(mojo::Shell* shell,
75 const std::string& url, 82 const std::string& url,
76 uint32_t id) { 83 uint32_t id) {
77 initialized_ = true; 84 initialized_ = true;
78 } 85 }
79 86
(...skipping 29 matching lines...) Expand all
109 // static 116 // static
110 void MojoShellConnection::Destroy() { 117 void MojoShellConnection::Destroy() {
111 // This joins the shell controller thread. 118 // This joins the shell controller thread.
112 delete Get(); 119 delete Get();
113 lazy_tls_ptr.Pointer()->Set(nullptr); 120 lazy_tls_ptr.Pointer()->Set(nullptr);
114 } 121 }
115 122
116 MojoShellConnection::~MojoShellConnection() {} 123 MojoShellConnection::~MojoShellConnection() {}
117 124
118 } // namespace content 125 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698