Chromium Code Reviews| 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(); |
| } |