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

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

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: m_domTreeVersion initialization Created 3 years, 11 months 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 23 matching lines...) Expand all
34 USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver); 34 USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver);
35 WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver); 35 WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
36 36
37 public: 37 public:
38 static ScriptPromiseResolver* create(ScriptState* scriptState) { 38 static ScriptPromiseResolver* create(ScriptState* scriptState) {
39 ScriptPromiseResolver* resolver = new ScriptPromiseResolver(scriptState); 39 ScriptPromiseResolver* resolver = new ScriptPromiseResolver(scriptState);
40 resolver->suspendIfNeeded(); 40 resolver->suspendIfNeeded();
41 return resolver; 41 return resolver;
42 } 42 }
43 43
44 #if ENABLE(ASSERT) 44 #if DCHECK_IS_ON()
45 // Eagerly finalized so as to ensure valid access to getExecutionContext() 45 // Eagerly finalized so as to ensure valid access to getExecutionContext()
46 // from the destructor's assert. 46 // from the destructor's assert.
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.
(...skipping 16 matching lines...) Expand all
71 } 71 }
72 72
73 void resolve() { resolve(ToV8UndefinedGenerator()); } 73 void resolve() { resolve(ToV8UndefinedGenerator()); }
74 void reject() { reject(ToV8UndefinedGenerator()); } 74 void reject() { reject(ToV8UndefinedGenerator()); }
75 75
76 ScriptState* getScriptState() { return m_scriptState.get(); } 76 ScriptState* getScriptState() { return m_scriptState.get(); }
77 77
78 // Note that an empty ScriptPromise will be returned after resolve or 78 // Note that an empty ScriptPromise will be returned after resolve or
79 // reject is called. 79 // reject is called.
80 ScriptPromise promise() { 80 ScriptPromise promise() {
81 #if ENABLE(ASSERT) 81 #if DCHECK_IS_ON()
82 m_isPromiseCalled = true; 82 m_isPromiseCalled = true;
83 #endif 83 #endif
84 return m_resolver.promise(); 84 return m_resolver.promise();
85 } 85 }
86 86
87 ScriptState* getScriptState() const { return m_scriptState.get(); } 87 ScriptState* getScriptState() const { return m_scriptState.get(); }
88 88
89 // SuspendableObject implementation. 89 // SuspendableObject implementation.
90 void suspend() override; 90 void suspend() override;
91 void resume() override; 91 void resume() override;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ResolutionState m_state; 154 ResolutionState m_state;
155 const RefPtr<ScriptState> m_scriptState; 155 const RefPtr<ScriptState> m_scriptState;
156 TaskRunnerTimer<ScriptPromiseResolver> m_timer; 156 TaskRunnerTimer<ScriptPromiseResolver> m_timer;
157 Resolver m_resolver; 157 Resolver m_resolver;
158 ScopedPersistent<v8::Value> m_value; 158 ScopedPersistent<v8::Value> m_value;
159 159
160 // To support keepAliveWhilePending(), this object needs to keep itself 160 // To support keepAliveWhilePending(), this object needs to keep itself
161 // alive while in that state. 161 // alive while in that state.
162 SelfKeepAlive<ScriptPromiseResolver> m_keepAlive; 162 SelfKeepAlive<ScriptPromiseResolver> m_keepAlive;
163 163
164 #if ENABLE(ASSERT) 164 #if DCHECK_IS_ON()
165 // True if promise() is called. 165 // True if promise() is called.
166 bool m_isPromiseCalled; 166 bool m_isPromiseCalled = false;
167 #endif 167 #endif
168 }; 168 };
169 169
170 } // namespace blink 170 } // namespace blink
171 171
172 #endif // ScriptPromiseResolver_h 172 #endif // ScriptPromiseResolver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698