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

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

Issue 2177243002: Use per-frame TaskRunner instead of thread's default in DataConsumerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_consumer_handle_unique_ptr
Patch Set: update Created 4 years, 4 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/BodyStreamBuffer.h" 5 #include "modules/fetch/BodyStreamBuffer.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8HiddenValue.h" 8 #include "bindings/core/v8/V8HiddenValue.h"
9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
10 #include "core/dom/DOMArrayBuffer.h" 10 #include "core/dom/DOMArrayBuffer.h"
11 #include "core/dom/DOMTypedArray.h" 11 #include "core/dom/DOMTypedArray.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "core/dom/TaskRunnerHelper.h"
13 #include "core/streams/ReadableStreamController.h" 14 #include "core/streams/ReadableStreamController.h"
14 #include "core/streams/ReadableStreamOperations.h" 15 #include "core/streams/ReadableStreamOperations.h"
15 #include "core/workers/WorkerGlobalScope.h" 16 #include "core/workers/WorkerGlobalScope.h"
16 #include "modules/fetch/Body.h" 17 #include "modules/fetch/Body.h"
17 #include "modules/fetch/DataConsumerHandleUtil.h" 18 #include "modules/fetch/DataConsumerHandleUtil.h"
18 #include "modules/fetch/DataConsumerTee.h" 19 #include "modules/fetch/DataConsumerTee.h"
19 #include "modules/fetch/ReadableStreamDataConsumerHandle.h" 20 #include "modules/fetch/ReadableStreamDataConsumerHandle.h"
20 #include "platform/RuntimeEnabledFeatures.h" 21 #include "platform/RuntimeEnabledFeatures.h"
21 #include "platform/blob/BlobData.h" 22 #include "platform/blob/BlobData.h"
22 #include "platform/network/EncodedFormData.h" 23 #include "platform/network/EncodedFormData.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 97
97 Member<BodyStreamBuffer> m_buffer; 98 Member<BodyStreamBuffer> m_buffer;
98 Member<FetchDataLoader::Client> m_client; 99 Member<FetchDataLoader::Client> m_client;
99 }; 100 };
100 101
101 BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, std::unique_ptr<Fet chDataConsumerHandle> handle) 102 BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, std::unique_ptr<Fet chDataConsumerHandle> handle)
102 : UnderlyingSourceBase(scriptState) 103 : UnderlyingSourceBase(scriptState)
103 , m_scriptState(scriptState) 104 , m_scriptState(scriptState)
104 , m_handle(std::move(handle)) 105 , m_handle(std::move(handle))
105 , m_reader(m_handle->obtainFetchDataReader(this)) 106 , m_reader(m_handle->obtainFetchDataReader(this, TaskRunnerHelper::getUnthro ttledTaskRunner(scriptState)->clone()))
106 , m_madeFromReadableStream(false) 107 , m_madeFromReadableStream(false)
107 { 108 {
108 if (RuntimeEnabledFeatures::responseBodyWithV8ExtraStreamEnabled()) { 109 if (RuntimeEnabledFeatures::responseBodyWithV8ExtraStreamEnabled()) {
109 if (isTerminating(scriptState)) { 110 if (isTerminating(scriptState)) {
110 m_reader = nullptr; 111 m_reader = nullptr;
111 m_handle = nullptr; 112 m_handle = nullptr;
112 return; 113 return;
113 } 114 }
114 v8::Local<v8::Value> bodyValue = toV8(this, scriptState); 115 v8::Local<v8::Value> bodyValue = toV8(this, scriptState);
115 if (bodyValue.IsEmpty()) { 116 if (bodyValue.IsEmpty()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 209 }
209 return nullptr; 210 return nullptr;
210 } 211 }
211 212
212 void BodyStreamBuffer::startLoading(FetchDataLoader* loader, FetchDataLoader::Cl ient* client) 213 void BodyStreamBuffer::startLoading(FetchDataLoader* loader, FetchDataLoader::Cl ient* client)
213 { 214 {
214 ASSERT(!m_loader); 215 ASSERT(!m_loader);
215 ASSERT(m_scriptState->contextIsValid()); 216 ASSERT(m_scriptState->contextIsValid());
216 std::unique_ptr<FetchDataConsumerHandle> handle = releaseHandle(); 217 std::unique_ptr<FetchDataConsumerHandle> handle = releaseHandle();
217 m_loader = loader; 218 m_loader = loader;
218 loader->start(handle.get(), new LoaderClient(m_scriptState->getExecutionCont ext(), this, client)); 219 loader->start(handle.get(), new LoaderClient(m_scriptState->getExecutionCont ext(), this, client), TaskRunnerHelper::getUnthrottledTaskRunner(m_scriptState.g et())->clone());
219 } 220 }
220 221
221 void BodyStreamBuffer::tee(BodyStreamBuffer** branch1, BodyStreamBuffer** branch 2) 222 void BodyStreamBuffer::tee(BodyStreamBuffer** branch1, BodyStreamBuffer** branch 2)
222 { 223 {
223 DCHECK(!isStreamLocked()); 224 DCHECK(!isStreamLocked());
224 DCHECK(!isStreamDisturbed()); 225 DCHECK(!isStreamDisturbed());
225 *branch1 = nullptr; 226 *branch1 = nullptr;
226 *branch2 = nullptr; 227 *branch2 = nullptr;
227 228
228 if (m_madeFromReadableStream) { 229 if (m_madeFromReadableStream) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 return createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumer Handle()); 478 return createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumer Handle());
478 } 479 }
479 if (isErrored) 480 if (isErrored)
480 return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorD ataConsumerHandle()); 481 return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorD ataConsumerHandle());
481 482
482 DCHECK(handle); 483 DCHECK(handle);
483 return handle; 484 return handle;
484 } 485 }
485 486
486 } // namespace blink 487 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698