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

Unified Diff: services/dart/content_handler_main.cc

Issue 1262493002: Enable HTTP loading in Mojo dart content handler (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | « mojo/tools/get_test_list.py ('k') | services/dart/dart_app.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/dart/content_handler_main.cc
diff --git a/services/dart/content_handler_main.cc b/services/dart/content_handler_main.cc
index c22f8966854e6e6ecaf99b193c286baa82bce288..7ecc39f2ffcc2928c6615aee7e29617b0d75c16c 100644
--- a/services/dart/content_handler_main.cc
+++ b/services/dart/content_handler_main.cc
@@ -22,6 +22,12 @@
namespace dart {
+static bool IsDartZip(std::string url) {
+ // If the url doesn't end with ".dart" we assume it is a zipped up
+ // dart application.
+ return !EndsWith(url, ".dart", false);
+}
+
class DartContentHandlerApp;
class DartContentHandler : public mojo::ContentHandlerFactory::ManagedDelegate {
@@ -143,7 +149,11 @@ DartContentHandler::CreateApplication(
mojo::InterfaceRequest<mojo::Application> application_request,
mojo::URLResponsePtr response) {
base::FilePath application_dir;
- {
+ std::string url = response->url.get();
+ if (IsDartZip(response->url.get())) {
+ // Loading a .dartzip:
+ // 1) Extract the .dartzip
+ // 2) Launch from temporary directory (|application_dir|).
handler_task_runner_->PostTask(
FROM_HERE,
base::Bind(
@@ -154,10 +164,13 @@ DartContentHandler::CreateApplication(
base::MessageLoop::current()->task_runner(), FROM_HERE,
base::MessageLoop::QuitWhenIdleClosure())));
base::RunLoop().Run();
+ return make_scoped_ptr(
+ new DartApp(application_request.Pass(), application_dir, strict_));
+ } else {
+ // Loading a raw .dart file pointed at by |url|.
+ return make_scoped_ptr(
+ new DartApp(application_request.Pass(), url, strict_));
}
-
- return make_scoped_ptr(
- new DartApp(application_request.Pass(), application_dir, strict_));
}
} // namespace dart
« no previous file with comments | « mojo/tools/get_test_list.py ('k') | services/dart/dart_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698