| 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" |
| 11 #include "bindings/core/v8/ToV8.h" | 11 #include "bindings/core/v8/ToV8.h" |
| 12 #include "core/CoreExport.h" | 12 #include "core/CoreExport.h" |
| 13 #include "core/dom/ActiveDOMObject.h" | 13 #include "core/dom/ActiveDOMObject.h" |
| 14 #include "core/dom/ExecutionContext.h" | 14 #include "core/dom/ExecutionContext.h" |
| 15 #include "platform/Timer.h" | 15 #include "platform/Timer.h" |
| 16 #include "wtf/RefCounted.h" | 16 #include "wtf/RefCounted.h" |
| 17 #include <v8.h> | 17 #include <v8.h> |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 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 GarbageCollectedFinalized<Scrip
tPromiseResolver>, public ActiveDOMObject { | 29 class CORE_EXPORT ScriptPromiseResolver : public GarbageCollectedFinalized<Scrip
tPromiseResolver>, public ActiveDOMObject { |
| 30 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver); | 30 USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver); |
| 31 WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver); | 31 WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver); |
| 32 public: | 32 public: |
| 33 static ScriptPromiseResolver* create(ScriptState* scriptState) | 33 static ScriptPromiseResolver* create(ScriptState* scriptState) |
| 34 { | 34 { |
| 35 ScriptPromiseResolver* resolver = new ScriptPromiseResolver(scriptState)
; | 35 ScriptPromiseResolver* resolver = new ScriptPromiseResolver(scriptState)
; |
| 36 resolver->suspendIfNeeded(); | 36 resolver->suspendIfNeeded(); |
| 37 return resolver; | 37 return resolver; |
| 38 } | 38 } |
| 39 | 39 |
| 40 #if ENABLE(ASSERT) | 40 #if ENABLE(ASSERT) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 #if ENABLE(ASSERT) | 152 #if ENABLE(ASSERT) |
| 153 // True if promise() is called. | 153 // True if promise() is called. |
| 154 bool m_isPromiseCalled; | 154 bool m_isPromiseCalled; |
| 155 #endif | 155 #endif |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 } // namespace blink | 158 } // namespace blink |
| 159 | 159 |
| 160 #endif // ScriptPromiseResolver_h | 160 #endif // ScriptPromiseResolver_h |
| OLD | NEW |