| 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 "chrome/app/mash/mash_runner.h" | 5 #include "chrome/app/mash/mash_runner.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
| 11 #include "base/i18n/icu_util.h" | 11 #include "base/i18n/icu_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/run_loop.h" |
| 16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 17 #include "components/tracing/common/trace_to_console.h" | 18 #include "components/tracing/common/trace_to_console.h" |
| 18 #include "components/tracing/common/tracing_switches.h" | 19 #include "components/tracing/common/tracing_switches.h" |
| 19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 20 #include "mash/package/mash_packaged_service.h" | 21 #include "mash/package/mash_packaged_service.h" |
| 21 #include "mojo/public/cpp/bindings/binding_set.h" | 22 #include "mojo/public/cpp/bindings/binding_set.h" |
| 22 #include "services/shell/background/background_shell.h" | 23 #include "services/shell/background/background_shell.h" |
| 23 #include "services/shell/native_runner_delegate.h" | 24 #include "services/shell/native_runner_delegate.h" |
| 24 #include "services/shell/public/cpp/connector.h" | 25 #include "services/shell/public/cpp/connector.h" |
| 25 #include "services/shell/public/cpp/identity.h" | 26 #include "services/shell/public/cpp/identity.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 shell::BackgroundShell background_shell; | 108 shell::BackgroundShell background_shell; |
| 108 std::unique_ptr<shell::BackgroundShell::InitParams> init_params( | 109 std::unique_ptr<shell::BackgroundShell::InitParams> init_params( |
| 109 new shell::BackgroundShell::InitParams); | 110 new shell::BackgroundShell::InitParams); |
| 110 init_params->native_runner_delegate = &native_runner_delegate; | 111 init_params->native_runner_delegate = &native_runner_delegate; |
| 111 background_shell.Init(std::move(init_params)); | 112 background_shell.Init(std::move(init_params)); |
| 112 service_.reset(new mash::MashPackagedService); | 113 service_.reset(new mash::MashPackagedService); |
| 113 service_->set_context(base::MakeUnique<shell::ServiceContext>( | 114 service_->set_context(base::MakeUnique<shell::ServiceContext>( |
| 114 service_.get(), | 115 service_.get(), |
| 115 background_shell.CreateServiceRequest("exe:chrome_mash"))); | 116 background_shell.CreateServiceRequest("exe:chrome_mash"))); |
| 116 service_->connector()->Connect("mojo:mash_session"); | 117 service_->connector()->Connect("mojo:mash_session"); |
| 117 base::MessageLoop::current()->Run(); | 118 base::RunLoop().Run(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void MashRunner::RunChild() { | 121 void MashRunner::RunChild() { |
| 121 base::i18n::InitializeICU(); | 122 base::i18n::InitializeICU(); |
| 122 shell::ChildProcessMainWithCallback( | 123 shell::ChildProcessMainWithCallback( |
| 123 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); | 124 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void MashRunner::StartChildApp( | 127 void MashRunner::StartChildApp( |
| 127 shell::mojom::ServiceRequest service_request) { | 128 shell::mojom::ServiceRequest service_request) { |
| 128 // TODO(sky): use MessagePumpMojo. | 129 // TODO(sky): use MessagePumpMojo. |
| 129 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); | 130 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
| 130 service_.reset(new mash::MashPackagedService); | 131 service_.reset(new mash::MashPackagedService); |
| 131 service_->set_context(base::MakeUnique<shell::ServiceContext>( | 132 service_->set_context(base::MakeUnique<shell::ServiceContext>( |
| 132 service_.get(), std::move(service_request))); | 133 service_.get(), std::move(service_request))); |
| 133 message_loop.Run(); | 134 base::RunLoop().Run(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 int MashMain() { | 137 int MashMain() { |
| 137 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
| 138 base::RouteStdioToConsole(false); | 139 base::RouteStdioToConsole(false); |
| 139 #endif | 140 #endif |
| 140 // TODO(sky): wire this up correctly. | 141 // TODO(sky): wire this up correctly. |
| 141 logging::LoggingSettings settings; | 142 logging::LoggingSettings settings; |
| 142 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 143 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 143 logging::InitLogging(settings); | 144 logging::InitLogging(settings); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 tracing::GetConfigForTraceToConsole(); | 162 tracing::GetConfigForTraceToConsole(); |
| 162 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 163 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 163 trace_config, | 164 trace_config, |
| 164 base::trace_event::TraceLog::RECORDING_MODE); | 165 base::trace_event::TraceLog::RECORDING_MODE); |
| 165 } | 166 } |
| 166 | 167 |
| 167 MashRunner mash_runner; | 168 MashRunner mash_runner; |
| 168 mash_runner.Run(); | 169 mash_runner.Run(); |
| 169 return 0; | 170 return 0; |
| 170 } | 171 } |
| OLD | NEW |