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

Unified Diff: mojo/dart/embedder/dart_controller.cc

Issue 1411843005: Dart: Removes C++ set for closing handles on an unhandled exception. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Format Created 5 years, 2 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 | « no previous file | mojo/dart/embedder/mojo_dart_state.h » ('j') | mojo/dart/embedder/test/run_dart_tests.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/embedder/dart_controller.cc
diff --git a/mojo/dart/embedder/dart_controller.cc b/mojo/dart/embedder/dart_controller.cc
index 16f4858dd8e16afb7f233c866856f20186382d07..8adde7e09d449b76200b4a394050e6885a7be126 100644
--- a/mojo/dart/embedder/dart_controller.cc
+++ b/mojo/dart/embedder/dart_controller.cc
@@ -258,8 +258,12 @@ static void RunIsolate(Dart_Isolate isolate,
DART_CHECK_VALID(result);
result = Dart_RunLoop();
+
+ // Here we log the error, but we don't do DART_CHECK_VALID because we don't
+ // want to bring the whole process down due to an error in application code,
+ // whereas above we do want to bring the whole process down for a bug in
+ // library or generated code.
tonic::LogIfError(result);
- DART_CHECK_VALID(result);
}
Dart_Handle DartController::LibraryTagHandler(Dart_LibraryTag tag,
@@ -444,19 +448,29 @@ void DartController::IsolateShutdownCallback(void* callback_data) {
}
void DartController::UnhandledExceptionCallback(Dart_Handle error) {
+ Dart_Handle mojo_core_lib =
+ Builtin::GetLibrary(Builtin::kMojoInternalLibrary);
+ DART_CHECK_VALID(mojo_core_lib);
+ Dart_Handle handle_natives_type =
+ Dart_GetType(mojo_core_lib,
+ Dart_NewStringFromCString("MojoHandleNatives"), 0, nullptr);
+ DART_CHECK_VALID(handle_natives_type);
+ Dart_Handle method_name = Dart_NewStringFromCString("_closeUnclosedHandles");
+ CHECK(!Dart_IsError(method_name));
+ Dart_Handle result =
+ Dart_Invoke(handle_natives_type, method_name, 0, nullptr);
+ DART_CHECK_VALID(result);
+
auto isolate_data = MojoDartState::Current();
if (!isolate_data->callbacks().exception.is_null()) {
+ int64_t handles_closed = 0;
+ Dart_Handle int_result = Dart_IntegerToInt64(result, &handles_closed);
+ DART_CHECK_VALID(int_result);
+
// TODO(zra): Instead of passing an error handle, it may make life easier
Cutch 2015/10/26 17:10:03 Is this TODO still relevant?
zra 2015/10/26 17:53:54 No. Removed.
// for clients if we pass any error string here instead.
- isolate_data->callbacks().exception.Run(error);
- }
-
- // Close handles generated by the isolate.
- std::set<MojoHandle>& handles = isolate_data->unclosed_handles();
- for (auto it = handles.begin(); it != handles.end(); ++it) {
- MojoClose((*it));
+ isolate_data->callbacks().exception.Run(error, handles_closed);
}
- handles.clear();
}
« no previous file with comments | « no previous file | mojo/dart/embedder/mojo_dart_state.h » ('j') | mojo/dart/embedder/test/run_dart_tests.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698