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

Side by Side Diff: mojo/dart/embedder/dart_controller.cc

Issue 996923003: Dart: Better handle leak checks. close() is async. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
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/callback.h" 5 #include "base/callback.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "crypto/random.h" 10 #include "crypto/random.h"
11 #include "dart/runtime/include/dart_api.h" 11 #include "dart/runtime/include/dart_api.h"
12 #include "dart/runtime/include/dart_native_api.h" 12 #include "dart/runtime/include/dart_native_api.h"
13 #include "mojo/dart/embedder/builtin.h" 13 #include "mojo/dart/embedder/builtin.h"
14 #include "mojo/dart/embedder/dart_controller.h" 14 #include "mojo/dart/embedder/dart_controller.h"
15 #include "mojo/dart/embedder/isolate_data.h" 15 #include "mojo/dart/embedder/isolate_data.h"
16 #include "mojo/public/c/system/core.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace dart { 19 namespace dart {
19 20
20 extern const uint8_t* snapshot_buffer; 21 extern const uint8_t* snapshot_buffer;
21 22
22 const char* kDartScheme = "dart:"; 23 const char* kDartScheme = "dart:";
23 const char* kMojoScheme = "mojo:"; 24 const char* kMojoScheme = "mojo:";
24 const char* kAsyncLibURL = "dart:async"; 25 const char* kAsyncLibURL = "dart:async";
25 const char* kInternalLibURL = "dart:_internal"; 26 const char* kInternalLibURL = "dart:_internal";
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 423
423 static void UnhandledExceptionCallback(Dart_Handle error) { 424 static void UnhandledExceptionCallback(Dart_Handle error) {
424 Dart_Isolate isolate = Dart_CurrentIsolate(); 425 Dart_Isolate isolate = Dart_CurrentIsolate();
425 void* data = Dart_IsolateData(isolate); 426 void* data = Dart_IsolateData(isolate);
426 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(data); 427 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(data);
427 if (!isolate_data->callbacks.exception.is_null()) { 428 if (!isolate_data->callbacks.exception.is_null()) {
428 // TODO(zra): Instead of passing an error handle, it may make life easier 429 // TODO(zra): Instead of passing an error handle, it may make life easier
429 // for clients if we pass any error string here instead. 430 // for clients if we pass any error string here instead.
430 isolate_data->callbacks.exception.Run(error); 431 isolate_data->callbacks.exception.Run(error);
431 } 432 }
433
434 // Close handles generated by the isolate.
435 std::set<int64_t>& handles = isolate_data->unclosed_handles;
436 for (auto it = handles.begin(); it != handles.end(); ++it) {
437 MojoClose(static_cast<MojoHandle>(*it));
438 }
439 handles.clear();
432 } 440 }
433 441
434 442
435 bool DartController::initialized_ = false; 443 bool DartController::initialized_ = false;
436 Dart_Isolate DartController::root_isolate_ = nullptr; 444 Dart_Isolate DartController::root_isolate_ = nullptr;
437 bool DartController::strict_compilation_ = false; 445 bool DartController::strict_compilation_ = false;
438 446
439 void DartController::InitVmIfNeeded(Dart_EntropySource entropy, 447 void DartController::InitVmIfNeeded(Dart_EntropySource entropy,
440 const char** arguments, 448 const char** arguments,
441 int arguments_count) { 449 int arguments_count) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 735
728 Dart_ExitScope(); 736 Dart_ExitScope();
729 Dart_ShutdownIsolate(); 737 Dart_ShutdownIsolate();
730 Dart_Cleanup(); 738 Dart_Cleanup();
731 root_isolate_ = nullptr; 739 root_isolate_ = nullptr;
732 initialized_ = false; 740 initialized_ = false;
733 } 741 }
734 742
735 } // namespace apps 743 } // namespace apps
736 } // namespace mojo 744 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698