| Index: Source/bindings/v8/ScriptPromiseResolver.h
|
| diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
|
| index 200638e468e85b564677987c725f15e79764ff16..5137eaac092d0cd37e4c25077a3111bc5a7bdce8 100644
|
| --- a/Source/bindings/v8/ScriptPromiseResolver.h
|
| +++ b/Source/bindings/v8/ScriptPromiseResolver.h
|
| @@ -51,7 +51,7 @@ class ExecutionContext;
|
| // ScriptPromiseResolver holds a PromiseResolver.
|
| // Here is a typical usage:
|
| // 1. Create a ScriptPromiseResolver.
|
| -// 2. Pass the promise object of the holder to a JavaScript program
|
| +// 2. Pass the associated promise object to a JavaScript program
|
| // (such as XMLHttpRequest return value).
|
| // 3. Call resolve or reject when the operation completes or
|
| // the operation fails respectively.
|
| @@ -63,7 +63,10 @@ class ExecutionContext;
|
| // To prevent memory leaks, you should release the reference manually
|
| // by calling resolve or reject.
|
| // Destroying the object will also release the reference.
|
| -//
|
| +// Note that ScriptPromiseResolver::promise returns an empty value when the
|
| +// resolver is already resolved or rejected. If you want to resolve a resolver
|
| +// immediately and return the associated promise, you should get the promise
|
| +// before resolving.
|
| class ScriptPromiseResolver : public RefCounted<ScriptPromiseResolver> {
|
| WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
|
| public:
|
| @@ -76,14 +79,10 @@ public:
|
| // entering a v8 context.
|
| ~ScriptPromiseResolver();
|
|
|
| - // Return true if the promise object is in pending state.
|
| - bool isPending() const;
|
| -
|
| - ScriptPromise promise()
|
| - {
|
| - ASSERT(m_promise.isolate()->InContext());
|
| - return m_promise;
|
| - }
|
| + // Returns the underlying Promise.
|
| + // Note that the underlying Promise is cleared when |resolve| or |reject|
|
| + // is called.
|
| + ScriptPromise promise();
|
|
|
| // To use following template methods, T must be a DOM class.
|
|
|
| @@ -141,7 +140,10 @@ private:
|
| void reject(v8::Handle<v8::Value>);
|
|
|
| v8::Isolate* m_isolate;
|
| + // Used when scriptPromiseOnV8Promise is disabled.
|
| ScriptPromise m_promise;
|
| + // Used when scriptPromiseOnV8Promise is enabled.
|
| + ScriptValue m_resolver;
|
| };
|
|
|
| template<typename T>
|
|
|