| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/events/PromiseRejectionEvent.h" | 5 #include "core/events/PromiseRejectionEvent.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 void PromiseRejectionEvent::dispose() { | 30 void PromiseRejectionEvent::dispose() { |
| 31 // Clear ScopedPersistents so that V8 doesn't call phantom callbacks | 31 // Clear ScopedPersistents so that V8 doesn't call phantom callbacks |
| 32 // (and touch the ScopedPersistents) after Oilpan starts lazy sweeping. | 32 // (and touch the ScopedPersistents) after Oilpan starts lazy sweeping. |
| 33 m_promise.clear(); | 33 m_promise.clear(); |
| 34 m_reason.clear(); | 34 m_reason.clear(); |
| 35 m_scriptState.clear(); | 35 m_scriptState.clear(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 ScriptPromise PromiseRejectionEvent::promise(ScriptState* state) const { | 38 ScriptPromise PromiseRejectionEvent::promise(ScriptState* state) const { |
| 39 // Return null when the promise is accessed by a different world than the worl
d that created the promise. | 39 // Return null when the promise is accessed by a different world than the |
| 40 // world that created the promise. |
| 40 if (!m_scriptState || !m_scriptState->contextIsValid() || | 41 if (!m_scriptState || !m_scriptState->contextIsValid() || |
| 41 m_scriptState->world().worldId() != state->world().worldId()) | 42 m_scriptState->world().worldId() != state->world().worldId()) |
| 42 return ScriptPromise(); | 43 return ScriptPromise(); |
| 43 return ScriptPromise(m_scriptState.get(), | 44 return ScriptPromise(m_scriptState.get(), |
| 44 m_promise.newLocal(m_scriptState->isolate())); | 45 m_promise.newLocal(m_scriptState->isolate())); |
| 45 } | 46 } |
| 46 | 47 |
| 47 ScriptValue PromiseRejectionEvent::reason(ScriptState* state) const { | 48 ScriptValue PromiseRejectionEvent::reason(ScriptState* state) const { |
| 48 // Return null when the value is accessed by a different world than the world
that created the value. | 49 // Return null when the value is accessed by a different world than the world |
| 50 // that created the value. |
| 49 if (m_reason.isEmpty() || !m_scriptState || | 51 if (m_reason.isEmpty() || !m_scriptState || |
| 50 !m_scriptState->contextIsValid() || | 52 !m_scriptState->contextIsValid() || |
| 51 m_scriptState->world().worldId() != state->world().worldId()) | 53 m_scriptState->world().worldId() != state->world().worldId()) |
| 52 return ScriptValue(state, v8::Undefined(state->isolate())); | 54 return ScriptValue(state, v8::Undefined(state->isolate())); |
| 53 return ScriptValue(m_scriptState.get(), | 55 return ScriptValue(m_scriptState.get(), |
| 54 m_reason.newLocal(m_scriptState->isolate())); | 56 m_reason.newLocal(m_scriptState->isolate())); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void PromiseRejectionEvent::setWrapperReference( | 59 void PromiseRejectionEvent::setWrapperReference( |
| 58 v8::Isolate* isolate, | 60 v8::Isolate* isolate, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 80 DEFINE_TRACE(PromiseRejectionEvent) { | 82 DEFINE_TRACE(PromiseRejectionEvent) { |
| 81 Event::trace(visitor); | 83 Event::trace(visitor); |
| 82 } | 84 } |
| 83 | 85 |
| 84 DEFINE_TRACE_WRAPPERS(PromiseRejectionEvent) { | 86 DEFINE_TRACE_WRAPPERS(PromiseRejectionEvent) { |
| 85 visitor->traceWrappers(&m_promise); | 87 visitor->traceWrappers(&m_promise); |
| 86 visitor->traceWrappers(&m_reason); | 88 visitor->traceWrappers(&m_reason); |
| 87 } | 89 } |
| 88 | 90 |
| 89 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |