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

Unified Diff: Source/bindings/v8/ScriptPromise.cpp

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.h ('k') | Source/bindings/v8/ScriptPromiseResolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptPromise.cpp
diff --git a/Source/bindings/v8/ScriptPromise.cpp b/Source/bindings/v8/ScriptPromise.cpp
index 7279ccc9fbb2e8bf5f7668e49d42bbf7754c7709..c8ce8bbffc63b56b8aa625f307a3b85f74e131fb 100644
--- a/Source/bindings/v8/ScriptPromise.cpp
+++ b/Source/bindings/v8/ScriptPromise.cpp
@@ -40,17 +40,18 @@
namespace WebCore {
-ScriptPromise::ScriptPromise(v8::Handle<v8::Value> value, v8::Isolate* isolate)
+ScriptPromise::ScriptPromise(ScriptState* scriptState, v8::Handle<v8::Value> value)
+ : m_scriptState(scriptState)
{
if (value.IsEmpty())
return;
- if (!V8PromiseCustom::isPromise(value, isolate) && !value->IsPromise()) {
- m_promise = ScriptValue(v8::Handle<v8::Value>(), isolate);
- V8ThrowException::throwTypeError("the given value is not a Promise", isolate);
+ if (!V8PromiseCustom::isPromise(value, scriptState->isolate()) && !value->IsPromise()) {
+ m_promise = ScriptValue(scriptState, v8::Handle<v8::Value>());
+ V8ThrowException::throwTypeError("the given value is not a Promise", scriptState->isolate());
return;
}
- m_promise = ScriptValue(value, isolate);
+ m_promise = ScriptValue(scriptState, value);
}
ScriptPromise ScriptPromise::then(PassOwnPtr<ScriptFunction> onFulfilled, PassOwnPtr<ScriptFunction> onRejected)
@@ -62,8 +63,8 @@ ScriptPromise ScriptPromise::then(PassOwnPtr<ScriptFunction> onFulfilled, PassOw
v8::Local<v8::Function> v8OnFulfilled = ScriptFunction::adoptByGarbageCollector(onFulfilled);
v8::Local<v8::Function> v8OnRejected = ScriptFunction::adoptByGarbageCollector(onRejected);
- if (V8PromiseCustom::isPromise(promise, isolate()))
- return ScriptPromise(V8PromiseCustom::then(promise, v8OnFulfilled, v8OnRejected, isolate()), isolate());
+ if (V8PromiseCustom::isPromise(promise, m_scriptState->isolate()))
+ return ScriptPromise(m_scriptState.get(), V8PromiseCustom::then(promise, v8OnFulfilled, v8OnRejected, m_scriptState->isolate()));
ASSERT(promise->IsPromise());
// Return this Promise if no handlers are given.
@@ -82,7 +83,7 @@ ScriptPromise ScriptPromise::then(PassOwnPtr<ScriptFunction> onFulfilled, PassOw
if (!v8OnRejected.IsEmpty())
resultPromise = resultPromise->Catch(v8OnRejected);
- return ScriptPromise(resultPromise, isolate());
+ return ScriptPromise(m_scriptState.get(), resultPromise);
}
ScriptPromise ScriptPromise::cast(const ScriptValue& value)
@@ -92,7 +93,7 @@ ScriptPromise ScriptPromise::cast(const ScriptValue& value)
v8::Local<v8::Value> v8Value(value.v8Value());
v8::Isolate* isolate = value.isolate();
if (V8PromiseCustom::isPromise(v8Value, isolate) || v8Value->IsPromise()) {
- return ScriptPromise(v8Value, isolate);
+ return ScriptPromise(value.scriptState(), v8Value);
}
if (RuntimeEnabledFeatures::scriptPromiseOnV8PromiseEnabled()) {
v8::Local<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(isolate);
@@ -102,9 +103,9 @@ ScriptPromise ScriptPromise::cast(const ScriptValue& value)
return ScriptPromise();
}
resolver->Resolve(v8Value);
- return ScriptPromise(resolver->GetPromise(), isolate);
+ return ScriptPromise(value.scriptState(), resolver->GetPromise());
}
- return ScriptPromise(V8PromiseCustom::toPromise(v8Value, isolate), isolate);
+ return ScriptPromise(value.scriptState(), V8PromiseCustom::toPromise(v8Value, isolate));
}
} // namespace WebCore
« no previous file with comments | « Source/bindings/v8/ScriptPromise.h ('k') | Source/bindings/v8/ScriptPromiseResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698