| 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" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void MashRunner::RunMain() { | 125 void MashRunner::RunMain() { |
| 126 // TODO(sky): refactor BackgroundServiceManager so can supply own context, we | 126 // TODO(sky): refactor BackgroundServiceManager so can supply own context, we |
| 127 // shouldn't we using context as it has a lot of stuff we don't really want | 127 // shouldn't we using context as it has a lot of stuff we don't really want |
| 128 // in chrome. | 128 // in chrome. |
| 129 NativeRunnerDelegateImpl native_runner_delegate; | 129 NativeRunnerDelegateImpl native_runner_delegate; |
| 130 service_manager::BackgroundServiceManager background_service_manager; | 130 service_manager::BackgroundServiceManager background_service_manager; |
| 131 std::unique_ptr<service_manager::BackgroundServiceManager::InitParams> | 131 std::unique_ptr<service_manager::BackgroundServiceManager::InitParams> |
| 132 init_params(new service_manager::BackgroundServiceManager::InitParams); | 132 init_params(new service_manager::BackgroundServiceManager::InitParams); |
| 133 init_params->native_runner_delegate = &native_runner_delegate; | 133 init_params->native_runner_delegate = &native_runner_delegate; |
| 134 background_service_manager.Init(std::move(init_params)); | 134 background_service_manager.Init(std::move(init_params)); |
| 135 service_.reset(new mash::MashPackagedService); | 135 context_.reset(new service_manager::ServiceContext( |
| 136 service_->set_context(base::MakeUnique<service_manager::ServiceContext>( | 136 base::MakeUnique<mash::MashPackagedService>(), |
| 137 service_.get(), | |
| 138 background_service_manager.CreateServiceRequest(kChromeMashServiceName))); | 137 background_service_manager.CreateServiceRequest(kChromeMashServiceName))); |
| 139 | 138 |
| 140 // We need to send a sync messages to the Catalog, so we wait for a completed | 139 // We need to send a sync messages to the Catalog, so we wait for a completed |
| 141 // connection first. | 140 // connection first. |
| 142 std::unique_ptr<service_manager::Connection> catalog_connection = | 141 std::unique_ptr<service_manager::Connection> catalog_connection = |
| 143 service_->connector()->Connect("service:catalog"); | 142 context_->connector()->Connect("service:catalog"); |
| 144 { | 143 { |
| 145 base::RunLoop run_loop; | 144 base::RunLoop run_loop; |
| 146 catalog_connection->AddConnectionCompletedClosure(run_loop.QuitClosure()); | 145 catalog_connection->AddConnectionCompletedClosure(run_loop.QuitClosure()); |
| 147 run_loop.Run(); | 146 run_loop.Run(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 // Synchronously override manifests needed for content process services. | 149 // Synchronously override manifests needed for content process services. |
| 151 catalog::mojom::CatalogControlPtr catalog_control; | 150 catalog::mojom::CatalogControlPtr catalog_control; |
| 152 catalog_connection->GetInterface(&catalog_control); | 151 catalog_connection->GetInterface(&catalog_control); |
| 153 CHECK(catalog_control->OverrideManifestPath( | 152 CHECK(catalog_control->OverrideManifestPath( |
| 154 content::kBrowserServiceName, | 153 content::kBrowserServiceName, |
| 155 GetPackageManifestPath(kChromeMashContentBrowserPackageName))); | 154 GetPackageManifestPath(kChromeMashContentBrowserPackageName))); |
| 156 CHECK(catalog_control->OverrideManifestPath( | 155 CHECK(catalog_control->OverrideManifestPath( |
| 157 content::kGpuServiceName, | 156 content::kGpuServiceName, |
| 158 GetPackageManifestPath(kChromeContentGpuPackageName))); | 157 GetPackageManifestPath(kChromeContentGpuPackageName))); |
| 159 CHECK(catalog_control->OverrideManifestPath( | 158 CHECK(catalog_control->OverrideManifestPath( |
| 160 content::kRendererServiceName, | 159 content::kRendererServiceName, |
| 161 GetPackageManifestPath(kChromeContentRendererPackageName))); | 160 GetPackageManifestPath(kChromeContentRendererPackageName))); |
| 162 CHECK(catalog_control->OverrideManifestPath( | 161 CHECK(catalog_control->OverrideManifestPath( |
| 163 content::kUtilityServiceName, | 162 content::kUtilityServiceName, |
| 164 GetPackageManifestPath(kChromeContentUtilityPackageName))); | 163 GetPackageManifestPath(kChromeContentUtilityPackageName))); |
| 165 | 164 |
| 166 // Ping mash_session to ensure an instance is brought up | 165 // Ping mash_session to ensure an instance is brought up |
| 167 service_->connector()->Connect("service:mash_session"); | 166 context_->connector()->Connect("service:mash_session"); |
| 168 base::RunLoop().Run(); | 167 base::RunLoop().Run(); |
| 169 } | 168 } |
| 170 | 169 |
| 171 void MashRunner::RunChild() { | 170 void MashRunner::RunChild() { |
| 172 base::i18n::InitializeICU(); | 171 base::i18n::InitializeICU(); |
| 173 InitializeResources(); | 172 InitializeResources(); |
| 174 service_manager::ChildProcessMainWithCallback( | 173 service_manager::ChildProcessMainWithCallback( |
| 175 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); | 174 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); |
| 176 } | 175 } |
| 177 | 176 |
| 178 void MashRunner::StartChildApp( | 177 void MashRunner::StartChildApp( |
| 179 service_manager::mojom::ServiceRequest service_request) { | 178 service_manager::mojom::ServiceRequest service_request) { |
| 180 // TODO(sad): Normally, this would be a TYPE_DEFAULT message loop. However, | 179 // TODO(sad): Normally, this would be a TYPE_DEFAULT message loop. However, |
| 181 // TYPE_UI is needed for mojo:ui. But it is not known whether the child app is | 180 // TYPE_UI is needed for mojo:ui. But it is not known whether the child app is |
| 182 // going to be mojo:ui at this point. So always create a TYPE_UI message loop | 181 // going to be mojo:ui at this point. So always create a TYPE_UI message loop |
| 183 // for now. | 182 // for now. |
| 184 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); | 183 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
| 185 service_.reset(new mash::MashPackagedService); | 184 context_.reset(new service_manager::ServiceContext( |
| 186 service_->set_context(base::MakeUnique<service_manager::ServiceContext>( | 185 base::MakeUnique<mash::MashPackagedService>(), |
| 187 service_.get(), std::move(service_request))); | 186 std::move(service_request))); |
| 188 base::RunLoop().Run(); | 187 base::RunLoop().Run(); |
| 189 } | 188 } |
| 190 | 189 |
| 191 int MashMain() { | 190 int MashMain() { |
| 192 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
| 193 base::RouteStdioToConsole(false); | 192 base::RouteStdioToConsole(false); |
| 194 #endif | 193 #endif |
| 195 // TODO(sky): wire this up correctly. | 194 // TODO(sky): wire this up correctly. |
| 196 logging::LoggingSettings settings; | 195 logging::LoggingSettings settings; |
| 197 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 196 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 215 tracing::GetConfigForTraceToConsole(); | 214 tracing::GetConfigForTraceToConsole(); |
| 216 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 215 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 217 trace_config, | 216 trace_config, |
| 218 base::trace_event::TraceLog::RECORDING_MODE); | 217 base::trace_event::TraceLog::RECORDING_MODE); |
| 219 } | 218 } |
| 220 | 219 |
| 221 MashRunner mash_runner; | 220 MashRunner mash_runner; |
| 222 mash_runner.Run(); | 221 mash_runner.Run(); |
| 223 return 0; | 222 return 0; |
| 224 } | 223 } |
| OLD | NEW |