Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: shell/context.cc

Issue 1965563002: Neuter the wrong-way ServiceProvider (a.k.a. exposed_services). (Closed) Base URL: https://github.com/domokit/mojo.git@work795_js_wrong_way
Patch Set: rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « shell/application_manager/shell_impl.cc ('k') | shell/native_runner_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(&registry)); 317 mojo::ConnectToService(tracing_services.get(), GetProxy(&registry));
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
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
OLDNEW
« no previous file with comments | « shell/application_manager/shell_impl.cc ('k') | shell/native_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698