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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.cpp

Issue 1899163002: BodyStreamBuffer's drainAs* function should lock stream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@body-stream-buffer-test-refactoring
Patch Set: Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchManager.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/serviceworkers/RespondWithObserver.h" 5 #include "modules/serviceworkers/RespondWithObserver.h"
6 6
7 #include "bindings/core/v8/ScriptFunction.h" 7 #include "bindings/core/v8/ScriptFunction.h"
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptValue.h" 9 #include "bindings/core/v8/ScriptValue.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 if (response->bodyUsed()) { 236 if (response->bodyUsed()) {
237 responseWasRejected(WebServiceWorkerResponseErrorBodyUsed); 237 responseWasRejected(WebServiceWorkerResponseErrorBodyUsed);
238 return; 238 return;
239 } 239 }
240 240
241 WebServiceWorkerResponse webResponse; 241 WebServiceWorkerResponse webResponse;
242 response->populateWebServiceWorkerResponse(webResponse); 242 response->populateWebServiceWorkerResponse(webResponse);
243 BodyStreamBuffer* buffer = response->internalBodyBuffer(); 243 BodyStreamBuffer* buffer = response->internalBodyBuffer();
244 if (buffer) { 244 if (buffer) {
245 RefPtr<BlobDataHandle> blobDataHandle = buffer->drainAsBlobDataHandle(Fe tchDataConsumerHandle::Reader::AllowBlobWithInvalidSize); 245 RefPtr<BlobDataHandle> blobDataHandle = buffer->drainAsBlobDataHandle(ge tExecutionContext(), FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize);
246 if (blobDataHandle) { 246 if (blobDataHandle) {
247 webResponse.setBlobDataHandle(blobDataHandle); 247 webResponse.setBlobDataHandle(blobDataHandle);
248 } else { 248 } else {
249 Stream* outStream = Stream::create(getExecutionContext(), ""); 249 Stream* outStream = Stream::create(getExecutionContext(), "");
250 webResponse.setStreamURL(outStream->url()); 250 webResponse.setStreamURL(outStream->url());
251 buffer->startLoading(getExecutionContext(), FetchDataLoader::createL oaderAsStream(outStream), new NoopLoaderClient); 251 buffer->startLoading(getExecutionContext(), FetchDataLoader::createL oaderAsStream(outStream), new NoopLoaderClient);
252 } 252 }
253 } 253 }
254 ServiceWorkerGlobalScopeClient::from(getExecutionContext())->didHandleFetchE vent(m_eventID, webResponse); 254 ServiceWorkerGlobalScopeClient::from(getExecutionContext())->didHandleFetchE vent(m_eventID, webResponse);
255 m_state = Done; 255 m_state = Done;
256 } 256 }
257 257
258 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode requestMode, WebURLRequ est::FrameType frameType, WebURLRequest::RequestContext requestContext) 258 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode requestMode, WebURLRequ est::FrameType frameType, WebURLRequest::RequestContext requestContext)
259 : ContextLifecycleObserver(context) 259 : ContextLifecycleObserver(context)
260 , m_eventID(eventID) 260 , m_eventID(eventID)
261 , m_requestURL(requestURL) 261 , m_requestURL(requestURL)
262 , m_requestMode(requestMode) 262 , m_requestMode(requestMode)
263 , m_frameType(frameType) 263 , m_frameType(frameType)
264 , m_requestContext(requestContext) 264 , m_requestContext(requestContext)
265 , m_state(Initial) 265 , m_state(Initial)
266 { 266 {
267 } 267 }
268 268
269 DEFINE_TRACE(RespondWithObserver) 269 DEFINE_TRACE(RespondWithObserver)
270 { 270 {
271 ContextLifecycleObserver::trace(visitor); 271 ContextLifecycleObserver::trace(visitor);
272 } 272 }
273 273
274 } // namespace blink 274 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchManager.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698