| 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 ScriptPromiseResolverWithContext_h | 5 #ifndef ScriptPromiseResolverWithContext_h |
| 6 #define ScriptPromiseResolverWithContext_h | 6 #define ScriptPromiseResolverWithContext_h |
| 7 | 7 |
| 8 #include "bindings/v8/ScopedPersistent.h" | 8 #include "bindings/v8/ScopedPersistent.h" |
| 9 #include "bindings/v8/ScriptPromise.h" | 9 #include "bindings/v8/ScriptPromise.h" |
| 10 #include "bindings/v8/ScriptPromiseResolver.h" | 10 #include "bindings/v8/ScriptPromiseResolver.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 { | 96 { |
| 97 if (m_state != Pending || !executionContext() || executionContext()->act
iveDOMObjectsAreStopped()) | 97 if (m_state != Pending || !executionContext() || executionContext()->act
iveDOMObjectsAreStopped()) |
| 98 return; | 98 return; |
| 99 m_state = newState; | 99 m_state = newState; |
| 100 // Retain this object until it is actually resolved or rejected. | 100 // Retain this object until it is actually resolved or rejected. |
| 101 // |deref| will be called in |clear|. | 101 // |deref| will be called in |clear|. |
| 102 ref(); | 102 ref(); |
| 103 | 103 |
| 104 ScriptState::Scope scope(m_scriptState.get()); | 104 ScriptState::Scope scope(m_scriptState.get()); |
| 105 m_value.set(m_scriptState->isolate(), toV8Value(value)); | 105 m_value.set(m_scriptState->isolate(), toV8Value(value)); |
| 106 if (!executionContext()->activeDOMObjectsAreSuspended()) { | 106 if (!executionContext()->activeDOMObjectsAreSuspended()) |
| 107 resolveOrRejectImmediately(); | 107 resolveOrRejectImmediately(); |
| 108 // |this| can't be deleted here, so it is safe to call an instance | |
| 109 // method. | |
| 110 postRunMicrotasks(); | |
| 111 } | |
| 112 } | 108 } |
| 113 | 109 |
| 114 void resolveOrRejectImmediately(); | 110 void resolveOrRejectImmediately(); |
| 115 void postRunMicrotasks(); | |
| 116 void onTimerFired(Timer<ScriptPromiseResolverWithContext>*); | 111 void onTimerFired(Timer<ScriptPromiseResolverWithContext>*); |
| 117 void clear(); | 112 void clear(); |
| 118 | 113 |
| 119 ResolutionState m_state; | 114 ResolutionState m_state; |
| 120 const RefPtr<ScriptState> m_scriptState; | 115 const RefPtr<ScriptState> m_scriptState; |
| 121 Timer<ScriptPromiseResolverWithContext> m_timer; | 116 Timer<ScriptPromiseResolverWithContext> m_timer; |
| 122 RefPtr<ScriptPromiseResolver> m_resolver; | 117 RefPtr<ScriptPromiseResolver> m_resolver; |
| 123 ScopedPersistent<v8::Value> m_value; | 118 ScopedPersistent<v8::Value> m_value; |
| 124 }; | 119 }; |
| 125 | 120 |
| 126 } // namespace WebCore | 121 } // namespace WebCore |
| 127 | 122 |
| 128 #endif // #ifndef ScriptPromiseResolverWithContext_h | 123 #endif // #ifndef ScriptPromiseResolverWithContext_h |
| OLD | NEW |