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/runner/context.h" | 5 #include "mojo/runner/context.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 else | 202 else |
203 runner_factory.reset(new InProcessNativeRunnerFactory(this)); | 203 runner_factory.reset(new InProcessNativeRunnerFactory(this)); |
204 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); | 204 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); |
205 application_manager_->set_native_runner_factory(runner_factory.Pass()); | 205 application_manager_->set_native_runner_factory(runner_factory.Pass()); |
206 | 206 |
207 ServiceProviderPtr service_provider_ptr; | 207 ServiceProviderPtr service_provider_ptr; |
208 ServiceProviderPtr tracing_service_provider_ptr; | 208 ServiceProviderPtr tracing_service_provider_ptr; |
209 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 209 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
210 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 210 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
211 request->url = mojo::String::From("mojo:tracing"); | 211 request->url = mojo::String::From("mojo:tracing"); |
212 application_manager_->ConnectToApplication( | 212 |
213 nullptr, request.Pass(), std::string(), GetProxy(&service_provider_ptr), | 213 scoped_ptr<shell::ConnectToApplicationParams> params( |
214 tracing_service_provider_ptr.Pass(), | 214 new shell::ConnectToApplicationParams); |
215 shell::GetPermissiveCapabilityFilter(), base::Closure(), | 215 params->SetURLInfo(request.Pass()); |
216 shell::EmptyConnectCallback()); | 216 params->set_services(GetProxy(&service_provider_ptr)); |
| 217 params->set_exposed_services(tracing_service_provider_ptr.Pass()); |
| 218 params->set_filter(shell::GetPermissiveCapabilityFilter()); |
| 219 application_manager_->ConnectToApplication(params.Pass()); |
217 | 220 |
218 // Record the shell startup metrics used for performance testing. | 221 // Record the shell startup metrics used for performance testing. |
219 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 222 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
220 tracing::kEnableStatsCollectionBindings)) { | 223 tracing::kEnableStatsCollectionBindings)) { |
221 tracing::StartupPerformanceDataCollectorPtr collector; | 224 tracing::StartupPerformanceDataCollectorPtr collector; |
222 service_provider_ptr->ConnectToService( | 225 service_provider_ptr->ConnectToService( |
223 tracing::StartupPerformanceDataCollector::Name_, | 226 tracing::StartupPerformanceDataCollector::Name_, |
224 GetProxy(&collector).PassMessagePipe()); | 227 GetProxy(&collector).PassMessagePipe()); |
225 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 228 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
226 // CurrentProcessInfo::CreationTime is only defined on some platforms. | 229 // CurrentProcessInfo::CreationTime is only defined on some platforms. |
(...skipping 29 matching lines...) Expand all Loading... |
256 } | 259 } |
257 | 260 |
258 void Context::Run(const GURL& url) { | 261 void Context::Run(const GURL& url) { |
259 DCHECK(app_complete_callback_.is_null()); | 262 DCHECK(app_complete_callback_.is_null()); |
260 ServiceProviderPtr services; | 263 ServiceProviderPtr services; |
261 ServiceProviderPtr exposed_services; | 264 ServiceProviderPtr exposed_services; |
262 | 265 |
263 app_urls_.insert(url); | 266 app_urls_.insert(url); |
264 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 267 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
265 request->url = mojo::String::From(url.spec()); | 268 request->url = mojo::String::From(url.spec()); |
266 application_manager_->ConnectToApplication( | 269 |
267 nullptr, request.Pass(), std::string(), GetProxy(&services), | 270 scoped_ptr<shell::ConnectToApplicationParams> params( |
268 exposed_services.Pass(), shell::GetPermissiveCapabilityFilter(), | 271 new shell::ConnectToApplicationParams); |
269 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url), | 272 params->SetURLInfo(request.Pass()); |
270 shell::EmptyConnectCallback()); | 273 params->set_services(GetProxy(&services)); |
| 274 params->set_exposed_services(exposed_services.Pass()); |
| 275 params->set_filter(shell::GetPermissiveCapabilityFilter()); |
| 276 params->set_on_application_end( |
| 277 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
| 278 application_manager_->ConnectToApplication(params.Pass()); |
271 } | 279 } |
272 | 280 |
273 void Context::RunCommandLineApplication(const base::Closure& callback) { | 281 void Context::RunCommandLineApplication(const base::Closure& callback) { |
274 DCHECK(app_urls_.empty()); | 282 DCHECK(app_urls_.empty()); |
275 DCHECK(app_complete_callback_.is_null()); | 283 DCHECK(app_complete_callback_.is_null()); |
276 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 284 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
277 base::CommandLine::StringVector args = command_line->GetArgs(); | 285 base::CommandLine::StringVector args = command_line->GetArgs(); |
278 for (size_t i = 0; i < args.size(); ++i) { | 286 for (size_t i = 0; i < args.size(); ++i) { |
279 GURL possible_app(args[i]); | 287 GURL possible_app(args[i]); |
280 if (possible_app.SchemeIs("mojo")) { | 288 if (possible_app.SchemeIs("mojo")) { |
(...skipping 14 matching lines...) Expand all Loading... |
295 base::MessageLoop::current()->Quit(); | 303 base::MessageLoop::current()->Quit(); |
296 } else { | 304 } else { |
297 app_complete_callback_.Run(); | 305 app_complete_callback_.Run(); |
298 } | 306 } |
299 } | 307 } |
300 } | 308 } |
301 } | 309 } |
302 | 310 |
303 } // namespace runner | 311 } // namespace runner |
304 } // namespace mojo | 312 } // namespace mojo |
OLD | NEW |