| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ExceptionStatePlaceholder_h | 31 #ifndef ExceptionStatePlaceholder_h |
| 32 #define ExceptionStatePlaceholder_h | 32 #define ExceptionStatePlaceholder_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
| 36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
| 37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 38 #include <v8.h> | |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 class ExceptionState; | |
| 43 | |
| 44 typedef int ExceptionCode; | |
| 45 | |
| 46 class IgnorableExceptionState final : public ExceptionState { | 41 class IgnorableExceptionState final : public ExceptionState { |
| 47 WTF_MAKE_NONCOPYABLE(IgnorableExceptionState); | 42 WTF_MAKE_NONCOPYABLE(IgnorableExceptionState); |
| 48 public: | 43 public: |
| 49 IgnorableExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0,
0, v8::Local<v8::Object>(), 0) { } | 44 IgnorableExceptionState() |
| 45 : ExceptionState(nullptr, ExceptionState::UnknownContext, nullptr, nullp
tr) { } |
| 46 |
| 50 ExceptionState& returnThis() { return *this; } | 47 ExceptionState& returnThis() { return *this; } |
| 51 void throwDOMException(const ExceptionCode&, const String& message = String(
)) override { } | 48 |
| 52 void throwTypeError(const String& message = String()) override { } | 49 void throwDOMException(const ExceptionCode&, const String& message) override
{ } |
| 53 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override { } | 50 void throwRangeError(const String& message) override { }; |
| 51 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage) override { } |
| 52 void throwTypeError(const String& message) override { } |
| 53 void rethrowV8Exception(v8::Local<v8::Value>) override { }; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 #define IGNORE_EXCEPTION (::blink::IgnorableExceptionState().returnThis()) | 56 #define IGNORE_EXCEPTION (::blink::IgnorableExceptionState().returnThis()) |
| 57 | 57 |
| 58 #if ENABLE(ASSERT) | 58 #if ENABLE(ASSERT) |
| 59 | 59 |
| 60 class CORE_EXPORT NoExceptionStateAssertionChecker final : public ExceptionState
{ | 60 class CORE_EXPORT NoExceptionStateAssertionChecker final : public ExceptionState
{ |
| 61 WTF_MAKE_NONCOPYABLE(NoExceptionStateAssertionChecker); | 61 WTF_MAKE_NONCOPYABLE(NoExceptionStateAssertionChecker); |
| 62 public: | 62 public: |
| 63 NoExceptionStateAssertionChecker(const char* file, int line); | 63 NoExceptionStateAssertionChecker(const char* file, int line); |
| 64 |
| 64 ExceptionState& returnThis() { return *this; } | 65 ExceptionState& returnThis() { return *this; } |
| 65 void throwDOMException(const ExceptionCode&, const String& message = String(
)) override; | 66 |
| 66 void throwTypeError(const String& message = String()) override; | 67 void throwDOMException(const ExceptionCode&, const String& message) override
; |
| 67 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; | 68 void throwRangeError(const String& message) override; |
| 69 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage) override; |
| 70 void throwTypeError(const String& message) override; |
| 71 void rethrowV8Exception(v8::Local<v8::Value>) override; |
| 68 | 72 |
| 69 private: | 73 private: |
| 70 const char* m_file; | 74 const char* m_file; |
| 71 int m_line; | 75 const int m_line; |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 #define ASSERT_NO_EXCEPTION (::blink::NoExceptionStateAssertionChecker(__FILE__,
__LINE__).returnThis()) | 78 #define ASSERT_NO_EXCEPTION (::blink::NoExceptionStateAssertionChecker(__FILE__,
__LINE__).returnThis()) |
| 75 | 79 |
| 76 #else | 80 #else |
| 77 | 81 |
| 78 #define ASSERT_NO_EXCEPTION (::blink::IgnorableExceptionState().returnThis()) | 82 #define ASSERT_NO_EXCEPTION (::blink::IgnorableExceptionState().returnThis()) |
| 79 | 83 |
| 80 #endif | 84 #endif |
| 81 | 85 |
| 82 } // namespace blink | 86 } // namespace blink |
| 83 | 87 |
| 84 #endif // ExceptionStatePlaceholder_h | 88 #endif // ExceptionStatePlaceholder_h |
| OLD | NEW |