OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 ScriptPromisePropertyBase_h | 5 #ifndef ScriptPromisePropertyBase_h |
6 #define ScriptPromisePropertyBase_h | 6 #define ScriptPromisePropertyBase_h |
7 | 7 |
8 #include "bindings/core/v8/ScopedPersistent.h" | 8 #include "bindings/core/v8/ScopedPersistent.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptPromiseProperties.h" | 10 #include "bindings/core/v8/ScriptPromiseProperties.h" |
11 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
12 #include "wtf/RefCounted.h" | 12 #include "wtf/RefCounted.h" |
13 #include <v8.h> | 13 #include <v8.h> |
14 | 14 |
15 namespace WebCore { | 15 namespace WebCore { |
16 | 16 |
17 class ExecutionContext; | 17 class ExecutionContext; |
18 | 18 |
19 class ScriptPromisePropertyBase : public ContextLifecycleObserver, public RefCou
nted<ScriptPromisePropertyBase> { | 19 class ScriptPromisePropertyBase : public RefCountedWillBeRefCountedGarbageCollec
ted<ScriptPromisePropertyBase>, public ContextLifecycleObserver { |
20 public: | 20 public: |
21 virtual ~ScriptPromisePropertyBase(); | 21 virtual ~ScriptPromisePropertyBase(); |
22 | 22 |
23 enum Name { | 23 enum Name { |
24 #define P(Name) Name | 24 #define P(Name) Name |
25 SCRIPT_PROMISE_PROPERTIES(P) | 25 SCRIPT_PROMISE_PROPERTIES(P) |
26 #undef P | 26 #undef P |
27 }; | 27 }; |
28 | 28 |
29 enum State { | 29 enum State { |
30 Pending, | 30 Pending, |
31 Resolved, | 31 Resolved, |
32 Rejected, | 32 Rejected, |
33 }; | 33 }; |
34 State state() const { return m_state; } | 34 State state() const { return m_state; } |
35 | 35 |
36 ScriptPromise promise(DOMWrapperWorld&); | 36 ScriptPromise promise(DOMWrapperWorld&); |
37 | 37 |
| 38 virtual void trace(Visitor*) { } |
| 39 |
38 protected: | 40 protected: |
39 ScriptPromisePropertyBase(ExecutionContext*, Name); | 41 ScriptPromisePropertyBase(ExecutionContext*, Name); |
40 | 42 |
41 void resolveOrReject(State targetState); | 43 void resolveOrReject(State targetState); |
42 | 44 |
43 // ScriptPromiseProperty overrides these to wrap the holder, | 45 // ScriptPromiseProperty overrides these to wrap the holder, |
44 // rejected value and resolved value. The | 46 // rejected value and resolved value. The |
45 // ScriptPromisePropertyBase caller will enter the V8Context for | 47 // ScriptPromisePropertyBase caller will enter the V8Context for |
46 // the property's execution context and the world it is | 48 // the property's execution context and the world it is |
47 // creating/settling promises in; the implementation should use | 49 // creating/settling promises in; the implementation should use |
(...skipping 13 matching lines...) Expand all Loading... |
61 State m_state; | 63 State m_state; |
62 | 64 |
63 // FIXME: When isolated worlds are supported replace this with a | 65 // FIXME: When isolated worlds are supported replace this with a |
64 // set of wrappers. | 66 // set of wrappers. |
65 ScopedPersistent<v8::Object> m_mainWorldWrapper; | 67 ScopedPersistent<v8::Object> m_mainWorldWrapper; |
66 }; | 68 }; |
67 | 69 |
68 } // namespace WebCore | 70 } // namespace WebCore |
69 | 71 |
70 #endif // ScriptPromisePropertyBase_h | 72 #endif // ScriptPromisePropertyBase_h |
OLD | NEW |