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

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

Issue 2365853002: Implement ReadableStreamBytesConsumer (Closed)
Patch Set: git cl format 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
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.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/fetch/Response.h" 5 #include "modules/fetch/Response.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8ArrayBuffer.h" 10 #include "bindings/core/v8/V8ArrayBuffer.h"
11 #include "bindings/core/v8/V8ArrayBufferView.h" 11 #include "bindings/core/v8/V8ArrayBufferView.h"
12 #include "bindings/core/v8/V8Binding.h" 12 #include "bindings/core/v8/V8Binding.h"
13 #include "bindings/core/v8/V8Blob.h" 13 #include "bindings/core/v8/V8Blob.h"
14 #include "bindings/core/v8/V8FormData.h" 14 #include "bindings/core/v8/V8FormData.h"
15 #include "bindings/core/v8/V8HiddenValue.h" 15 #include "bindings/core/v8/V8HiddenValue.h"
16 #include "bindings/core/v8/V8URLSearchParams.h" 16 #include "bindings/core/v8/V8URLSearchParams.h"
17 #include "core/dom/DOMArrayBuffer.h" 17 #include "core/dom/DOMArrayBuffer.h"
18 #include "core/dom/DOMArrayBufferView.h" 18 #include "core/dom/DOMArrayBufferView.h"
19 #include "core/dom/URLSearchParams.h" 19 #include "core/dom/URLSearchParams.h"
20 #include "core/fileapi/Blob.h" 20 #include "core/fileapi/Blob.h"
21 #include "core/html/FormData.h" 21 #include "core/html/FormData.h"
22 #include "core/streams/ReadableStreamOperations.h" 22 #include "core/streams/ReadableStreamOperations.h"
23 #include "modules/fetch/BlobBytesConsumer.h" 23 #include "modules/fetch/BlobBytesConsumer.h"
24 #include "modules/fetch/BodyStreamBuffer.h" 24 #include "modules/fetch/BodyStreamBuffer.h"
25 #include "modules/fetch/DataConsumerHandleUtil.h" 25 #include "modules/fetch/DataConsumerHandleUtil.h"
26 #include "modules/fetch/FormDataBytesConsumer.h" 26 #include "modules/fetch/FormDataBytesConsumer.h"
27 #include "modules/fetch/ReadableStreamDataConsumerHandle.h"
28 #include "modules/fetch/ResponseInit.h" 27 #include "modules/fetch/ResponseInit.h"
29 #include "platform/network/EncodedFormData.h" 28 #include "platform/network/EncodedFormData.h"
30 #include "platform/network/HTTPHeaderMap.h" 29 #include "platform/network/HTTPHeaderMap.h"
31 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" 30 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h"
32 #include "wtf/RefPtr.h" 31 #include "wtf/RefPtr.h"
33 #include <memory> 32 #include <memory>
34 33
35 namespace blink { 34 namespace blink {
36 35
37 namespace { 36 namespace {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return nullptr; 174 return nullptr;
176 bodyBuffer = 175 bodyBuffer =
177 new BodyStreamBuffer(scriptState, new FormDataBytesConsumer(string)); 176 new BodyStreamBuffer(scriptState, new FormDataBytesConsumer(string));
178 contentType = "text/plain;charset=UTF-8"; 177 contentType = "text/plain;charset=UTF-8";
179 } 178 }
180 Response* response = 179 Response* response =
181 create(scriptState, bodyBuffer, contentType, 180 create(scriptState, bodyBuffer, contentType,
182 ResponseInit(init, exceptionState), exceptionState); 181 ResponseInit(init, exceptionState), exceptionState);
183 if (!exceptionState.hadException() && !reader.isEmpty()) { 182 if (!exceptionState.hadException() && !reader.isEmpty()) {
184 // Add a hidden reference so that the weak persistent in the 183 // Add a hidden reference so that the weak persistent in the
185 // ReadableStreamDataConsumerHandle will be valid as long as the 184 // ReadableStreamBytesConsumer will be valid as long as the
186 // Response is valid. 185 // Response is valid.
187 v8::Local<v8::Value> wrapper = toV8(response, scriptState); 186 v8::Local<v8::Value> wrapper = toV8(response, scriptState);
188 if (wrapper.IsEmpty()) { 187 if (wrapper.IsEmpty()) {
189 exceptionState.throwTypeError("Cannot create a Response wrapper"); 188 exceptionState.throwTypeError("Cannot create a Response wrapper");
190 return nullptr; 189 return nullptr;
191 } 190 }
192 ASSERT(wrapper->IsObject()); 191 ASSERT(wrapper->IsObject());
193 V8HiddenValue::setHiddenValue( 192 V8HiddenValue::setHiddenValue(
194 scriptState, wrapper.As<v8::Object>(), 193 scriptState, wrapper.As<v8::Object>(),
195 V8HiddenValue::readableStreamReaderInResponse(scriptState->isolate()), 194 V8HiddenValue::readableStreamReaderInResponse(scriptState->isolate()),
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 462 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
464 } 463 }
465 464
466 DEFINE_TRACE(Response) { 465 DEFINE_TRACE(Response) {
467 Body::trace(visitor); 466 Body::trace(visitor);
468 visitor->trace(m_response); 467 visitor->trace(m_response);
469 visitor->trace(m_headers); 468 visitor->trace(m_headers);
470 } 469 }
471 470
472 } // namespace blink 471 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandleTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698