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

Unified Diff: services/shell/shell.cc

Issue 1899583002: Revert of Remove shell::Loader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/shell/shell.h ('k') | services/shell/shell.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/shell.cc
diff --git a/services/shell/shell.cc b/services/shell/shell.cc
index a542ae4769e481d48514d785e9650414d4d09d3a..35049dd41f30873ef65a2161d14f8a1c5f548fde 100644
--- a/services/shell/shell.cc
+++ b/services/shell/shell.cc
@@ -120,8 +120,10 @@
allow_any_application_(capability_spec.required.count("*") == 1),
pid_receiver_binding_(this),
weak_factory_(this) {
- if (identity_.name() == kShellName)
+ if (identity_.name() == kShellName ||
+ shell_->GetLoaderForName(identity_.name())) {
pid_ = base::Process::Current().Pid();
+ }
DCHECK_NE(mojom::kInvalidInstanceID, id_);
}
@@ -458,6 +460,7 @@
Shell::~Shell() {
TerminateShellConnections();
+ STLDeleteValues(&name_to_loader_);
for (auto& runner : native_runners_)
runner.reset();
}
@@ -484,6 +487,14 @@
Connect(std::move(params), std::move(client));
return request;
+}
+
+void Shell::SetLoaderForName(std::unique_ptr<Loader> loader,
+ const std::string& name) {
+ auto it = name_to_loader_.find(name);
+ if (it != name_to_loader_.end())
+ delete it->second;
+ name_to_loader_[name] = loader.release();
}
////////////////////////////////////////////////////////////////////////////////
@@ -726,22 +737,42 @@
} else {
// Otherwise we create a new ShellClient pipe.
mojom::ShellClientRequest request = GetProxy(&client);
- CHECK(!result->package_url.is_null() && !result->capabilities.is_null());
-
- if (target.name() != result->resolved_name) {
+ if (LoadWithLoader(target, &request)) {
instance->StartWithClient(std::move(client));
- Identity factory(result->resolved_name, target.user_id(),
- instance_name);
- CreateShellClientWithFactory(factory, target.name(),
- std::move(request));
} else {
- instance->StartWithFilePath(
- mojo::util::UrlToFilePath(result->package_url.To<GURL>()));
+ CHECK(!result->package_url.is_null() && !result->capabilities.is_null());
+
+ if (target.name() != result->resolved_name) {
+ instance->StartWithClient(std::move(client));
+ Identity factory(result->resolved_name, target.user_id(),
+ instance_name);
+ CreateShellClientWithFactory(factory, target.name(),
+ std::move(request));
+ } else {
+ instance->StartWithFilePath(
+ mojo::util::UrlToFilePath(result->package_url.To<GURL>()));
+ }
}
}
// Now that the instance has a ShellClient, we can connect to it.
instance->ConnectToClient(std::move(params));
+}
+
+bool Shell::LoadWithLoader(const Identity& target,
+ mojom::ShellClientRequest* request) {
+ Loader* loader = GetLoaderForName(target.name());
+ if (!loader)
+ return false;
+ loader->Load(target.name(), std::move(*request));
+ return true;
+}
+
+Loader* Shell::GetLoaderForName(const std::string& name) {
+ auto name_it = name_to_loader_.find(name);
+ if (name_it != name_to_loader_.end())
+ return name_it->second;
+ return default_loader_.get();
}
base::WeakPtr<Shell> Shell::GetWeakPtr() {
« no previous file with comments | « services/shell/shell.h ('k') | services/shell/shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698