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

Unified Diff: shell/dynamic_application_loader.cc

Issue 884303002: Launch nexes from mojo_shell. Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Edits Created 5 years, 11 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 | « shell/BUILD.gn ('k') | shell/nacl/nacl_service_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/dynamic_application_loader.cc
diff --git a/shell/dynamic_application_loader.cc b/shell/dynamic_application_loader.cc
index afc9a5395c241d4861400bc0d6feb4cddba02956..50c0db5effc3b115885b8427d9acbbef9aeddd88 100644
--- a/shell/dynamic_application_loader.cc
+++ b/shell/dynamic_application_loader.cc
@@ -28,6 +28,9 @@
#include "shell/context.h"
#include "shell/data_pipe_peek.h"
#include "shell/filename_util.h"
+#if defined(MOJO_USE_NACL)
+#include "shell/nacl/nacl_service_runner.h"
+#endif
#include "shell/switches.h"
#include "url/url_util.h"
@@ -81,6 +84,17 @@ class DynamicApplicationLoader::Loader {
base::TaskRunner* task_runner,
base::Callback<void(const base::FilePath&, bool)> callback) = 0;
+ virtual GURL URL() = 0;
+
+ std::string Extension() {
+ std::string filename = URL().ExtractFileName();
+ size_t dot = filename.rfind('.');
+ if (dot != std::string::npos) {
+ return filename.substr(dot);
+ }
+ return "";
+ }
+
virtual std::string MimeType() = 0;
virtual bool HasMojoMagic() = 0;
@@ -112,6 +126,14 @@ class DynamicApplicationLoader::Loader {
// header, or looking for some specific mojo signature prepended to the
// library.
+ // TODO(ncbray) sniff or infer the content type at a previous stage in the
+ // pipeline.
+ if (Extension() == ".nexe") {
+ AsPath(context_->task_runners()->blocking_pool(),
+ base::Bind(&Loader::RunNexe, weak_ptr_factory_.GetWeakPtr()));
+ return;
+ }
+
AsPath(context_->task_runners()->blocking_pool(),
base::Bind(&Loader::RunLibrary, weak_ptr_factory_.GetWeakPtr()));
}
@@ -149,6 +171,25 @@ class DynamicApplicationLoader::Loader {
base::Bind(&Loader::ReportComplete, weak_ptr_factory_.GetWeakPtr()));
}
+ void RunNexe(const base::FilePath& path, bool path_exists) {
+ DCHECK(application_request_.is_pending());
+
+ if (!path_exists) {
+ LOG(ERROR) << "Library not started because library path '" << path.value()
+ << "' does not exist.";
+ ReportComplete();
+ return;
+ }
+
+#if defined(MOJO_USE_NACL)
+ nacl_runner_.reset(new NaClServiceRunner(context_));
+ nacl_runner_->Start(path, application_request_.Pass());
+#else
+ LOG(ERROR) << "Library not started because Native Client is not enabled.";
+ ReportComplete();
+#endif
+ }
+
DynamicServiceRunner::CleanupBehavior cleanup_behavior_;
InterfaceRequest<Application> application_request_;
ApplicationLoader::LoadCallback load_callback_;
@@ -157,6 +198,9 @@ class DynamicApplicationLoader::Loader {
MimeTypeToURLMap* mime_type_to_url_;
DynamicServiceRunnerFactory* runner_factory_;
scoped_ptr<DynamicServiceRunner> runner_;
+#if defined(MOJO_USE_NACL)
+ scoped_ptr<NaClServiceRunner> nacl_runner_;
+#endif
base::WeakPtrFactory<Loader> weak_ptr_factory_;
};
@@ -224,6 +268,8 @@ class DynamicApplicationLoader::LocalLoader : public Loader {
FROM_HERE, base::Bind(callback, path_, base::PathExists(path_)));
}
+ GURL URL() override { return url_; }
+
std::string MimeType() override { return ""; }
bool HasMojoMagic() override {
@@ -391,6 +437,8 @@ class DynamicApplicationLoader::NetworkLoader : public Loader {
weak_ptr_factory_.GetWeakPtr(), callback));
}
+ GURL URL() override { return url_; }
+
std::string MimeType() override {
DCHECK(response_);
return response_->mime_type;
« no previous file with comments | « shell/BUILD.gn ('k') | shell/nacl/nacl_service_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698