Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h

Issue 2552993002: Rename activeDOMObjectsAreStopped to isContextDestroyed (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 EAGERLY_FINALIZE(); 47 EAGERLY_FINALIZE();
48 48
49 ~ScriptPromiseResolver() override { 49 ~ScriptPromiseResolver() override {
50 // This assertion fails if: 50 // This assertion fails if:
51 // - promise() is called at least once and 51 // - promise() is called at least once and
52 // - this resolver is destructed before it is resolved, rejected, 52 // - this resolver is destructed before it is resolved, rejected,
53 // detached, the V8 isolate is terminated or the associated 53 // detached, the V8 isolate is terminated or the associated
54 // ExecutionContext is stopped. 54 // ExecutionContext is stopped.
55 ASSERT(m_state == Detached || !m_isPromiseCalled || 55 ASSERT(m_state == Detached || !m_isPromiseCalled ||
56 !getScriptState()->contextIsValid() || !getExecutionContext() || 56 !getScriptState()->contextIsValid() || !getExecutionContext() ||
57 getExecutionContext()->activeDOMObjectsAreStopped()); 57 getExecutionContext()->isContextDestroyed());
58 } 58 }
59 #endif 59 #endif
60 60
61 // Anything that can be passed to toV8 can be passed to this function. 61 // Anything that can be passed to toV8 can be passed to this function.
62 template <typename T> 62 template <typename T>
63 void resolve(T value) { 63 void resolve(T value) {
64 resolveOrReject(value, Resolving); 64 resolveOrReject(value, Resolving);
65 } 65 }
66 66
67 // Anything that can be passed to toV8 can be passed to this function. 67 // Anything that can be passed to toV8 can be passed to this function.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 enum ResolutionState { 113 enum ResolutionState {
114 Pending, 114 Pending,
115 Resolving, 115 Resolving,
116 Rejecting, 116 Rejecting,
117 Detached, 117 Detached,
118 }; 118 };
119 119
120 template <typename T> 120 template <typename T>
121 void resolveOrReject(T value, ResolutionState newState) { 121 void resolveOrReject(T value, ResolutionState newState) {
122 if (m_state != Pending || !getScriptState()->contextIsValid() || 122 if (m_state != Pending || !getScriptState()->contextIsValid() ||
123 !getExecutionContext() || 123 !getExecutionContext() || getExecutionContext()->isContextDestroyed())
124 getExecutionContext()->activeDOMObjectsAreStopped())
125 return; 124 return;
126 ASSERT(newState == Resolving || newState == Rejecting); 125 ASSERT(newState == Resolving || newState == Rejecting);
127 m_state = newState; 126 m_state = newState;
128 127
129 ScriptState::Scope scope(m_scriptState.get()); 128 ScriptState::Scope scope(m_scriptState.get());
130 m_value.set(m_scriptState->isolate(), 129 m_value.set(m_scriptState->isolate(),
131 toV8(value, m_scriptState->context()->Global(), 130 toV8(value, m_scriptState->context()->Global(),
132 m_scriptState->isolate())); 131 m_scriptState->isolate()));
133 132
134 if (getExecutionContext()->activeDOMObjectsAreSuspended()) { 133 if (getExecutionContext()->activeDOMObjectsAreSuspended()) {
(...skipping 29 matching lines...) Expand all
164 163
165 #if ENABLE(ASSERT) 164 #if ENABLE(ASSERT)
166 // True if promise() is called. 165 // True if promise() is called.
167 bool m_isPromiseCalled; 166 bool m_isPromiseCalled;
168 #endif 167 #endif
169 }; 168 };
170 169
171 } // namespace blink 170 } // namespace blink
172 171
173 #endif // ScriptPromiseResolver_h 172 #endif // ScriptPromiseResolver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698