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

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

Issue 273683006: ScriptPromise should understand the ScriptState from which the ScriptPromise is generated (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/bindings/v8/ScriptPromise.cpp ('k') | Source/bindings/v8/ScriptPromiseResolver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptPromiseResolver.h
diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
index a54ace56ec096e10c9391b1101112c4af05f7bcc..f9efcf39b6e68261b38a4b7ce94e529810d082a7 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.h
+++ b/Source/bindings/v8/ScriptPromiseResolver.h
@@ -68,8 +68,7 @@ class ExecutionContext;
class ScriptPromiseResolver : public RefCounted<ScriptPromiseResolver> {
WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
public:
- static PassRefPtr<ScriptPromiseResolver> create(ExecutionContext*);
- static PassRefPtr<ScriptPromiseResolver> create(v8::Isolate*);
+ static PassRefPtr<ScriptPromiseResolver> create(ScriptState*);
// A ScriptPromiseResolver should be resolved / rejected before
// its destruction.
@@ -85,7 +84,7 @@ public:
template<typename T>
void resolve(const T& value, ExecutionContext* executionContext)
{
- ASSERT(m_isolate->InContext());
+ ASSERT(m_scriptState->isolate()->InContext());
// You should use ScriptPromiseResolverWithContext when you want
// to resolve a Promise in a non-original V8 context.
return resolve(value);
@@ -93,7 +92,7 @@ public:
template<typename T>
void reject(const T& value, ExecutionContext* executionContext)
{
- ASSERT(m_isolate->InContext());
+ ASSERT(m_scriptState->isolate()->InContext());
// You should use ScriptPromiseResolverWithContext when you want
// to reject a Promise in a non-original V8 context.
return reject(value);
@@ -101,27 +100,27 @@ public:
template<typename T>
void resolve(const T& value)
{
- ASSERT(m_isolate->InContext());
+ ASSERT(m_scriptState->isolate()->InContext());
resolve(toV8Value(value));
}
template<typename T>
void reject(const T& value)
{
- ASSERT(m_isolate->InContext());
+ ASSERT(m_scriptState->isolate()->InContext());
reject(toV8Value(value));
}
template<typename T> void resolve(const T& value, v8::Handle<v8::Object> creationContext)
{
- ASSERT(m_isolate->InContext());
+ ASSERT(m_scriptState->isolate()->InContext());
resolve(toV8Value(value, creationContext));
}
template<typename T> void reject(const T& value, v8::Handle<v8::Object> creationContext)
{
- ASSERT(m_isolate->InContext());
+ ASSERT(m_scriptState->isolate()->InContext());
reject(toV8Value(value, creationContext));
}
- v8::Isolate* isolate() const { return m_isolate; }
+ v8::Isolate* isolate() const { return m_scriptState->isolate(); }
void resolve(v8::Handle<v8::Value>);
void reject(v8::Handle<v8::Value>);
@@ -131,29 +130,29 @@ public:
{
return creationContext;
}
- // Used by ToV8Value<ScriptPromiseResolver, v8::Isolate*>.
- static v8::Handle<v8::Object> getCreationContext(v8::Isolate* isolate)
+ // Used by ToV8Value<ScriptPromiseResolver, ScriptState*>.
+ static v8::Handle<v8::Object> getCreationContext(ScriptState* scriptState)
{
- return ScriptState::current(isolate)->context()->Global();
+ return scriptState->context()->Global();
}
private:
template<typename T>
v8::Handle<v8::Value> toV8Value(const T& value, v8::Handle<v8::Object> creationContext)
{
- return ToV8Value<ScriptPromiseResolver, v8::Handle<v8::Object> >::toV8Value(value, creationContext, m_isolate);
+ return ToV8Value<ScriptPromiseResolver, v8::Handle<v8::Object> >::toV8Value(value, creationContext, m_scriptState->isolate());
}
template<typename T>
v8::Handle<v8::Value> toV8Value(const T& value)
{
- return ToV8Value<ScriptPromiseResolver, v8::Isolate*>::toV8Value(value, m_isolate, m_isolate);
+ return ToV8Value<ScriptPromiseResolver, ScriptState*>::toV8Value(value, m_scriptState.get(), m_scriptState->isolate());
}
- ScriptPromiseResolver(ExecutionContext*);
- ScriptPromiseResolver(v8::Isolate*);
+ explicit ScriptPromiseResolver(ScriptState*);
- v8::Isolate* m_isolate;
+ // FIXME: Remove this once ScriptValue::scriptState() becomes available.
+ RefPtr<ScriptState> m_scriptState;
// Used when scriptPromiseOnV8Promise is disabled.
ScriptPromise m_promise;
// Used when scriptPromiseOnV8Promise is enabled.
« no previous file with comments | « Source/bindings/v8/ScriptPromise.cpp ('k') | Source/bindings/v8/ScriptPromiseResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698