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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // resolved with |value|. | 112 // resolved with |value|. |
113 // Returns |value| itself if it is a Promise. | 113 // Returns |value| itself if it is a Promise. |
114 static ScriptPromise cast(ScriptState*, const ScriptValue& /*value*/); | 114 static ScriptPromise cast(ScriptState*, const ScriptValue& /*value*/); |
115 static ScriptPromise cast(ScriptState*, v8::Handle<v8::Value> /*value*/); | 115 static ScriptPromise cast(ScriptState*, v8::Handle<v8::Value> /*value*/); |
116 | 116 |
117 static ScriptPromise reject(ScriptState*, const ScriptValue&); | 117 static ScriptPromise reject(ScriptState*, const ScriptValue&); |
118 static ScriptPromise reject(ScriptState*, v8::Handle<v8::Value>); | 118 static ScriptPromise reject(ScriptState*, v8::Handle<v8::Value>); |
119 | 119 |
120 static ScriptPromise rejectWithDOMException(ScriptState*, PassRefPtrWillBeRa
wPtr<DOMException>); | 120 static ScriptPromise rejectWithDOMException(ScriptState*, PassRefPtrWillBeRa
wPtr<DOMException>); |
121 | 121 |
122 // static functions each of which returns a ScriptPromise rejected with | |
123 // the given error. | |
124 // They coresspond to functions in V8Binding.h, such as throwError, | |
125 // throwTypeError, etc. | |
126 // FIXME: Remove these functions. | |
127 static ScriptPromise rejectWithTypeError(ScriptState*, const String&); | |
128 static ScriptPromise rejectWithArityTypeErrorForMethod(ScriptState*, const c
har* method, const char* type, const char* valid, unsigned provided); | |
129 static ScriptPromise rejectWithArityTypeErrorForConstructor(ScriptState*, co
nst char* type, const char* valid, unsigned provided); | |
130 static ScriptPromise rejectWithArityTypeError(ScriptState*, ExceptionState&,
const char* valid, unsigned provided); | |
131 static ScriptPromise rejectWithMinimumArityTypeErrorForMethod( | |
132 ScriptState*, const char* method, const char* type, unsigned expected, u
nsigned providedLeastNumMandatoryParams); | |
133 static ScriptPromise rejectWithMinimumArityTypeErrorForConstructor( | |
134 ScriptState*, const char* type, unsigned expected, unsigned providedLeas
tNumMandatoryParams); | |
135 static ScriptPromise rejectWithMinimumArityTypeError(ScriptState*, Exception
State&, unsigned expected, unsigned providedLeastNumMandatoryParams); | |
136 | |
137 static v8::Local<v8::Promise> rejectRaw(v8::Isolate*, v8::Handle<v8::Value>)
; | 122 static v8::Local<v8::Promise> rejectRaw(v8::Isolate*, v8::Handle<v8::Value>)
; |
138 | 123 |
139 // This is a utility class intended to be used internally. | 124 // This is a utility class intended to be used internally. |
140 // ScriptPromiseResolver is for general purpose. | 125 // ScriptPromiseResolver is for general purpose. |
141 class InternalResolver FINAL { | 126 class InternalResolver FINAL { |
142 public: | 127 public: |
143 explicit InternalResolver(ScriptState*); | 128 explicit InternalResolver(ScriptState*); |
144 v8::Local<v8::Promise> v8Promise() const; | 129 v8::Local<v8::Promise> v8Promise() const; |
145 ScriptPromise promise() const; | 130 ScriptPromise promise() const; |
146 void resolve(v8::Local<v8::Value>); | 131 void resolve(v8::Local<v8::Value>); |
147 void reject(v8::Local<v8::Value>); | 132 void reject(v8::Local<v8::Value>); |
148 void clear() { m_resolver.clear(); } | 133 void clear() { m_resolver.clear(); } |
149 | 134 |
150 private: | 135 private: |
151 ScriptValue m_resolver; | 136 ScriptValue m_resolver; |
152 }; | 137 }; |
153 | 138 |
154 private: | 139 private: |
155 RefPtr<ScriptState> m_scriptState; | 140 RefPtr<ScriptState> m_scriptState; |
156 ScriptValue m_promise; | 141 ScriptValue m_promise; |
157 }; | 142 }; |
158 | 143 |
159 } // namespace blink | 144 } // namespace blink |
160 | 145 |
161 | 146 |
162 #endif // ScriptPromise_h | 147 #endif // ScriptPromise_h |
OLD | NEW |