Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ExceptionState.h

Issue 2272313003: binding: Makes ExceptionState STACK_ALLOCATED(). (Closed)
Patch Set: . Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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/OnStackObjectChecker.h"
35 #include "bindings/core/v8/ScopedPersistent.h" 34 #include "bindings/core/v8/ScopedPersistent.h"
36 #include "bindings/core/v8/ScriptPromise.h" 35 #include "bindings/core/v8/ScriptPromise.h"
37 #include "bindings/core/v8/V8ThrowException.h" 36 #include "bindings/core/v8/V8ThrowException.h"
38 #include "core/CoreExport.h" 37 #include "core/CoreExport.h"
39 #include "wtf/Allocator.h" 38 #include "wtf/Allocator.h"
40 #include "wtf/Noncopyable.h" 39 #include "wtf/Noncopyable.h"
41 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
42 #include <v8.h> 41 #include <v8.h>
43 42
44 namespace blink { 43 namespace blink {
45 44
46 typedef int ExceptionCode; 45 typedef int ExceptionCode;
47 class ScriptPromiseResolver; 46 class ScriptPromiseResolver;
48 class ScriptState; 47 class ScriptState;
49 48
50 class CORE_EXPORT ExceptionState { 49 class CORE_EXPORT ExceptionState {
50 STACK_ALLOCATED();
51 WTF_MAKE_NONCOPYABLE(ExceptionState); 51 WTF_MAKE_NONCOPYABLE(ExceptionState);
52 USING_FAST_MALLOC(ExceptionState);
53 public: 52 public:
54 enum ContextType { 53 enum ContextType {
55 ConstructionContext, 54 ConstructionContext,
56 ExecutionContext, 55 ExecutionContext,
57 DeletionContext, 56 DeletionContext,
58 GetterContext, 57 GetterContext,
59 SetterContext, 58 SetterContext,
60 EnumerationContext, 59 EnumerationContext,
61 QueryContext, 60 QueryContext,
62 IndexedGetterContext, 61 IndexedGetterContext,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const char* interfaceName() const { return m_interfaceName; } 125 const char* interfaceName() const { return m_interfaceName; }
127 126
128 void rethrowV8Exception(v8::Local<v8::Value> value) 127 void rethrowV8Exception(v8::Local<v8::Value> value)
129 { 128 {
130 setException(value); 129 setException(value);
131 } 130 }
132 131
133 // Might return nullptr. 132 // Might return nullptr.
134 v8::Isolate* isolate() const { return m_isolate; } 133 v8::Isolate* isolate() const { return m_isolate; }
135 134
136 #if ENABLE(ASSERT)
137 OnStackObjectChecker& getOnStackObjectChecker() { return m_onStackObjectChec ker; }
138 #endif
139
140 protected: 135 protected:
141 ExceptionCode m_code; 136 ExceptionCode m_code;
142 ContextType m_context; 137 ContextType m_context;
143 String m_message; 138 String m_message;
144 const char* m_propertyName; 139 const char* m_propertyName;
145 const char* m_interfaceName; 140 const char* m_interfaceName;
146 141
147 private: 142 private:
148 void setException(v8::Local<v8::Value>); 143 void setException(v8::Local<v8::Value>);
149 void throwException(); 144 void throwException();
150 145
151 String addExceptionContext(const String&) const; 146 String addExceptionContext(const String&) const;
152 147
153 ScopedPersistent<v8::Value> m_exception; 148 ScopedPersistent<v8::Value> m_exception;
154 v8::Isolate* m_isolate; 149 v8::Isolate* m_isolate;
155 #if ENABLE(ASSERT)
156 OnStackObjectChecker m_onStackObjectChecker;
157 #endif
158 }; 150 };
159 151
160 // Used if exceptions can/should not be directly thrown. 152 // Used if exceptions can/should not be directly thrown.
161 class CORE_EXPORT NonThrowableExceptionState final : public ExceptionState { 153 class CORE_EXPORT NonThrowableExceptionState final : public ExceptionState {
162 WTF_MAKE_NONCOPYABLE(NonThrowableExceptionState); 154 WTF_MAKE_NONCOPYABLE(NonThrowableExceptionState);
163 public: 155 public:
164 NonThrowableExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } 156 NonThrowableExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { }
165 void throwDOMException(const ExceptionCode&, const String& message) override ; 157 void throwDOMException(const ExceptionCode&, const String& message) override ;
166 void throwTypeError(const String& message = String()) override; 158 void throwTypeError(const String& message = String()) override;
167 void throwSecurityError(const String& sanitizedMessage, const String& unsani tizedMessage = String()) override; 159 void throwSecurityError(const String& sanitizedMessage, const String& unsani tizedMessage = String()) override;
168 void throwRangeError(const String& message) override; 160 void throwRangeError(const String& message) override;
169 }; 161 };
170 162
171 // Used if any exceptions thrown are ignorable. 163 // Used if any exceptions thrown are ignorable.
172 class CORE_EXPORT TrackExceptionState final : public ExceptionState { 164 class CORE_EXPORT TrackExceptionState final : public ExceptionState {
173 WTF_MAKE_NONCOPYABLE(TrackExceptionState); 165 WTF_MAKE_NONCOPYABLE(TrackExceptionState);
174 public: 166 public:
175 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { } 167 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Local<v8::Object>(), v8::Isolate::GetCurrent()) { }
176 void throwDOMException(const ExceptionCode&, const String& message) override ; 168 void throwDOMException(const ExceptionCode&, const String& message) override ;
177 void throwTypeError(const String& message = String()) override; 169 void throwTypeError(const String& message = String()) override;
178 void throwSecurityError(const String& sanitizedMessage, const String& unsani tizedMessage = String()) override; 170 void throwSecurityError(const String& sanitizedMessage, const String& unsani tizedMessage = String()) override;
179 void throwRangeError(const String& message) override; 171 void throwRangeError(const String& message) override;
180 }; 172 };
181 173
182 } // namespace blink 174 } // namespace blink
183 175
184 #endif // ExceptionState_h 176 #endif // ExceptionState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698