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/CoreExport.h" | 11 #include "core/CoreExport.h" |
12 #include "core/dom/ContextLifecycleObserver.h" | 12 #include "core/dom/ContextLifecycleObserver.h" |
13 #include "wtf/Compiler.h" | 13 #include "wtf/Compiler.h" |
| 14 #include "wtf/OwnPtr.h" |
14 #include "wtf/RefCounted.h" | 15 #include "wtf/RefCounted.h" |
15 #include "wtf/Vector.h" | 16 #include "wtf/Vector.h" |
16 #include <memory> | |
17 #include <v8.h> | 17 #include <v8.h> |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
21 class DOMWrapperWorld; | 21 class DOMWrapperWorld; |
22 class ExecutionContext; | 22 class ExecutionContext; |
23 class ScriptState; | 23 class ScriptState; |
24 | 24 |
25 // TODO(yhirano): Remove NEVER_INLINE once we find the cause of crashes. | 25 // TODO(yhirano): Remove NEVER_INLINE once we find the cause of crashes. |
26 class CORE_EXPORT ScriptPromisePropertyBase : public GarbageCollectedFinalized<S
criptPromisePropertyBase>, public ContextLifecycleObserver { | 26 class CORE_EXPORT ScriptPromisePropertyBase : public GarbageCollectedFinalized<S
criptPromisePropertyBase>, public ContextLifecycleObserver { |
(...skipping 29 matching lines...) Expand all Loading... |
56 // the property's execution context and the world it is | 56 // the property's execution context and the world it is |
57 // creating/settling promises in; the implementation should use | 57 // creating/settling promises in; the implementation should use |
58 // this context. | 58 // this context. |
59 virtual v8::Local<v8::Object> holder(v8::Isolate*, v8::Local<v8::Object> cre
ationContext) = 0; | 59 virtual v8::Local<v8::Object> holder(v8::Isolate*, v8::Local<v8::Object> cre
ationContext) = 0; |
60 virtual v8::Local<v8::Value> resolvedValue(v8::Isolate*, v8::Local<v8::Objec
t> creationContext) = 0; | 60 virtual v8::Local<v8::Value> resolvedValue(v8::Isolate*, v8::Local<v8::Objec
t> creationContext) = 0; |
61 virtual v8::Local<v8::Value> rejectedValue(v8::Isolate*, v8::Local<v8::Objec
t> creationContext) = 0; | 61 virtual v8::Local<v8::Value> rejectedValue(v8::Isolate*, v8::Local<v8::Objec
t> creationContext) = 0; |
62 | 62 |
63 NEVER_INLINE void resetBase(); | 63 NEVER_INLINE void resetBase(); |
64 | 64 |
65 private: | 65 private: |
66 typedef Vector<std::unique_ptr<ScopedPersistent<v8::Object>>> WeakPersistent
Set; | 66 typedef Vector<OwnPtr<ScopedPersistent<v8::Object>>> WeakPersistentSet; |
67 | 67 |
68 void resolveOrRejectInternal(v8::Local<v8::Promise::Resolver>); | 68 void resolveOrRejectInternal(v8::Local<v8::Promise::Resolver>); |
69 v8::Local<v8::Object> ensureHolderWrapper(ScriptState*); | 69 v8::Local<v8::Object> ensureHolderWrapper(ScriptState*); |
70 NEVER_INLINE void clearWrappers(); | 70 NEVER_INLINE void clearWrappers(); |
71 // TODO(yhirano): Remove these functions once we find the cause of crashes. | 71 // TODO(yhirano): Remove these functions once we find the cause of crashes. |
72 NEVER_INLINE void checkThis(); | 72 NEVER_INLINE void checkThis(); |
73 NEVER_INLINE void checkWrappers(); | 73 NEVER_INLINE void checkWrappers(); |
74 | 74 |
75 v8::Local<v8::String> promiseName(); | 75 v8::Local<v8::String> promiseName(); |
76 v8::Local<v8::String> resolverName(); | 76 v8::Local<v8::String> resolverName(); |
77 | 77 |
78 v8::Isolate* m_isolate; | 78 v8::Isolate* m_isolate; |
79 Name m_name; | 79 Name m_name; |
80 State m_state; | 80 State m_state; |
81 | 81 |
82 WeakPersistentSet m_wrappers; | 82 WeakPersistentSet m_wrappers; |
83 }; | 83 }; |
84 | 84 |
85 } // namespace blink | 85 } // namespace blink |
86 | 86 |
87 #endif // ScriptPromisePropertyBase_h | 87 #endif // ScriptPromisePropertyBase_h |
OLD | NEW |