Index: third_party/WebKit/Source/bindings/core/v8/GeneratedCodeHelper.h |
diff --git a/third_party/WebKit/Source/bindings/core/v8/GeneratedCodeHelper.h b/third_party/WebKit/Source/bindings/core/v8/GeneratedCodeHelper.h |
index 2bb7093baae50d29d70e7939b8a5b4ae93076732..c5e4af685149c1bb73766029d332e00b29acfdf1 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/GeneratedCodeHelper.h |
+++ b/third_party/WebKit/Source/bindings/core/v8/GeneratedCodeHelper.h |
@@ -11,18 +11,54 @@ |
#ifndef GeneratedCodeHelper_h |
#define GeneratedCodeHelper_h |
+#include "bindings/core/v8/ExceptionState.h" |
+#include "bindings/core/v8/V8Binding.h" |
#include "core/CoreExport.h" |
#include "wtf/PassRefPtr.h" |
#include <v8.h> |
namespace blink { |
+class ScriptState; |
class SerializedScriptValue; |
CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&); |
CORE_EXPORT v8::Local<v8::Value> v8Deserialize(v8::Isolate*, PassRefPtr<SerializedScriptValue>); |
+// Throws an arity error of type TypeError. |
+CORE_EXPORT void throwMinimumArityError(ExceptionState&, unsigned expected, unsigned actual); |
+CORE_EXPORT void throwInvalidArityError(ExceptionState&, const char* validRange, unsigned actual); |
+CORE_EXPORT void throwMinimumArityErrorForMethod(v8::Isolate*, const char* interface, const char* method, unsigned expected, unsigned actual); |
+CORE_EXPORT void throwMinimumArityErrorForConstructor(v8::Isolate*, const char* interface, unsigned expected, unsigned actual); |
+ |
+// ExceptionToPromiseScope converts a possible exception to a reject promise |
+// and returns the promise instead of throwing the exception. |
+// |
+// Promise-returning DOM operations are required to always return a promise |
+// and to never throw an exception. |
+// See also http://heycam.github.io/webidl/#es-operations |
+class CORE_EXPORT ExceptionToPromiseScope { |
haraken
2016/09/02 16:24:13
I still don't understand what GeneratedCodeHelper
Yuki
2016/09/05 07:19:25
I don't expect that this will be used in such a ma
haraken
2016/09/05 08:24:22
I'm confused...
Note that the logic ExceptionToPr
|
+ STACK_ALLOCATED(); |
+public: |
+ ExceptionToPromiseScope(const v8::FunctionCallbackInfo<v8::Value>& info, ScriptState* scriptState, ExceptionState& exceptionState) |
haraken
2016/09/02 16:24:13
Would it make more sense to introduce another cons
Yuki
2016/09/05 07:19:25
I don't think so. ExceptionToPromiseScope depends
haraken
2016/09/05 08:24:22
As I mentioned above, this functionality is implem
|
+ : m_info(info) |
+ , m_scriptState(scriptState) |
+ , m_exceptionState(exceptionState) { } |
+ ~ExceptionToPromiseScope() |
+ { |
+ if (!m_exceptionState.hadException()) |
+ return; |
+ |
+ v8SetReturnValue(m_info, m_exceptionState.reject(m_scriptState).v8Value()); |
+ } |
+ |
+private: |
+ const v8::FunctionCallbackInfo<v8::Value>& m_info; |
+ ScriptState* m_scriptState; |
+ ExceptionState& m_exceptionState; |
+}; |
+ |
} // namespace blink |
#endif // GeneratedCodeHelper_h |