Chromium Code Reviews| 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 ScriptPromiseResolver_h | 5 #ifndef ScriptPromiseResolver_h |
| 6 #define ScriptPromiseResolver_h | 6 #define ScriptPromiseResolver_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/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 // This class wraps v8::Promise::Resolver and provides the following | 21 // This class wraps v8::Promise::Resolver and provides the following |
| 22 // functionalities. | 22 // functionalities. |
| 23 // - A ScriptPromiseResolver retains a ScriptState. A caller | 23 // - A ScriptPromiseResolver retains a ScriptState. A caller |
| 24 // can call resolve or reject from outside of a V8 context. | 24 // can call resolve or reject from outside of a V8 context. |
| 25 // - This class is an ActiveDOMObject and keeps track of the associated | 25 // - This class is an ActiveDOMObject and keeps track of the associated |
| 26 // ExecutionContext state. When the ExecutionContext is suspended, | 26 // ExecutionContext state. When the ExecutionContext is suspended, |
| 27 // resolve or reject will be delayed. When it is stopped, resolve or reject | 27 // resolve or reject will be delayed. When it is stopped, resolve or reject |
| 28 // will be ignored. | 28 // will be ignored. |
| 29 class CORE_EXPORT ScriptPromiseResolver : public RefCountedWillBeRefCountedGarba geCollected<ScriptPromiseResolver>, public ActiveDOMObject { | 29 class CORE_EXPORT ScriptPromiseResolver : public RefCountedWillBeRefCountedGarba geCollected<ScriptPromiseResolver>, public ActiveDOMObject { |
| 30 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver); | 30 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver); |
| 31 #if ENABLE(ASSERT) | |
| 32 WILL_BE_USING_PRE_FINALIZER(ScriptPromiseResolver, assertNotPending); | |
| 33 #endif | |
| 34 WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver); | 31 WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver); |
| 35 public: | 32 public: |
| 36 static PassRefPtrWillBeRawPtr<ScriptPromiseResolver> create(ScriptState* scr iptState) | 33 static PassRefPtrWillBeRawPtr<ScriptPromiseResolver> create(ScriptState* scr iptState) |
| 37 { | 34 { |
| 38 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = adoptRefWillBeNoop( new ScriptPromiseResolver(scriptState)); | 35 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = adoptRefWillBeNoop( new ScriptPromiseResolver(scriptState)); |
| 39 resolver->suspendIfNeeded(); | 36 resolver->suspendIfNeeded(); |
| 40 return resolver.release(); | 37 return resolver.release(); |
| 41 } | 38 } |
| 42 | 39 |
| 43 #if !ENABLE(OILPAN) && ENABLE(ASSERT) | 40 #if ENABLE(ASSERT) |
| 41 // Eagerly finalized to allow assertNotPending() access | |
| 42 // other heap objects. | |
| 43 EAGERLY_FINALIZE(); | |
| 44 | |
| 44 ~ScriptPromiseResolver() override | 45 ~ScriptPromiseResolver() override |
| 45 { | 46 { |
| 46 assertNotPending(); | 47 assertNotPending(); |
|
haraken
2015/06/04 01:02:31
Now you can inline assertNotPending() here.
| |
| 47 } | 48 } |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 // Anything that can be passed to toV8 can be passed to this function. | 51 // Anything that can be passed to toV8 can be passed to this function. |
| 51 template<typename T> | 52 template<typename T> |
| 52 void resolve(T value) | 53 void resolve(T value) |
| 53 { | 54 { |
| 54 resolveOrReject(value, Resolving); | 55 resolveOrReject(value, Resolving); |
| 55 } | 56 } |
| 56 | 57 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 ScopedPersistent<v8::Value> m_value; | 152 ScopedPersistent<v8::Value> m_value; |
| 152 #if ENABLE(ASSERT) | 153 #if ENABLE(ASSERT) |
| 153 // True if promise() is called. | 154 // True if promise() is called. |
| 154 bool m_isPromiseCalled; | 155 bool m_isPromiseCalled; |
| 155 #endif | 156 #endif |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 } // namespace blink | 159 } // namespace blink |
| 159 | 160 |
| 160 #endif // ScriptPromiseResolver_h | 161 #endif // ScriptPromiseResolver_h |
| OLD | NEW |