| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_ | |
| 6 #define SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_ | |
| 7 | |
| 8 #include "sky/engine/tonic/dart_persistent_value.h" | |
| 9 #include "sky/engine/wtf/Noncopyable.h" | |
| 10 #include "sky/engine/wtf/text/WTFString.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 typedef int ExceptionCode; | |
| 15 | |
| 16 class ExceptionState { | |
| 17 WTF_MAKE_NONCOPYABLE(ExceptionState); | |
| 18 | |
| 19 public: | |
| 20 enum Context { | |
| 21 ConstructionContext, | |
| 22 ExecutionContext, | |
| 23 DeletionContext, | |
| 24 GetterContext, | |
| 25 SetterContext, | |
| 26 EnumerationContext, | |
| 27 QueryContext, | |
| 28 IndexedGetterContext, | |
| 29 IndexedSetterContext, | |
| 30 IndexedDeletionContext, | |
| 31 UnknownContext, // FIXME: Remove this once we've flipped over to the new | |
| 32 // API. | |
| 33 }; | |
| 34 | |
| 35 ExceptionState(); | |
| 36 ExceptionState(Context context, const char* interfaceName); | |
| 37 ExceptionState(Context context, | |
| 38 const char* propertyName, | |
| 39 const char* interfaceName); | |
| 40 ~ExceptionState(); | |
| 41 | |
| 42 void ThrowDOMException(const ExceptionCode& code, const String& message); | |
| 43 void ThrowTypeError(const String& message); | |
| 44 void ThrowRangeError(const String& message); | |
| 45 | |
| 46 bool ThrowIfNeeded(); | |
| 47 void ClearException(); | |
| 48 | |
| 49 ExceptionCode code() const { return code_; } | |
| 50 const String& message() const { return message_; } | |
| 51 bool had_exception() const { return had_exception_ || code_; } | |
| 52 | |
| 53 Dart_Handle GetDartException(Dart_NativeArguments args, bool auto_scope); | |
| 54 | |
| 55 private: | |
| 56 ExceptionCode code_; | |
| 57 String message_; | |
| 58 bool had_exception_; | |
| 59 DartPersistentValue exception_; | |
| 60 }; | |
| 61 | |
| 62 class NonThrowableExceptionState final : public ExceptionState {}; | |
| 63 | |
| 64 class TrackExceptionState final : public ExceptionState {}; | |
| 65 | |
| 66 } // namespace blink | |
| 67 | |
| 68 #endif // SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_ | |
| OLD | NEW |