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

Unified Diff: third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp

Issue 2544883005: Remove RefPtr<ScriptState> from PromiseRejectionEvent (Closed)
Patch Set: temp Created 4 years 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 | « third_party/WebKit/Source/core/events/PromiseRejectionEvent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp
diff --git a/third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp b/third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp
index d92390209d188e97cae733dd76a574abe5573647..7653df1fa8c4d87f9ca2cbb81227c3c4e7878e0a 100644
--- a/third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp
+++ b/third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp
@@ -13,7 +13,7 @@ PromiseRejectionEvent::PromiseRejectionEvent(
const AtomicString& type,
const PromiseRejectionEventInit& initializer)
: Event(type, initializer),
- m_scriptState(state),
+ m_world(state->world()),
m_promise(this),
m_reason(this) {
ThreadState::current()->registerPreFinalizer(this);
@@ -33,28 +33,23 @@ void PromiseRejectionEvent::dispose() {
// (and touch the ScopedPersistents) after Oilpan starts lazy sweeping.
m_promise.clear();
m_reason.clear();
- m_scriptState.clear();
+ m_world.clear();
}
-ScriptPromise PromiseRejectionEvent::promise(ScriptState* state) const {
+ScriptPromise PromiseRejectionEvent::promise(ScriptState* scriptState) const {
// Return null when the promise is accessed by a different world than the
// world that created the promise.
- if (!m_scriptState || !m_scriptState->contextIsValid() ||
- m_scriptState->world().worldId() != state->world().worldId())
+ if (!canBeDispatchedInWorld(scriptState->world()))
return ScriptPromise();
- return ScriptPromise(m_scriptState.get(),
- m_promise.newLocal(m_scriptState->isolate()));
+ return ScriptPromise(scriptState, m_promise.newLocal(scriptState->isolate()));
}
-ScriptValue PromiseRejectionEvent::reason(ScriptState* state) const {
+ScriptValue PromiseRejectionEvent::reason(ScriptState* scriptState) const {
// Return null when the value is accessed by a different world than the world
// that created the value.
- if (m_reason.isEmpty() || !m_scriptState ||
- !m_scriptState->contextIsValid() ||
- m_scriptState->world().worldId() != state->world().worldId())
- return ScriptValue(state, v8::Undefined(state->isolate()));
- return ScriptValue(m_scriptState.get(),
- m_reason.newLocal(m_scriptState->isolate()));
+ if (m_reason.isEmpty() || !canBeDispatchedInWorld(scriptState->world()))
+ return ScriptValue(scriptState, v8::Undefined(scriptState->isolate()));
+ return ScriptValue(scriptState, m_reason.newLocal(scriptState->isolate()));
}
void PromiseRejectionEvent::setWrapperReference(
@@ -76,8 +71,7 @@ const AtomicString& PromiseRejectionEvent::interfaceName() const {
bool PromiseRejectionEvent::canBeDispatchedInWorld(
const DOMWrapperWorld& world) const {
- return m_scriptState && m_scriptState->contextIsValid() &&
- m_scriptState->world().worldId() == world.worldId();
+ return m_world && m_world->worldId() == world.worldId();
}
DEFINE_TRACE(PromiseRejectionEvent) {
« no previous file with comments | « third_party/WebKit/Source/core/events/PromiseRejectionEvent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698