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 #ifndef PromiseRejectionEvent_h | 5 #ifndef PromiseRejectionEvent_h |
6 #define PromiseRejectionEvent_h | 6 #define PromiseRejectionEvent_h |
7 | 7 |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
8 #include "bindings/core/v8/ScopedPersistent.h" | 9 #include "bindings/core/v8/ScopedPersistent.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptState.h" | 11 #include "bindings/core/v8/ScriptState.h" |
11 #include "bindings/core/v8/ScriptValue.h" | 12 #include "bindings/core/v8/ScriptValue.h" |
12 #include "core/CoreExport.h" | 13 #include "core/CoreExport.h" |
13 #include "core/events/Event.h" | 14 #include "core/events/Event.h" |
14 #include "core/events/PromiseRejectionEventInit.h" | 15 #include "core/events/PromiseRejectionEventInit.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class CORE_EXPORT PromiseRejectionEvent final : public Event { | 19 class CORE_EXPORT PromiseRejectionEvent final : public Event { |
19 DEFINE_WRAPPERTYPEINFO(); | 20 DEFINE_WRAPPERTYPEINFO(); |
20 public: | 21 public: |
21 static PassRefPtrWillBeRawPtr<PromiseRejectionEvent> create() | 22 static PassRefPtrWillBeRawPtr<PromiseRejectionEvent> create() |
22 { | 23 { |
23 return adoptRefWillBeNoop(new PromiseRejectionEvent); | 24 return adoptRefWillBeNoop(new PromiseRejectionEvent); |
24 } | 25 } |
25 static PassRefPtrWillBeRawPtr<PromiseRejectionEvent> create(ScriptState* sta
te, const AtomicString& type, const PromiseRejectionEventInit& initializer) | 26 static PassRefPtrWillBeRawPtr<PromiseRejectionEvent> create(ScriptState* sta
te, const AtomicString& type, const PromiseRejectionEventInit& initializer) |
26 { | 27 { |
27 return adoptRefWillBeNoop(new PromiseRejectionEvent(state, type, initial
izer)); | 28 return adoptRefWillBeNoop(new PromiseRejectionEvent(state, type, initial
izer)); |
28 } | 29 } |
29 | 30 |
30 ScriptValue reason(ScriptState*) const; | 31 ScriptValue reason(ScriptState*) const; |
31 ScriptPromise promise(ScriptState*) const; | 32 ScriptPromise promise(ScriptState*) const; |
32 | 33 |
33 virtual const AtomicString& interfaceName() const override; | 34 virtual const AtomicString& interfaceName() const override; |
34 | 35 |
| 36 // PromiseRejectionEvents are similar to ErrorEvents in that they can't be |
| 37 // observed across different worlds. |
| 38 virtual bool canBeDispatchedInWorld(const DOMWrapperWorld&) const override; |
| 39 |
35 DECLARE_VIRTUAL_TRACE(); | 40 DECLARE_VIRTUAL_TRACE(); |
36 | 41 |
37 private: | 42 private: |
38 PromiseRejectionEvent(); | 43 PromiseRejectionEvent(); |
39 PromiseRejectionEvent(ScriptState*, const AtomicString&, const PromiseReject
ionEventInit&); | 44 PromiseRejectionEvent(ScriptState*, const AtomicString&, const PromiseReject
ionEventInit&); |
40 ~PromiseRejectionEvent() override; | 45 ~PromiseRejectionEvent() override; |
41 | 46 |
42 static void didCollectPromise(const v8::WeakCallbackInfo<PromiseRejectionEve
nt>&); | 47 static void didCollectPromise(const v8::WeakCallbackInfo<PromiseRejectionEve
nt>&); |
43 static void didCollectReason(const v8::WeakCallbackInfo<PromiseRejectionEven
t>&); | 48 static void didCollectReason(const v8::WeakCallbackInfo<PromiseRejectionEven
t>&); |
44 | 49 |
45 RefPtr<ScriptState> m_scriptState; | 50 RefPtr<ScriptState> m_scriptState; |
46 ScopedPersistent<v8::Value> m_promise; | 51 ScopedPersistent<v8::Value> m_promise; |
47 ScopedPersistent<v8::Value> m_reason; | 52 ScopedPersistent<v8::Value> m_reason; |
48 }; | 53 }; |
49 | 54 |
50 } // namespace blink | 55 } // namespace blink |
51 | 56 |
52 #endif // PromiseRejectionEvent_h | 57 #endif // PromiseRejectionEvent_h |
OLD | NEW |