| 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 |
| 11 PromiseRejectionEvent::PromiseRejectionEvent( | 11 PromiseRejectionEvent::PromiseRejectionEvent( |
| 12 ScriptState* state, | 12 ScriptState* state, |
| 13 const AtomicString& type, | 13 const AtomicString& type, |
| 14 const PromiseRejectionEventInit& initializer) | 14 const PromiseRejectionEventInit& initializer) |
| 15 : Event(type, initializer), | 15 : Event(type, initializer), |
| 16 m_scriptState(state), | 16 m_scriptState(state), |
| 17 m_promise(this), | 17 m_promise(this), |
| 18 m_reason(this) { | 18 m_reason(this) { |
| 19 ThreadState::current()->registerPreFinalizer(this); | 19 ThreadState::current()->registerPreFinalizer(this); |
| 20 DCHECK(initializer.hasPromise()); | 20 DCHECK(initializer.hasPromise()); |
| 21 m_promise.set(initializer.promise().isolate(), | 21 m_promise.set(initializer.promise().isolate(), |
| 22 initializer.promise().v8Value()); | 22 initializer.promise().v8Value()); |
| 23 m_promise.setPhantom(); | |
| 24 if (initializer.hasReason()) { | 23 if (initializer.hasReason()) { |
| 25 m_reason.set(initializer.reason().isolate(), | 24 m_reason.set(initializer.reason().isolate(), |
| 26 initializer.reason().v8Value()); | 25 initializer.reason().v8Value()); |
| 27 m_reason.setPhantom(); | |
| 28 } | 26 } |
| 29 } | 27 } |
| 30 | 28 |
| 31 PromiseRejectionEvent::~PromiseRejectionEvent() {} | 29 PromiseRejectionEvent::~PromiseRejectionEvent() {} |
| 32 | 30 |
| 33 void PromiseRejectionEvent::dispose() { | 31 void PromiseRejectionEvent::dispose() { |
| 34 // Clear ScopedPersistents so that V8 doesn't call phantom callbacks | 32 // Clear ScopedPersistents so that V8 doesn't call phantom callbacks |
| 35 // (and touch the ScopedPersistents) after Oilpan starts lazy sweeping. | 33 // (and touch the ScopedPersistents) after Oilpan starts lazy sweeping. |
| 36 m_promise.clear(); | 34 m_promise.clear(); |
| 37 m_reason.clear(); | 35 m_reason.clear(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 DEFINE_TRACE(PromiseRejectionEvent) { | 83 DEFINE_TRACE(PromiseRejectionEvent) { |
| 86 Event::trace(visitor); | 84 Event::trace(visitor); |
| 87 } | 85 } |
| 88 | 86 |
| 89 DEFINE_TRACE_WRAPPERS(PromiseRejectionEvent) { | 87 DEFINE_TRACE_WRAPPERS(PromiseRejectionEvent) { |
| 90 visitor->traceWrappers(m_promise); | 88 visitor->traceWrappers(m_promise); |
| 91 visitor->traceWrappers(m_reason); | 89 visitor->traceWrappers(m_reason); |
| 92 } | 90 } |
| 93 | 91 |
| 94 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |