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

Side by Side Diff: mojo/shell/application_manager.cc

Issue 1755423002: Add a test for application lifecycle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@27amtest
Patch Set: . Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/application_manager.h" 5 #include "mojo/shell/application_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 DCHECK(it != shell_client_factories_.end()); 462 DCHECK(it != shell_client_factories_.end());
463 shell_client_factories_.erase(it); 463 shell_client_factories_.erase(it);
464 } 464 }
465 465
466 void ApplicationManager::OnGotResolvedName( 466 void ApplicationManager::OnGotResolvedName(
467 scoped_ptr<ConnectParams> params, 467 scoped_ptr<ConnectParams> params,
468 const String& resolved_name, 468 const String& resolved_name,
469 const String& resolved_qualifier, 469 const String& resolved_qualifier,
470 mojom::CapabilityFilterPtr base_filter, 470 mojom::CapabilityFilterPtr base_filter,
471 const String& file_url) { 471 const String& file_url) {
472 std::string qualifier = params->target().qualifier();
473 if (qualifier == GetNamePath(params->target().name()))
474 qualifier = resolved_qualifier;
475 Identity target(params->target().name(), qualifier,
476 params->target().user_id());
477 params->set_target(target);
478
472 // It's possible that when this manifest request was issued, another one was 479 // It's possible that when this manifest request was issued, another one was
473 // already in-progress and completed by the time this one did, and so the 480 // already in-progress and completed by the time this one did, and so the
474 // requested application may already be running. 481 // requested application may already be running.
475 if (ConnectToExistingInstance(&params)) 482 if (ConnectToExistingInstance(&params))
476 return; 483 return;
477 484
478 Identity source = params->source(); 485 Identity source = params->source();
479 // |base_filter| can be null when there is no manifest, e.g. for URL types 486 // |base_filter| can be null when there is no manifest, e.g. for URL types
480 // not resolvable by the resolver. 487 // not resolvable by the resolver.
481 CapabilityFilter filter = GetPermissiveCapabilityFilter(); 488 CapabilityFilter filter = GetPermissiveCapabilityFilter();
482 if (!base_filter.is_null()) 489 if (!base_filter.is_null())
483 filter = base_filter->filter.To<CapabilityFilter>(); 490 filter = base_filter->filter.To<CapabilityFilter>();
484 Identity target = params->target();
485 target.set_filter(filter); 491 target.set_filter(filter);
486 492
487 mojom::ShellClientRequest request; 493 mojom::ShellClientRequest request;
488 Instance* instance = CreateInstance(target, &request); 494 Instance* instance = CreateInstance(target, &request);
489 instance->ConnectToClient(std::move(params)); 495 instance->ConnectToClient(std::move(params));
490 496
491 if (LoadWithLoader(target, &request)) 497 if (LoadWithLoader(target, &request))
492 return; 498 return;
493 499
494 CHECK(!file_url.is_null() && !base_filter.is_null()); 500 CHECK(!file_url.is_null() && !base_filter.is_null());
495 501
496 if (target.name() != resolved_name) { 502 if (target.name() != resolved_name) {
497 // In cases where a package alias is resolved, we have to use the qualifier 503 // In cases where a package alias is resolved, we have to use the qualifier
498 // from the original request rather than for the package itself, which will 504 // from the original request rather than for the package itself, which will
499 // always be the same. 505 // always be the same.
500 CreateShellClient( 506 CreateShellClient(
501 source, Identity(resolved_name, target.qualifier(), target.user_id()), 507 source, Identity(resolved_name, resolved_qualifier, target.user_id()),
502 target.name(), std::move(request)); 508 target.name(), std::move(request));
503 } else { 509 } else {
504 bool start_sandboxed = false; 510 bool start_sandboxed = false;
505 native_runners_.push_back( 511 native_runners_.push_back(
506 instance->StartWithFileURL(file_url.To<GURL>(), std::move(request), 512 instance->StartWithFileURL(file_url.To<GURL>(), std::move(request),
507 start_sandboxed, 513 start_sandboxed,
508 native_runner_factory_.get())); 514 native_runner_factory_.get()));
509 } 515 }
510 } 516 }
511 517
(...skipping 17 matching lines...) Expand all
529 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) { 535 for (auto it = native_runners_.begin(); it != native_runners_.end(); ++it) {
530 if (it->get() == runner) { 536 if (it->get() == runner) {
531 native_runners_.erase(it); 537 native_runners_.erase(it);
532 return; 538 return;
533 } 539 }
534 } 540 }
535 } 541 }
536 542
537 } // namespace shell 543 } // namespace shell
538 } // namespace mojo 544 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/package_manager/package_manager.cc ('k') | mojo/shell/public/cpp/application_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698