| Index: shell/dynamic_application_loader.cc
|
| diff --git a/shell/dynamic_application_loader.cc b/shell/dynamic_application_loader.cc
|
| index 6b2a1c9d8a5261ad93b5b48512b1c0f62271e199..96865e02295b72af91a7892262a34eefe45effa3 100644
|
| --- a/shell/dynamic_application_loader.cc
|
| +++ b/shell/dynamic_application_loader.cc
|
| @@ -26,6 +26,9 @@
|
| #include "shell/context.h"
|
| #include "shell/data_pipe_peek.h"
|
| #include "shell/filename_util.h"
|
| +#if MOJO_USE_NACL
|
| +#include "shell/nacl/nacl_service_runner.h"
|
| +#endif
|
| #include "shell/switches.h"
|
| #include "url/url_util.h"
|
|
|
| @@ -79,6 +82,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;
|
| @@ -110,6 +124,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()));
|
| }
|
| @@ -147,6 +169,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 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_;
|
| @@ -155,6 +196,9 @@ class DynamicApplicationLoader::Loader {
|
| MimeTypeToURLMap* mime_type_to_url_;
|
| DynamicServiceRunnerFactory* runner_factory_;
|
| scoped_ptr<DynamicServiceRunner> runner_;
|
| +#if MOJO_USE_NACL
|
| + scoped_ptr<NaClServiceRunner> nacl_runner_;
|
| +#endif
|
| base::WeakPtrFactory<Loader> weak_ptr_factory_;
|
| };
|
|
|
| @@ -222,6 +266,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 {
|
| @@ -388,6 +434,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;
|
|
|