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

Unified Diff: Source/bindings/v8/ScriptPromiseResolver.h

Issue 23479016: Introduce Promise mapping to the IDL generator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/ScriptPromiseResolver.h
diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
index 18d30523fad4eef50394bc20bae123dba4888b14..64ce6e469a06104adeeae54313e25fa6ad1dfcdd 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.h
+++ b/Source/bindings/v8/ScriptPromiseResolver.h
@@ -32,7 +32,7 @@
#define ScriptPromiseResolver_h
#include "bindings/v8/ScopedPersistent.h"
-#include "bindings/v8/ScriptObject.h"
+#include "bindings/v8/ScriptPromise.h"
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/ScriptValue.h"
#include "wtf/RefPtr.h"
@@ -59,11 +59,14 @@ class ScriptExecutionContext;
// To use ScriptPromiseResolver out of a v8 context the caller must
// enter a v8 context, for example by using ScriptScope and ScriptState.
//
-class ScriptPromiseResolver : public RefCounted<ScriptPromiseResolver> {
- WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
+class ScriptPromiseResolver {
yhirano 2013/09/02 11:58:17 Can ScriptPromiseResolver be a subclass of ScriptV
public:
- static PassRefPtr<ScriptPromiseResolver> create(ScriptExecutionContext*);
- static PassRefPtr<ScriptPromiseResolver> create();
+ ScriptPromiseResolver();
+ explicit ScriptPromiseResolver(ScriptValue resolver);
+ ScriptPromiseResolver(v8::Handle<v8::Value> resolver, v8::Isolate*);
+
+ static ScriptPromiseResolver create(ScriptExecutionContext*);
+ static ScriptPromiseResolver create();
// A ScriptPromiseResolver should be fulfilled / resolved / rejected before
// its destruction.
@@ -83,10 +86,10 @@ public:
// - The resolver's resolved flag is not set.
bool isPending() const;
- ScriptObject promise()
+ ScriptPromise promise()
{
ASSERT(v8::Context::InContext());
- return ScriptObject(ScriptState::current(), m_promise.newLocal(m_isolate));
+ return m_promise;
}
// Fulfill with a C++ object which can be converted to a v8 object by toV8.
@@ -103,15 +106,35 @@ public:
void resolve(ScriptValue);
void reject(ScriptValue);
+ bool isObject() const
+ {
+ return m_resolver.isObject();
+ }
+
+ bool isNull() const
+ {
+ return m_resolver.isNull();
+ }
+
+ bool isUndefinedOrNull() const
+ {
+ return m_resolver.isUndefined() || m_resolver.isNull();
+ }
+
+ v8::Handle<v8::Value> v8Value() const
+ {
+ return m_resolver.v8Value();
+ }
+
private:
- ScriptPromiseResolver(v8::Handle<v8::Object> creationContext, v8::Isolate*);
+ ScriptPromiseResolver(v8::Handle<v8::Value> resolver, v8::Handle<v8::Value> promise, v8::Isolate*);
void fulfill(v8::Handle<v8::Value>);
void resolve(v8::Handle<v8::Value>);
void reject(v8::Handle<v8::Value>);
v8::Isolate* m_isolate;
- ScopedPersistent<v8::Object> m_promise;
- ScopedPersistent<v8::Object> m_resolver;
+ ScriptPromise m_promise;
+ ScriptValue m_resolver;
haraken 2013/09/02 21:44:21 Won't these cause memory leaks? Specifically, how
yusukesuzuki 2013/09/03 01:52:40 ScriptPromiseResolver is not a native class of DOM
haraken 2013/09/03 02:12:19 Sorry, actually I'm not a best reviewer here since
yusukesuzuki 2013/09/03 03:57:45 Right. This case causes memory leaks. For example,
bool isPendingInternal() const;
};

Powered by Google App Engine
This is Rietveld 408576698