| 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 "shell/context.h" | 5 #include "shell/context.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // The mojo_shell --args-for command-line switch is handled specially because | 304 // The mojo_shell --args-for command-line switch is handled specially because |
| 305 // it can appear more than once. The base::CommandLine class collapses | 305 // it can appear more than once. The base::CommandLine class collapses |
| 306 // multiple occurrences of the same switch. | 306 // multiple occurrences of the same switch. |
| 307 base::CommandLine* current = base::CommandLine::ForCurrentProcess(); | 307 base::CommandLine* current = base::CommandLine::ForCurrentProcess(); |
| 308 for (size_t i = 1; i < current->argv().size(); ++i) | 308 for (size_t i = 1; i < current->argv().size(); ++i) |
| 309 ApplyApplicationArgs(this, current->argv()[i]); | 309 ApplyApplicationArgs(this, current->argv()[i]); |
| 310 | 310 |
| 311 ServiceProviderPtr tracing_services; | 311 ServiceProviderPtr tracing_services; |
| 312 application_manager_.ConnectToApplication(GURL("mojo:tracing"), GURL(""), | 312 application_manager_.ConnectToApplication(GURL("mojo:tracing"), GURL(""), |
| 313 GetProxy(&tracing_services), | 313 GetProxy(&tracing_services), |
| 314 nullptr, base::Closure()); | 314 base::Closure()); |
| 315 if (tracer_) { | 315 if (tracer_) { |
| 316 tracing::TraceProviderRegistryPtr registry; | 316 tracing::TraceProviderRegistryPtr registry; |
| 317 mojo::ConnectToService(tracing_services.get(), GetProxy(®istry)); | 317 mojo::ConnectToService(tracing_services.get(), GetProxy(®istry)); |
| 318 | 318 |
| 319 mojo::InterfaceHandle<tracing::TraceProvider> provider; | 319 mojo::InterfaceHandle<tracing::TraceProvider> provider; |
| 320 tracer_->ConnectToProvider(GetProxy(&provider)); | 320 tracer_->ConnectToProvider(GetProxy(&provider)); |
| 321 registry->RegisterTraceProvider(provider.Pass()); | 321 registry->RegisterTraceProvider(provider.Pass()); |
| 322 } | 322 } |
| 323 | 323 |
| 324 if (command_line.HasSwitch(switches::kTraceStartup)) { | 324 if (command_line.HasSwitch(switches::kTraceStartup)) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 351 DCHECK(task_runners_->shell_runner()->RunsTasksOnCurrentThread()); | 351 DCHECK(task_runners_->shell_runner()->RunsTasksOnCurrentThread()); |
| 352 base::MessageLoop::current()->Quit(); | 352 base::MessageLoop::current()->Quit(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void Context::OnSlaveDisconnect(mojo::embedder::SlaveInfo slave_info) { | 355 void Context::OnSlaveDisconnect(mojo::embedder::SlaveInfo slave_info) { |
| 356 // TODO(vtl): Do something, once we actually have |slave_info|. | 356 // TODO(vtl): Do something, once we actually have |slave_info|. |
| 357 } | 357 } |
| 358 | 358 |
| 359 void Context::Run(const GURL& url) { | 359 void Context::Run(const GURL& url) { |
| 360 ServiceProviderPtr services; | 360 ServiceProviderPtr services; |
| 361 ServiceProviderPtr exposed_services; | |
| 362 | 361 |
| 363 app_urls_.insert(url); | 362 app_urls_.insert(url); |
| 364 application_manager_.ConnectToApplication( | 363 application_manager_.ConnectToApplication( |
| 365 url, GURL(), mojo::GetProxy(&services), exposed_services.Pass(), | 364 url, GURL(), mojo::GetProxy(&services), |
| 366 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | 365 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
| 367 } | 366 } |
| 368 | 367 |
| 369 void Context::OnApplicationEnd(const GURL& url) { | 368 void Context::OnApplicationEnd(const GURL& url) { |
| 370 if (app_urls_.find(url) != app_urls_.end()) { | 369 if (app_urls_.find(url) != app_urls_.end()) { |
| 371 app_urls_.erase(url); | 370 app_urls_.erase(url); |
| 372 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 371 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
| 373 DCHECK(task_runners_->shell_runner()->RunsTasksOnCurrentThread()); | 372 DCHECK(task_runners_->shell_runner()->RunsTasksOnCurrentThread()); |
| 374 base::MessageLoop::current()->Quit(); | 373 base::MessageLoop::current()->Quit(); |
| 375 } | 374 } |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 | 377 |
| 379 } // namespace shell | 378 } // namespace shell |
| OLD | NEW |