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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Body.cpp

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 #include "modules/fetch/Body.h" 5 #include "modules/fetch/Body.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/V8ArrayBuffer.h" 9 #include "bindings/core/v8/V8ArrayBuffer.h"
10 #include "bindings/core/v8/V8ThrowException.h" 10 #include "bindings/core/v8/V8ThrowException.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 class BodyJsonConsumer final : public BodyConsumerBase { 87 class BodyJsonConsumer final : public BodyConsumerBase {
88 WTF_MAKE_NONCOPYABLE(BodyJsonConsumer); 88 WTF_MAKE_NONCOPYABLE(BodyJsonConsumer);
89 89
90 public: 90 public:
91 explicit BodyJsonConsumer(ScriptPromiseResolver* resolver) 91 explicit BodyJsonConsumer(ScriptPromiseResolver* resolver)
92 : BodyConsumerBase(resolver) {} 92 : BodyConsumerBase(resolver) {}
93 93
94 void didFetchDataLoadedString(const String& string) override { 94 void didFetchDataLoadedString(const String& string) override {
95 if (!resolver()->getExecutionContext() || 95 if (!resolver()->getExecutionContext() ||
96 resolver()->getExecutionContext()->activeDOMObjectsAreStopped()) 96 resolver()->getExecutionContext()->isContextDestroyed())
97 return; 97 return;
98 ScriptState::Scope scope(resolver()->getScriptState()); 98 ScriptState::Scope scope(resolver()->getScriptState());
99 v8::Isolate* isolate = resolver()->getScriptState()->isolate(); 99 v8::Isolate* isolate = resolver()->getScriptState()->isolate();
100 v8::Local<v8::String> inputString = v8String(isolate, string); 100 v8::Local<v8::String> inputString = v8String(isolate, string);
101 v8::TryCatch trycatch(isolate); 101 v8::TryCatch trycatch(isolate);
102 v8::Local<v8::Value> parsed; 102 v8::Local<v8::Value> parsed;
103 if (v8Call(v8::JSON::Parse(isolate, inputString), parsed, trycatch)) 103 if (v8Call(v8::JSON::Parse(isolate, inputString), parsed, trycatch))
104 resolver()->resolve(parsed); 104 resolver()->resolve(parsed);
105 else 105 else
106 resolver()->reject(trycatch.Exception()); 106 resolver()->reject(trycatch.Exception());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 bool Body::bodyUsed() { 211 bool Body::bodyUsed() {
212 return bodyBuffer() && bodyBuffer()->isStreamDisturbed(); 212 return bodyBuffer() && bodyBuffer()->isStreamDisturbed();
213 } 213 }
214 214
215 bool Body::isBodyLocked() { 215 bool Body::isBodyLocked() {
216 return bodyBuffer() && bodyBuffer()->isStreamLocked(); 216 return bodyBuffer() && bodyBuffer()->isStreamLocked();
217 } 217 }
218 218
219 bool Body::hasPendingActivity() const { 219 bool Body::hasPendingActivity() const {
220 if (!getExecutionContext() || 220 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed())
221 getExecutionContext()->activeDOMObjectsAreStopped())
222 return false; 221 return false;
223 if (!bodyBuffer()) 222 if (!bodyBuffer())
224 return false; 223 return false;
225 return bodyBuffer()->hasPendingActivity(); 224 return bodyBuffer()->hasPendingActivity();
226 } 225 }
227 226
228 Body::Body(ExecutionContext* context) 227 Body::Body(ExecutionContext* context)
229 : ActiveScriptWrappable(this), ContextLifecycleObserver(context) {} 228 : ActiveScriptWrappable(this), ContextLifecycleObserver(context) {}
230 229
231 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) { 230 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) {
232 if (isBodyLocked() || bodyUsed()) 231 if (isBodyLocked() || bodyUsed())
233 return ScriptPromise::reject( 232 return ScriptPromise::reject(
234 scriptState, V8ThrowException::createTypeError(scriptState->isolate(), 233 scriptState, V8ThrowException::createTypeError(scriptState->isolate(),
235 "Already read")); 234 "Already read"));
236 return ScriptPromise(); 235 return ScriptPromise();
237 } 236 }
238 237
239 } // namespace blink 238 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698