Chromium Code Reviews| Index: sky/engine/tonic/dart_exception_factory.cc |
| diff --git a/sky/engine/tonic/dart_exception_factory.cc b/sky/engine/tonic/dart_exception_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..52b57092792c306ad638e3a4b12268390a722e4f |
| --- /dev/null |
| +++ b/sky/engine/tonic/dart_exception_factory.cc |
| @@ -0,0 +1,34 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "sky/engine/config.h" |
| +#include "sky/engine/tonic/dart_exception_factory.h" |
| + |
| +#include "sky/engine/tonic/dart_converter.h" |
| +#include "sky/engine/tonic/dart_builtin.h" |
| + |
| +namespace blink { |
| + |
| +DartExceptionFactory::DartExceptionFactory(DartState* dart_state) |
| + : dart_state_(dart_state) { |
| +} |
| + |
| +DartExceptionFactory::~DartExceptionFactory() { |
| +} |
| + |
| +Dart_Handle DartExceptionFactory::CreateException(const String& class_name, |
| + const String& message) { |
| + if (core_library_.is_empty()) { |
| + Dart_Handle library = DartBuiltin::LookupLibrary("dart:core"); |
| + core_library_.Set(dart_state_, library); |
| + } |
| + |
| + Dart_Handle exception_class = Dart_GetType( |
| + core_library_.value(), StringToDart(dart_state_, class_name), 0, 0); |
| + Dart_Handle message_handle = StringToDart(dart_state_, message); |
| + Dart_Handle empty_string = Dart_NewStringFromCString(""); |
|
esprehn
2015/02/17 18:06:53
Do we want a shared per isolate empty string? Exce
abarth-chromium
2015/02/17 18:14:05
It looks like Dart_NewStringFromCString("") is rel
|
| + return Dart_New(exception_class, empty_string, 1, &message_handle); |
| +} |
| + |
| +} // namespace blink |