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

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

Issue 2365853002: Implement ReadableStreamBytesConsumer (Closed)
Patch Set: fix 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/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" 27 #include "modules/fetch/ReadableStreamBytesConsumer.h"
hiroshige 2016/09/30 06:35:15 nit: is this include needed? (no references to Rea
yhirano 2016/09/30 09:01:02 Done.
28 #include "modules/fetch/ResponseInit.h" 28 #include "modules/fetch/ResponseInit.h"
29 #include "platform/network/EncodedFormData.h" 29 #include "platform/network/EncodedFormData.h"
30 #include "platform/network/HTTPHeaderMap.h" 30 #include "platform/network/HTTPHeaderMap.h"
31 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" 31 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h"
32 #include "wtf/RefPtr.h" 32 #include "wtf/RefPtr.h"
33 #include <memory> 33 #include <memory>
34 34
35 namespace blink { 35 namespace blink {
36 36
37 namespace { 37 namespace {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } else { 153 } else {
154 String string = toUSVString(isolate, body, exceptionState); 154 String string = toUSVString(isolate, body, exceptionState);
155 if (exceptionState.hadException()) 155 if (exceptionState.hadException())
156 return nullptr; 156 return nullptr;
157 bodyBuffer = new BodyStreamBuffer(scriptState, new FormDataBytesConsumer (string)); 157 bodyBuffer = new BodyStreamBuffer(scriptState, new FormDataBytesConsumer (string));
158 contentType = "text/plain;charset=UTF-8"; 158 contentType = "text/plain;charset=UTF-8";
159 } 159 }
160 Response* response = create(scriptState, bodyBuffer, contentType, ResponseIn it(init, exceptionState), exceptionState); 160 Response* response = create(scriptState, bodyBuffer, contentType, ResponseIn it(init, exceptionState), exceptionState);
161 if (!exceptionState.hadException() && !reader.isEmpty()) { 161 if (!exceptionState.hadException() && !reader.isEmpty()) {
162 // Add a hidden reference so that the weak persistent in the 162 // Add a hidden reference so that the weak persistent in the
163 // ReadableStreamDataConsumerHandle will be valid as long as the 163 // ReadableStreamBytesConsumer will be valid as long as the
164 // Response is valid. 164 // Response is valid.
165 v8::Local<v8::Value> wrapper = toV8(response, scriptState); 165 v8::Local<v8::Value> wrapper = toV8(response, scriptState);
166 if (wrapper.IsEmpty()) { 166 if (wrapper.IsEmpty()) {
167 exceptionState.throwTypeError("Cannot create a Response wrapper"); 167 exceptionState.throwTypeError("Cannot create a Response wrapper");
168 return nullptr; 168 return nullptr;
169 } 169 }
170 ASSERT(wrapper->IsObject()); 170 ASSERT(wrapper->IsObject());
171 V8HiddenValue::setHiddenValue(scriptState, wrapper.As<v8::Object>(), V8H iddenValue::readableStreamReaderInResponse(scriptState->isolate()), reader.v8Val ue()); 171 V8HiddenValue::setHiddenValue(scriptState, wrapper.As<v8::Object>(), V8H iddenValue::readableStreamReaderInResponse(scriptState->isolate()), reader.v8Val ue());
172 } 172 }
173 return response; 173 return response;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 438 }
439 439
440 DEFINE_TRACE(Response) 440 DEFINE_TRACE(Response)
441 { 441 {
442 Body::trace(visitor); 442 Body::trace(visitor);
443 visitor->trace(m_response); 443 visitor->trace(m_response);
444 visitor->trace(m_headers); 444 visitor->trace(m_headers);
445 } 445 }
446 446
447 } // namespace blink 447 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698