| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 using tracked_objects::ThreadData; | 80 using tracked_objects::ThreadData; |
| 81 | 81 |
| 82 namespace content { | 82 namespace content { |
| 83 namespace { | 83 namespace { |
| 84 | 84 |
| 85 // How long to wait for a connection to the browser process before giving up. | 85 // How long to wait for a connection to the browser process before giving up. |
| 86 const int kConnectionTimeoutS = 15; | 86 const int kConnectionTimeoutS = 15; |
| 87 | 87 |
| 88 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = | 88 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl>>::DestructorAtExit |
| 89 LAZY_INSTANCE_INITIALIZER; | 89 g_lazy_tls = LAZY_INSTANCE_INITIALIZER; |
| 90 | 90 |
| 91 // This isn't needed on Windows because there the sandbox's job object | 91 // This isn't needed on Windows because there the sandbox's job object |
| 92 // terminates child processes automatically. For unsandboxed processes (i.e. | 92 // terminates child processes automatically. For unsandboxed processes (i.e. |
| 93 // plugins), PluginThread has EnsureTerminateMessageFilter. | 93 // plugins), PluginThread has EnsureTerminateMessageFilter. |
| 94 #if defined(OS_POSIX) | 94 #if defined(OS_POSIX) |
| 95 | 95 |
| 96 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ | 96 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
| 97 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ | 97 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ |
| 98 defined(UNDEFINED_SANITIZER) | 98 defined(UNDEFINED_SANITIZER) |
| 99 // A thread delegate that waits for |duration| and then exits the process with | 99 // A thread delegate that waits for |duration| and then exits the process with |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 219 } |
| 220 | 220 |
| 221 void QuitClosure::PostQuitFromNonMainThread() { | 221 void QuitClosure::PostQuitFromNonMainThread() { |
| 222 base::AutoLock lock(lock_); | 222 base::AutoLock lock(lock_); |
| 223 while (closure_.is_null()) | 223 while (closure_.is_null()) |
| 224 cond_var_.Wait(); | 224 cond_var_.Wait(); |
| 225 | 225 |
| 226 closure_.Run(); | 226 closure_.Run(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 base::LazyInstance<QuitClosure> g_quit_closure = LAZY_INSTANCE_INITIALIZER; | 229 base::LazyInstance<QuitClosure>::DestructorAtExit g_quit_closure = |
| 230 LAZY_INSTANCE_INITIALIZER; |
| 230 #endif | 231 #endif |
| 231 | 232 |
| 232 void InitializeMojoIPCChannel() { | 233 void InitializeMojoIPCChannel() { |
| 233 mojo::edk::ScopedPlatformHandle platform_channel; | 234 mojo::edk::ScopedPlatformHandle platform_channel; |
| 234 #if defined(OS_WIN) | 235 #if defined(OS_WIN) |
| 235 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 236 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 236 mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch)) { | 237 mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch)) { |
| 237 platform_channel = | 238 platform_channel = |
| 238 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( | 239 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( |
| 239 *base::CommandLine::ForCurrentProcess()); | 240 *base::CommandLine::ForCurrentProcess()); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 connected_to_browser_ = true; | 872 connected_to_browser_ = true; |
| 872 child_info_ = local_info; | 873 child_info_ = local_info; |
| 873 browser_info_ = remote_info; | 874 browser_info_ = remote_info; |
| 874 } | 875 } |
| 875 | 876 |
| 876 bool ChildThreadImpl::IsInBrowserProcess() const { | 877 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 877 return static_cast<bool>(browser_process_io_runner_); | 878 return static_cast<bool>(browser_process_io_runner_); |
| 878 } | 879 } |
| 879 | 880 |
| 880 } // namespace content | 881 } // namespace content |
| OLD | NEW |