| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/service_manager/public/cpp/standalone_service/standalone_serv
ice.h" | 5 #include "services/service_manager/public/cpp/standalone_service/standalone_serv
ice.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 void RunStandaloneService(const StandaloneServiceCallback& callback) { | 59 void RunStandaloneService(const StandaloneServiceCallback& callback) { |
| 60 DCHECK(!base::MessageLoop::current()); | 60 DCHECK(!base::MessageLoop::current()); |
| 61 | 61 |
| 62 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
| 63 // Send our task port to the parent. | 63 // Send our task port to the parent. |
| 64 MachBroker::SendTaskPortToParent(); | 64 MachBroker::SendTaskPortToParent(); |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 #if !defined(OFFICIAL_BUILD) | |
| 68 // Initialize stack dumping just before initializing sandbox to make | |
| 69 // sure symbol names in all loaded libraries will be cached. | |
| 70 base::debug::EnableInProcessStackDumping(); | |
| 71 #endif | |
| 72 #if defined(OS_LINUX) | 67 #if defined(OS_LINUX) |
| 73 std::unique_ptr<LinuxSandbox> sandbox; | 68 std::unique_ptr<LinuxSandbox> sandbox; |
| 74 const base::CommandLine& command_line = | 69 const base::CommandLine& command_line = |
| 75 *base::CommandLine::ForCurrentProcess(); | 70 *base::CommandLine::ForCurrentProcess(); |
| 76 if (command_line.HasSwitch(switches::kEnableSandbox)) | 71 if (command_line.HasSwitch(switches::kEnableSandbox)) |
| 77 sandbox = InitializeSandbox(); | 72 sandbox = InitializeSandbox(); |
| 78 #endif | 73 #endif |
| 79 | 74 |
| 80 mojo::edk::Init(); | 75 mojo::edk::Init(); |
| 81 | 76 |
| 82 base::Thread io_thread("io_thread"); | 77 base::Thread io_thread("io_thread"); |
| 83 io_thread.StartWithOptions( | 78 io_thread.StartWithOptions( |
| 84 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 79 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 85 | 80 |
| 86 mojo::edk::ScopedIPCSupport ipc_support( | 81 mojo::edk::ScopedIPCSupport ipc_support( |
| 87 io_thread.task_runner(), | 82 io_thread.task_runner(), |
| 88 mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN); | 83 mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN); |
| 89 mojo::edk::SetParentPipeHandleFromCommandLine(); | 84 mojo::edk::SetParentPipeHandleFromCommandLine(); |
| 90 | 85 |
| 91 callback.Run(GetServiceRequestFromCommandLine()); | 86 callback.Run(GetServiceRequestFromCommandLine()); |
| 92 } | 87 } |
| 93 | 88 |
| 94 } // namespace service_manager | 89 } // namespace service_manager |
| OLD | NEW |