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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 ExceptionState_h | 31 #ifndef ExceptionState_h |
32 #define ExceptionState_h | 32 #define ExceptionState_h |
33 | 33 |
34 #include "bindings/core/v8/ScopedPersistent.h" | 34 #include "bindings/core/v8/ScopedPersistent.h" |
| 35 #include "bindings/core/v8/ScriptPromise.h" |
35 #include "bindings/core/v8/V8ThrowException.h" | 36 #include "bindings/core/v8/V8ThrowException.h" |
36 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
37 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
38 #include <v8.h> | 39 #include <v8.h> |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 typedef int ExceptionCode; | 43 typedef int ExceptionCode; |
| 44 class ScriptState; |
43 | 45 |
44 class ExceptionState { | 46 class ExceptionState { |
45 WTF_MAKE_NONCOPYABLE(ExceptionState); | 47 WTF_MAKE_NONCOPYABLE(ExceptionState); |
46 public: | 48 public: |
47 enum Context { | 49 enum Context { |
48 ConstructionContext, | 50 ConstructionContext, |
49 ExecutionContext, | 51 ExecutionContext, |
50 DeletionContext, | 52 DeletionContext, |
51 GetterContext, | 53 GetterContext, |
52 SetterContext, | 54 SetterContext, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const String& message() const { return m_message; } | 88 const String& message() const { return m_message; } |
87 | 89 |
88 bool throwIfNeeded() | 90 bool throwIfNeeded() |
89 { | 91 { |
90 if (!hadException()) | 92 if (!hadException()) |
91 return false; | 93 return false; |
92 throwException(); | 94 throwException(); |
93 return true; | 95 return true; |
94 } | 96 } |
95 | 97 |
| 98 // This method clears out the exception which |this| has. |
| 99 ScriptPromise reject(ScriptState*); |
| 100 |
96 Context context() const { return m_context; } | 101 Context context() const { return m_context; } |
97 const char* propertyName() const { return m_propertyName; } | 102 const char* propertyName() const { return m_propertyName; } |
98 const char* interfaceName() const { return m_interfaceName; } | 103 const char* interfaceName() const { return m_interfaceName; } |
99 | 104 |
100 void rethrowV8Exception(v8::Handle<v8::Value> value) | 105 void rethrowV8Exception(v8::Handle<v8::Value> value) |
101 { | 106 { |
102 setException(value); | 107 setException(value); |
103 } | 108 } |
104 | 109 |
105 protected: | 110 protected: |
(...skipping 30 matching lines...) Expand all Loading... |
136 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0,
v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { } | 141 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0,
v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { } |
137 virtual void throwDOMException(const ExceptionCode&, const String& message)
OVERRIDE; | 142 virtual void throwDOMException(const ExceptionCode&, const String& message)
OVERRIDE; |
138 virtual void throwTypeError(const String& message = String()) OVERRIDE; | 143 virtual void throwTypeError(const String& message = String()) OVERRIDE; |
139 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()) OVERRIDE; | 144 virtual void throwSecurityError(const String& sanitizedMessage, const String
& unsanitizedMessage = String()) OVERRIDE; |
140 virtual void throwRangeError(const String& message) OVERRIDE; | 145 virtual void throwRangeError(const String& message) OVERRIDE; |
141 }; | 146 }; |
142 | 147 |
143 } // namespace blink | 148 } // namespace blink |
144 | 149 |
145 #endif // ExceptionState_h | 150 #endif // ExceptionState_h |
OLD | NEW |