| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "mojo/services/url_response_disk_cache/interfaces/url_response_disk_cac
he.mojom.h" | 22 #include "mojo/services/url_response_disk_cache/interfaces/url_response_disk_cac
he.mojom.h" |
| 23 #include "services/dart/content_handler_app_service_connector.h" | 23 #include "services/dart/content_handler_app_service_connector.h" |
| 24 #include "services/dart/dart_app.h" | 24 #include "services/dart/dart_app.h" |
| 25 #include "services/dart/dart_tracing.h" | 25 #include "services/dart/dart_tracing.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 namespace dart { | 28 namespace dart { |
| 29 | 29 |
| 30 const char kCompleteTimeline[] = "--complete-timeline"; | 30 const char kCompleteTimeline[] = "--complete-timeline"; |
| 31 const char kEnableStrictMode[] = "--enable-strict-mode"; | 31 const char kEnableStrictMode[] = "--enable-strict-mode"; |
| 32 const char kDisableObservatory[] = "--disable-observatory"; |
| 32 const char kTraceStartup[] = "--trace-startup"; | 33 const char kTraceStartup[] = "--trace-startup"; |
| 33 | 34 |
| 34 static bool IsDartZip(std::string url) { | 35 static bool IsDartZip(std::string url) { |
| 35 // If the url doesn't end with ".dart" we assume it is a zipped up | 36 // If the url doesn't end with ".dart" we assume it is a zipped up |
| 36 // dart application. | 37 // dart application. |
| 37 return !EndsWith(url, ".dart", false); | 38 return !EndsWith(url, ".dart", false); |
| 38 } | 39 } |
| 39 | 40 |
| 40 class DartContentHandlerApp; | 41 class DartContentHandlerApp; |
| 41 | 42 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 app->ConnectToService("mojo:url_response_disk_cache", | 116 app->ConnectToService("mojo:url_response_disk_cache", |
| 116 &url_response_disk_cache_); | 117 &url_response_disk_cache_); |
| 117 service_connector_ = new ContentHandlerAppServiceConnector(app); | 118 service_connector_ = new ContentHandlerAppServiceConnector(app); |
| 118 | 119 |
| 119 const char* timeline_arg = nullptr; | 120 const char* timeline_arg = nullptr; |
| 120 int timeline_arg_count = 0; | 121 int timeline_arg_count = 0; |
| 121 if (app->HasArg(kCompleteTimeline)) { | 122 if (app->HasArg(kCompleteTimeline)) { |
| 122 timeline_arg = kCompleteTimeline; | 123 timeline_arg = kCompleteTimeline; |
| 123 timeline_arg_count = 1; | 124 timeline_arg_count = 1; |
| 124 } | 125 } |
| 126 |
| 127 bool observatory_enabled = true; |
| 128 if (app->HasArg(kDisableObservatory)) { |
| 129 observatory_enabled = false; |
| 130 } |
| 125 bool success = mojo::dart::DartController::Initialize( | 131 bool success = mojo::dart::DartController::Initialize( |
| 126 service_connector_, default_strict_, &timeline_arg, timeline_arg_count); | 132 service_connector_, |
| 133 default_strict_, |
| 134 observatory_enabled, |
| 135 &timeline_arg, |
| 136 timeline_arg_count); |
| 127 | 137 |
| 128 if (app->HasArg(kTraceStartup)) { | 138 if (app->HasArg(kTraceStartup)) { |
| 129 DartTimelineController::EnableAll(); | 139 DartTimelineController::EnableAll(); |
| 130 } | 140 } |
| 131 if (!success) { | 141 if (!success) { |
| 132 LOG(ERROR) << "Dart VM Initialization failed"; | 142 LOG(ERROR) << "Dart VM Initialization failed"; |
| 133 } | 143 } |
| 134 } | 144 } |
| 135 | 145 |
| 136 bool HasStrictQueryParam(const std::string& requestedUrl) { | 146 bool HasStrictQueryParam(const std::string& requestedUrl) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 225 |
| 216 } // namespace dart | 226 } // namespace dart |
| 217 | 227 |
| 218 MojoResult MojoMain(MojoHandle application_request) { | 228 MojoResult MojoMain(MojoHandle application_request) { |
| 219 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp); | 229 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp); |
| 220 MojoResult r = runner.Run(application_request); | 230 MojoResult r = runner.Run(application_request); |
| 221 // TODO(johnmccutchan): Remove this once the Dart VM shuts down threads. | 231 // TODO(johnmccutchan): Remove this once the Dart VM shuts down threads. |
| 222 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 232 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 223 return r; | 233 return r; |
| 224 } | 234 } |
| OLD | NEW |