Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 bool IsRunningInMojoShell() { | 36 bool IsRunningInMojoShell() { |
| 37 return mojo_shell_connection_factory || | 37 return mojo_shell_connection_factory || |
| 38 base::CommandLine::ForCurrentProcess()->HasSwitch( | 38 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 39 mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch); | 39 mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool ShouldWaitForShell() { | 42 bool ShouldWaitForShell() { |
| 43 return mojo_shell_connection_factory || | 43 return mojo_shell_connection_factory || IsRunningInMojoShell(); |
|
Ken Rockot(use gerrit already)
2016/04/25 23:29:35
Unfortunately IsRunningInMojoShell is a misnomer,
sadrul
2016/04/26 03:22:04
I was thinking a naive workaround would be to chec
| |
| 44 (IsRunningInMojoShell() && | |
| 45 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 46 switches::kWaitForMojoShell)); | |
| 47 } | 44 } |
| 48 | 45 |
| 49 // static | 46 // static |
| 50 bool MojoShellConnectionImpl::CreateUsingFactory() { | 47 bool MojoShellConnectionImpl::CreateUsingFactory() { |
| 51 if (mojo_shell_connection_factory) { | 48 if (mojo_shell_connection_factory) { |
| 52 DCHECK(!lazy_tls_ptr.Pointer()->Get()); | 49 DCHECK(!lazy_tls_ptr.Pointer()->Get()); |
| 53 mojo_shell_connection_factory->Run(); | 50 mojo_shell_connection_factory->Run(); |
| 54 DCHECK(lazy_tls_ptr.Pointer()->Get()); | 51 DCHECK(lazy_tls_ptr.Pointer()->Get()); |
| 55 return true; | 52 return true; |
| 56 } | 53 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 // static | 163 // static |
| 167 void MojoShellConnection::Destroy() { | 164 void MojoShellConnection::Destroy() { |
| 168 // This joins the shell controller thread. | 165 // This joins the shell controller thread. |
| 169 delete Get(); | 166 delete Get(); |
| 170 lazy_tls_ptr.Pointer()->Set(nullptr); | 167 lazy_tls_ptr.Pointer()->Set(nullptr); |
| 171 } | 168 } |
| 172 | 169 |
| 173 MojoShellConnection::~MojoShellConnection() {} | 170 MojoShellConnection::~MojoShellConnection() {} |
| 174 | 171 |
| 175 } // namespace content | 172 } // namespace content |
| OLD | NEW |