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

Side by Side Diff: services/dart/content_handler_main.cc

Issue 1688793002: Fix shutdown race when running Dart on the message loop (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | tonic/dart_message_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_split.h" 8 #include "base/strings/string_split.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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 public: 133 public:
134 DartContentHandlerApp() 134 DartContentHandlerApp()
135 : content_handler_(this, false), 135 : content_handler_(this, false),
136 strict_content_handler_(this, true), 136 strict_content_handler_(this, true),
137 content_handler_factory_(&content_handler_), 137 content_handler_factory_(&content_handler_),
138 strict_content_handler_factory_(&strict_content_handler_), 138 strict_content_handler_factory_(&strict_content_handler_),
139 service_connector_(nullptr), 139 service_connector_(nullptr),
140 default_strict_(false), 140 default_strict_(false),
141 run_on_message_loop_(false) {} 141 run_on_message_loop_(false) {}
142 142
143 ~DartContentHandlerApp() override {} 143 ~DartContentHandlerApp() override {
144 // Shutdown the controller.
145 mojo::dart::DartController::Shutdown();
146 delete service_connector_;
147 }
144 148
145 void ExtractApplication(base::FilePath* application_dir, 149 void ExtractApplication(base::FilePath* application_dir,
146 mojo::URLResponsePtr response, 150 mojo::URLResponsePtr response,
147 const base::Closure& callback) { 151 const base::Closure& callback) {
148 url_response_disk_cache_->UpdateAndGetExtracted( 152 url_response_disk_cache_->UpdateAndGetExtracted(
149 response.Pass(), 153 response.Pass(),
150 [application_dir, callback](mojo::Array<uint8_t> application_dir_path, 154 [application_dir, callback](mojo::Array<uint8_t> application_dir_path,
151 mojo::Array<uint8_t> cache_path) { 155 mojo::Array<uint8_t> cache_path) {
152 if (application_dir_path.is_null()) { 156 if (application_dir_path.is_null()) {
153 *application_dir = base::FilePath(); 157 *application_dir = base::FilePath();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 mojo::ApplicationConnection* connection) override { 239 mojo::ApplicationConnection* connection) override {
236 bool strict = HasStrictQueryParam(connection->GetConnectionURL()); 240 bool strict = HasStrictQueryParam(connection->GetConnectionURL());
237 if (default_strict_ || strict) { 241 if (default_strict_ || strict) {
238 connection->AddService(&strict_content_handler_factory_); 242 connection->AddService(&strict_content_handler_factory_);
239 } else { 243 } else {
240 connection->AddService(&content_handler_factory_); 244 connection->AddService(&content_handler_factory_);
241 } 245 }
242 return true; 246 return true;
243 } 247 }
244 248
245 // Overridden from ApplicationDelegate:
246 void Quit() override {
247 // Shutdown the controller.
248 mojo::dart::DartController::Shutdown();
249 delete service_connector_;
250 }
251
252 mojo::TracingImpl tracing_; 249 mojo::TracingImpl tracing_;
253 DartContentHandler content_handler_; 250 DartContentHandler content_handler_;
254 DartContentHandler strict_content_handler_; 251 DartContentHandler strict_content_handler_;
255 mojo::ContentHandlerFactory content_handler_factory_; 252 mojo::ContentHandlerFactory content_handler_factory_;
256 mojo::ContentHandlerFactory strict_content_handler_factory_; 253 mojo::ContentHandlerFactory strict_content_handler_factory_;
257 mojo::URLResponseDiskCachePtr url_response_disk_cache_; 254 mojo::URLResponseDiskCachePtr url_response_disk_cache_;
258 ContentHandlerAppServiceConnector* service_connector_; 255 ContentHandlerAppServiceConnector* service_connector_;
259 DartTracingImpl dart_tracing_; 256 DartTracingImpl dart_tracing_;
260 bool default_strict_; 257 bool default_strict_;
261 bool run_on_message_loop_; 258 bool run_on_message_loop_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 pause_isolates_on_exit)); 321 pause_isolates_on_exit));
325 } 322 }
326 } 323 }
327 324
328 } // namespace dart 325 } // namespace dart
329 326
330 MojoResult MojoMain(MojoHandle application_request) { 327 MojoResult MojoMain(MojoHandle application_request) {
331 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp); 328 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp);
332 return runner.Run(application_request); 329 return runner.Run(application_request);
333 } 330 }
OLDNEW
« no previous file with comments | « no previous file | tonic/dart_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698