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 18 matching lines...) Expand all Loading... |
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/OnStackObjectChecker.h" | 34 #include "bindings/core/v8/OnStackObjectChecker.h" |
35 #include "bindings/core/v8/ScopedPersistent.h" | 35 #include "bindings/core/v8/ScopedPersistent.h" |
36 #include "bindings/core/v8/ScriptPromise.h" | 36 #include "bindings/core/v8/ScriptPromise.h" |
37 #include "bindings/core/v8/V8ThrowException.h" | 37 #include "bindings/core/v8/V8ThrowException.h" |
38 #include "core/CoreExport.h" | 38 #include "core/CoreExport.h" |
| 39 #include "wtf/Allocator.h" |
39 #include "wtf/Noncopyable.h" | 40 #include "wtf/Noncopyable.h" |
40 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
41 #include <v8.h> | 42 #include <v8.h> |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 typedef int ExceptionCode; | 46 typedef int ExceptionCode; |
46 class ScriptPromiseResolver; | 47 class ScriptPromiseResolver; |
47 class ScriptState; | 48 class ScriptState; |
48 | 49 |
49 class CORE_EXPORT ExceptionState { | 50 class CORE_EXPORT ExceptionState { |
50 WTF_MAKE_NONCOPYABLE(ExceptionState); | 51 WTF_MAKE_NONCOPYABLE(ExceptionState); |
| 52 WTF_MAKE_FAST_ALLOCATED(ExceptionState); |
51 public: | 53 public: |
52 enum Context { | 54 enum Context { |
53 ConstructionContext, | 55 ConstructionContext, |
54 ExecutionContext, | 56 ExecutionContext, |
55 DeletionContext, | 57 DeletionContext, |
56 GetterContext, | 58 GetterContext, |
57 SetterContext, | 59 SetterContext, |
58 EnumerationContext, | 60 EnumerationContext, |
59 QueryContext, | 61 QueryContext, |
60 IndexedGetterContext, | 62 IndexedGetterContext, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ScopedPersistent<v8::Value> m_exception; | 135 ScopedPersistent<v8::Value> m_exception; |
134 v8::Local<v8::Object> m_creationContext; | 136 v8::Local<v8::Object> m_creationContext; |
135 v8::Isolate* m_isolate; | 137 v8::Isolate* m_isolate; |
136 #if ENABLE(ASSERT) | 138 #if ENABLE(ASSERT) |
137 OnStackObjectChecker m_onStackObjectChecker; | 139 OnStackObjectChecker m_onStackObjectChecker; |
138 #endif | 140 #endif |
139 }; | 141 }; |
140 | 142 |
141 // Used if exceptions can/should not be directly thrown. | 143 // Used if exceptions can/should not be directly thrown. |
142 class CORE_EXPORT NonThrowableExceptionState final : public ExceptionState { | 144 class CORE_EXPORT NonThrowableExceptionState final : public ExceptionState { |
| 145 WTF_MAKE_NONCOPYABLE(NonThrowableExceptionState); |
143 public: | 146 public: |
144 NonThrowableExceptionState(): ExceptionState(ExceptionState::UnknownContext,
0, 0, v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } | 147 NonThrowableExceptionState(): ExceptionState(ExceptionState::UnknownContext,
0, 0, v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } |
145 void throwDOMException(const ExceptionCode&, const String& message) override
; | 148 void throwDOMException(const ExceptionCode&, const String& message) override
; |
146 void throwTypeError(const String& message = String()) override; | 149 void throwTypeError(const String& message = String()) override; |
147 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; | 150 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; |
148 void throwRangeError(const String& message) override; | 151 void throwRangeError(const String& message) override; |
149 }; | 152 }; |
150 | 153 |
151 // Used if any exceptions thrown are ignorable. | 154 // Used if any exceptions thrown are ignorable. |
152 class CORE_EXPORT TrackExceptionState final : public ExceptionState { | 155 class CORE_EXPORT TrackExceptionState final : public ExceptionState { |
| 156 WTF_MAKE_NONCOPYABLE(TrackExceptionState); |
153 public: | 157 public: |
154 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0,
v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } | 158 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0,
v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } |
155 void throwDOMException(const ExceptionCode&, const String& message) override
; | 159 void throwDOMException(const ExceptionCode&, const String& message) override
; |
156 void throwTypeError(const String& message = String()) override; | 160 void throwTypeError(const String& message = String()) override; |
157 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; | 161 void throwSecurityError(const String& sanitizedMessage, const String& unsani
tizedMessage = String()) override; |
158 void throwRangeError(const String& message) override; | 162 void throwRangeError(const String& message) override; |
159 }; | 163 }; |
160 | 164 |
161 } // namespace blink | 165 } // namespace blink |
162 | 166 |
163 #endif // ExceptionState_h | 167 #endif // ExceptionState_h |
OLD | NEW |