| 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 "mojo/shell/standalone/context.h" | 5 #include "mojo/shell/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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 new InProcessNativeRunnerFactory(blocking_pool_.get())); | 148 new InProcessNativeRunnerFactory(blocking_pool_.get())); |
| 149 } else { | 149 } else { |
| 150 NativeRunnerDelegate* native_runner_delegate = init_params ? | 150 NativeRunnerDelegate* native_runner_delegate = init_params ? |
| 151 init_params->native_runner_delegate : nullptr; | 151 init_params->native_runner_delegate : nullptr; |
| 152 runner_factory.reset(new OutOfProcessNativeRunnerFactory( | 152 runner_factory.reset(new OutOfProcessNativeRunnerFactory( |
| 153 blocking_pool_.get(), native_runner_delegate)); | 153 blocking_pool_.get(), native_runner_delegate)); |
| 154 } | 154 } |
| 155 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog; | 155 scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog; |
| 156 if (init_params) | 156 if (init_params) |
| 157 app_catalog = std::move(init_params->app_catalog); | 157 app_catalog = std::move(init_params->app_catalog); |
| 158 application_manager_.reset(new ApplicationManager(std::move(runner_factory), | 158 shell_.reset(new Shell(std::move(runner_factory), blocking_pool_.get(), |
| 159 blocking_pool_.get(), | 159 std::move(app_catalog))); |
| 160 std::move(app_catalog))); | |
| 161 | 160 |
| 162 shell::mojom::InterfaceProviderPtr tracing_remote_interfaces; | 161 shell::mojom::InterfaceProviderPtr tracing_remote_interfaces; |
| 163 shell::mojom::InterfaceProviderPtr tracing_local_interfaces; | 162 shell::mojom::InterfaceProviderPtr tracing_local_interfaces; |
| 164 new TracingInterfaceProvider(&tracer_, GetProxy(&tracing_local_interfaces)); | 163 new TracingInterfaceProvider(&tracer_, GetProxy(&tracing_local_interfaces)); |
| 165 | 164 |
| 166 scoped_ptr<ConnectParams> params(new ConnectParams); | 165 scoped_ptr<ConnectParams> params(new ConnectParams); |
| 167 params->set_source(CreateShellIdentity()); | 166 params->set_source(CreateShellIdentity()); |
| 168 params->set_target(Identity("mojo:tracing", std::string(), | 167 params->set_target(Identity("mojo:tracing", std::string(), |
| 169 mojom::Connector::kUserInherit)); | 168 mojom::Connector::kUserInherit)); |
| 170 params->set_remote_interfaces(GetProxy(&tracing_remote_interfaces)); | 169 params->set_remote_interfaces(GetProxy(&tracing_remote_interfaces)); |
| 171 params->set_local_interfaces(std::move(tracing_local_interfaces)); | 170 params->set_local_interfaces(std::move(tracing_local_interfaces)); |
| 172 application_manager_->Connect(std::move(params)); | 171 shell_->Connect(std::move(params)); |
| 173 | 172 |
| 174 if (command_line.HasSwitch(tracing::kTraceStartup)) { | 173 if (command_line.HasSwitch(tracing::kTraceStartup)) { |
| 175 tracing::TraceCollectorPtr coordinator; | 174 tracing::TraceCollectorPtr coordinator; |
| 176 auto coordinator_request = GetProxy(&coordinator); | 175 auto coordinator_request = GetProxy(&coordinator); |
| 177 tracing_remote_interfaces->GetInterface( | 176 tracing_remote_interfaces->GetInterface( |
| 178 tracing::TraceCollector::Name_, coordinator_request.PassMessagePipe()); | 177 tracing::TraceCollector::Name_, coordinator_request.PassMessagePipe()); |
| 179 tracer_.StartCollectingFromTracingService(std::move(coordinator)); | 178 tracer_.StartCollectingFromTracingService(std::move(coordinator)); |
| 180 } | 179 } |
| 181 | 180 |
| 182 // Record the shell startup metrics used for performance testing. | 181 // Record the shell startup metrics used for performance testing. |
| 183 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 182 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 184 tracing::kEnableStatsCollectionBindings)) { | 183 tracing::kEnableStatsCollectionBindings)) { |
| 185 tracing::StartupPerformanceDataCollectorPtr collector; | 184 tracing::StartupPerformanceDataCollectorPtr collector; |
| 186 tracing_remote_interfaces->GetInterface( | 185 tracing_remote_interfaces->GetInterface( |
| 187 tracing::StartupPerformanceDataCollector::Name_, | 186 tracing::StartupPerformanceDataCollector::Name_, |
| 188 GetProxy(&collector).PassMessagePipe()); | 187 GetProxy(&collector).PassMessagePipe()); |
| 189 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 188 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
| 190 // CurrentProcessInfo::CreationTime is only defined on some platforms. | 189 // CurrentProcessInfo::CreationTime is only defined on some platforms. |
| 191 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); | 190 const base::Time creation_time = base::CurrentProcessInfo::CreationTime(); |
| 192 collector->SetShellProcessCreationTime(creation_time.ToInternalValue()); | 191 collector->SetShellProcessCreationTime(creation_time.ToInternalValue()); |
| 193 #endif | 192 #endif |
| 194 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); | 193 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); |
| 195 } | 194 } |
| 196 } | 195 } |
| 197 | 196 |
| 198 void Context::Shutdown() { | 197 void Context::Shutdown() { |
| 199 // Actions triggered by ApplicationManager's destructor may require a current | 198 // Actions triggered by Shell's destructor may require a current message loop, |
| 200 // message loop, so we should destruct it explicitly now as ~Context() occurs | 199 // so we should destruct it explicitly now as ~Context() occurs post message |
| 201 // post message loop shutdown. | 200 // loop shutdown. |
| 202 application_manager_.reset(); | 201 shell_.reset(); |
| 203 | 202 |
| 204 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); | 203 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); |
| 205 DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); | 204 DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); |
| 206 // Post a task in case OnShutdownComplete is called synchronously. | 205 // Post a task in case OnShutdownComplete is called synchronously. |
| 207 base::MessageLoop::current()->PostTask(FROM_HERE, | 206 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 208 base::Bind(edk::ShutdownIPCSupport)); | 207 base::Bind(edk::ShutdownIPCSupport)); |
| 209 // We'll quit when we get OnShutdownComplete(). | 208 // We'll quit when we get OnShutdownComplete(). |
| 210 base::MessageLoop::current()->Run(); | 209 base::MessageLoop::current()->Run(); |
| 211 } | 210 } |
| 212 | 211 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 225 std::string possible_app = args[i]; | 224 std::string possible_app = args[i]; |
| 226 #endif | 225 #endif |
| 227 if (GetNameType(possible_app) == "mojo") { | 226 if (GetNameType(possible_app) == "mojo") { |
| 228 Run(possible_app); | 227 Run(possible_app); |
| 229 break; | 228 break; |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 } | 231 } |
| 233 | 232 |
| 234 void Context::Run(const std::string& name) { | 233 void Context::Run(const std::string& name) { |
| 235 application_manager_->SetInstanceQuitCallback( | 234 shell_->SetInstanceQuitCallback(base::Bind(&OnInstanceQuit, name)); |
| 236 base::Bind(&OnInstanceQuit, name)); | |
| 237 | 235 |
| 238 shell::mojom::InterfaceProviderPtr remote_interfaces; | 236 shell::mojom::InterfaceProviderPtr remote_interfaces; |
| 239 shell::mojom::InterfaceProviderPtr local_interfaces; | 237 shell::mojom::InterfaceProviderPtr local_interfaces; |
| 240 | 238 |
| 241 scoped_ptr<ConnectParams> params(new ConnectParams); | 239 scoped_ptr<ConnectParams> params(new ConnectParams); |
| 242 params->set_source(CreateShellIdentity()); | 240 params->set_source(CreateShellIdentity()); |
| 243 params->set_target(Identity(name, std::string(), | 241 params->set_target(Identity(name, std::string(), |
| 244 mojom::Connector::kUserRoot)); | 242 mojom::Connector::kUserRoot)); |
| 245 params->set_remote_interfaces(GetProxy(&remote_interfaces)); | 243 params->set_remote_interfaces(GetProxy(&remote_interfaces)); |
| 246 params->set_local_interfaces(std::move(local_interfaces)); | 244 params->set_local_interfaces(std::move(local_interfaces)); |
| 247 application_manager_->Connect(std::move(params)); | 245 shell_->Connect(std::move(params)); |
| 248 } | 246 } |
| 249 | 247 |
| 250 } // namespace shell | 248 } // namespace shell |
| 251 } // namespace mojo | 249 } // namespace mojo |
| OLD | NEW |