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

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

Issue 2433773006: Remove ExecutionContext::activeDOMObjectsAreStopped()
Patch Set: Created 4 years, 2 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 #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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 }; 85 };
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())
97 return; 96 return;
98 ScriptState::Scope scope(resolver()->getScriptState()); 97 ScriptState::Scope scope(resolver()->getScriptState());
99 v8::Isolate* isolate = resolver()->getScriptState()->isolate(); 98 v8::Isolate* isolate = resolver()->getScriptState()->isolate();
100 v8::Local<v8::String> inputString = v8String(isolate, string); 99 v8::Local<v8::String> inputString = v8String(isolate, string);
101 v8::TryCatch trycatch(isolate); 100 v8::TryCatch trycatch(isolate);
102 v8::Local<v8::Value> parsed; 101 v8::Local<v8::Value> parsed;
103 if (v8Call(v8::JSON::Parse(isolate, inputString), parsed, trycatch)) 102 if (v8Call(v8::JSON::Parse(isolate, inputString), parsed, trycatch))
104 resolver()->resolve(parsed); 103 resolver()->resolve(parsed);
105 else 104 else
106 resolver()->reject(trycatch.Exception()); 105 resolver()->reject(trycatch.Exception());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 209
211 bool Body::bodyUsed() { 210 bool Body::bodyUsed() {
212 return bodyBuffer() && bodyBuffer()->isStreamDisturbed(); 211 return bodyBuffer() && bodyBuffer()->isStreamDisturbed();
213 } 212 }
214 213
215 bool Body::isBodyLocked() { 214 bool Body::isBodyLocked() {
216 return bodyBuffer() && bodyBuffer()->isStreamLocked(); 215 return bodyBuffer() && bodyBuffer()->isStreamLocked();
217 } 216 }
218 217
219 bool Body::hasPendingActivity() const { 218 bool Body::hasPendingActivity() const {
220 if (!getExecutionContext() || 219 if (!getExecutionContext())
221 getExecutionContext()->activeDOMObjectsAreStopped())
222 return false; 220 return false;
223 if (!bodyBuffer()) 221 if (!bodyBuffer())
224 return false; 222 return false;
225 return bodyBuffer()->hasPendingActivity(); 223 return bodyBuffer()->hasPendingActivity();
226 } 224 }
227 225
228 Body::Body(ExecutionContext* context) 226 Body::Body(ExecutionContext* context)
229 : ActiveScriptWrappable(this), ContextLifecycleObserver(context) {} 227 : ActiveScriptWrappable(this), ContextLifecycleObserver(context) {}
230 228
231 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) { 229 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) {
232 if (isBodyLocked() || bodyUsed()) 230 if (isBodyLocked() || bodyUsed())
233 return ScriptPromise::reject( 231 return ScriptPromise::reject(
234 scriptState, V8ThrowException::createTypeError(scriptState->isolate(), 232 scriptState, V8ThrowException::createTypeError(scriptState->isolate(),
235 "Already read")); 233 "Already read"));
236 return ScriptPromise(); 234 return ScriptPromise();
237 } 235 }
238 236
239 } // namespace blink 237 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698