OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/standalone/context.h" | 5 #include "services/service_manager/standalone/context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 blocking_pool_->Shutdown(); | 123 blocking_pool_->Shutdown(); |
124 } | 124 } |
125 | 125 |
126 // static | 126 // static |
127 void Context::EnsureEmbedderIsInitialized() { | 127 void Context::EnsureEmbedderIsInitialized() { |
128 static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER; | 128 static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER; |
129 setup.Get(); | 129 setup.Get(); |
130 } | 130 } |
131 | 131 |
132 void Context::Init(std::unique_ptr<InitParams> init_params) { | 132 void Context::Init(std::unique_ptr<InitParams> init_params) { |
133 TRACE_EVENT0("mojo_shell", "Context::Init"); | 133 TRACE_EVENT0("service_manager", "Context::Init"); |
134 const base::CommandLine& command_line = | 134 const base::CommandLine& command_line = |
135 *base::CommandLine::ForCurrentProcess(); | 135 *base::CommandLine::ForCurrentProcess(); |
136 | 136 |
137 bool trace_startup = command_line.HasSwitch(::switches::kTraceStartup); | 137 bool trace_startup = command_line.HasSwitch(::switches::kTraceStartup); |
138 if (trace_startup) { | 138 if (trace_startup) { |
139 tracer_.Start( | 139 tracer_.Start( |
140 command_line.GetSwitchValueASCII(::switches::kTraceStartup), | 140 command_line.GetSwitchValueASCII(::switches::kTraceStartup), |
141 command_line.GetSwitchValueASCII(::switches::kTraceStartupDuration), | 141 command_line.GetSwitchValueASCII(::switches::kTraceStartupDuration), |
142 "mojo_runner.trace"); | 142 "mojo_runner.trace"); |
143 } | 143 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 if (command_line.HasSwitch(tracing::kTraceStartup)) { | 216 if (command_line.HasSwitch(tracing::kTraceStartup)) { |
217 tracing::mojom::CollectorPtr coordinator; | 217 tracing::mojom::CollectorPtr coordinator; |
218 auto coordinator_request = GetProxy(&coordinator); | 218 auto coordinator_request = GetProxy(&coordinator); |
219 tracing_remote_interfaces->GetInterface( | 219 tracing_remote_interfaces->GetInterface( |
220 tracing::mojom::Collector::Name_, | 220 tracing::mojom::Collector::Name_, |
221 coordinator_request.PassMessagePipe()); | 221 coordinator_request.PassMessagePipe()); |
222 tracer_.StartCollectingFromTracingService(std::move(coordinator)); | 222 tracer_.StartCollectingFromTracingService(std::move(coordinator)); |
223 } | 223 } |
224 | 224 |
225 // Record the shell startup metrics used for performance testing. | 225 // Record the service manager startup metrics used for performance testing. |
226 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 226 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
227 tracing::kEnableStatsCollectionBindings)) { | 227 tracing::kEnableStatsCollectionBindings)) { |
228 tracing::mojom::StartupPerformanceDataCollectorPtr collector; | 228 tracing::mojom::StartupPerformanceDataCollectorPtr collector; |
229 tracing_remote_interfaces->GetInterface( | 229 tracing_remote_interfaces->GetInterface( |
230 tracing::mojom::StartupPerformanceDataCollector::Name_, | 230 tracing::mojom::StartupPerformanceDataCollector::Name_, |
231 mojo::GetProxy(&collector).PassMessagePipe()); | 231 mojo::GetProxy(&collector).PassMessagePipe()); |
232 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 232 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
233 // CurrentProcessInfo::CreationTime is only defined on some platforms. | 233 // CurrentProcessInfo::CreationTime is only defined on some platforms. |
234 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); | 234 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); |
235 collector->SetShellProcessCreationTime(creation_time.ToInternalValue()); | 235 collector->SetServiceManagerProcessCreationTime( |
| 236 creation_time.ToInternalValue()); |
236 #endif | 237 #endif |
237 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); | 238 collector->SetServiceManagerMainEntryPointTime( |
| 239 main_entry_time_.ToInternalValue()); |
238 } | 240 } |
239 } | 241 } |
240 | 242 |
241 void Context::Shutdown() { | 243 void Context::Shutdown() { |
242 // Actions triggered by Shell's destructor may require a current message loop, | 244 // Actions triggered by Service Manager's destructor may require a current |
| 245 // message loop, |
243 // so we should destruct it explicitly now as ~Context() occurs post message | 246 // so we should destruct it explicitly now as ~Context() occurs post message |
244 // loop shutdown. | 247 // loop shutdown. |
245 service_manager_.reset(); | 248 service_manager_.reset(); |
246 | 249 |
247 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_); | 250 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_); |
248 | 251 |
249 // If we didn't initialize the edk we should not shut it down. | 252 // If we didn't initialize the edk we should not shut it down. |
250 if (!init_edk_) | 253 if (!init_edk_) |
251 return; | 254 return; |
252 | 255 |
253 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); | 256 TRACE_EVENT0("service_manager", "Context::Shutdown"); |
254 // Post a task in case OnShutdownComplete is called synchronously. | 257 // Post a task in case OnShutdownComplete is called synchronously. |
255 base::ThreadTaskRunnerHandle::Get()->PostTask( | 258 base::ThreadTaskRunnerHandle::Get()->PostTask( |
256 FROM_HERE, base::Bind(mojo::edk::ShutdownIPCSupport)); | 259 FROM_HERE, base::Bind(mojo::edk::ShutdownIPCSupport)); |
257 // We'll quit when we get OnShutdownComplete(). | 260 // We'll quit when we get OnShutdownComplete(). |
258 base::RunLoop().Run(); | 261 base::RunLoop().Run(); |
259 } | 262 } |
260 | 263 |
261 void Context::OnShutdownComplete() { | 264 void Context::OnShutdownComplete() { |
262 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_); | 265 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_); |
263 base::MessageLoop::current()->QuitWhenIdle(); | 266 base::MessageLoop::current()->QuitWhenIdle(); |
(...skipping 22 matching lines...) Expand all Loading... |
286 mojom::InterfaceProviderPtr local_interfaces; | 289 mojom::InterfaceProviderPtr local_interfaces; |
287 | 290 |
288 std::unique_ptr<ConnectParams> params(new ConnectParams); | 291 std::unique_ptr<ConnectParams> params(new ConnectParams); |
289 params->set_source(CreateServiceManagerIdentity()); | 292 params->set_source(CreateServiceManagerIdentity()); |
290 params->set_target(Identity(name, mojom::kRootUserID)); | 293 params->set_target(Identity(name, mojom::kRootUserID)); |
291 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); | 294 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); |
292 service_manager_->Connect(std::move(params)); | 295 service_manager_->Connect(std::move(params)); |
293 } | 296 } |
294 | 297 |
295 } // namespace service_manager | 298 } // namespace service_manager |
OLD | NEW |