Chromium Code Reviews

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

Issue 1595713003: Make ReadableStreamOperations use ScriptValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment and add a couple asserts Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« 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/ReadableStreamOperations.h" 9 #include "bindings/core/v8/ReadableStreamOperations.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 115 matching lines...)
126 } else if (V8ArrayBuffer::hasInstance(body, isolate)) { 126 } else if (V8ArrayBuffer::hasInstance(body, isolate)) {
127 bodyHandle = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(b ody.As<v8::Object>())); 127 bodyHandle = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(b ody.As<v8::Object>()));
128 } else if (V8ArrayBufferView::hasInstance(body, isolate)) { 128 } else if (V8ArrayBufferView::hasInstance(body, isolate)) {
129 bodyHandle = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toIm pl(body.As<v8::Object>())); 129 bodyHandle = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toIm pl(body.As<v8::Object>()));
130 } else if (V8FormData::hasInstance(body, isolate)) { 130 } else if (V8FormData::hasInstance(body, isolate)) {
131 RefPtr<EncodedFormData> formData = V8FormData::toImpl(body.As<v8::Object >())->encodeMultiPartFormData(); 131 RefPtr<EncodedFormData> formData = V8FormData::toImpl(body.As<v8::Object >())->encodeMultiPartFormData();
132 // Here we handle formData->boundary() as a C-style string. See 132 // Here we handle formData->boundary() as a C-style string. See
133 // FormDataEncoder::generateUniqueBoundaryString. 133 // FormDataEncoder::generateUniqueBoundaryString.
134 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin g::ConstructFromLiteral) + formData->boundary().data(); 134 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin g::ConstructFromLiteral) + formData->boundary().data();
135 bodyHandle = FetchFormDataConsumerHandle::create(executionContext, formD ata.release()); 135 bodyHandle = FetchFormDataConsumerHandle::create(executionContext, formD ata.release());
136 } else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnab led() && ReadableStreamOperations::isReadableStream(scriptState, body)) { 136 } else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnab led() && ReadableStreamOperations::isReadableStream(scriptState, bodyValue)) {
137 bodyHandle = ReadableStreamDataConsumerHandle::create(scriptState, body) ; 137 bodyHandle = ReadableStreamDataConsumerHandle::create(scriptState, bodyV alue);
138 } else { 138 } else {
139 String string = toUSVString(isolate, body, exceptionState); 139 String string = toUSVString(isolate, body, exceptionState);
140 if (exceptionState.hadException()) 140 if (exceptionState.hadException())
141 return nullptr; 141 return nullptr;
142 bodyHandle = FetchFormDataConsumerHandle::create(string); 142 bodyHandle = FetchFormDataConsumerHandle::create(string);
143 contentType = "text/plain;charset=UTF-8"; 143 contentType = "text/plain;charset=UTF-8";
144 } 144 }
145 // TODO(yhirano): Add the URLSearchParams case. 145 // TODO(yhirano): Add the URLSearchParams case.
146 return create(executionContext, bodyHandle.release(), contentType, ResponseI nit(init, exceptionState), exceptionState); 146 return create(executionContext, bodyHandle.release(), contentType, ResponseI nit(init, exceptionState), exceptionState);
147 } 147 }
(...skipping 248 matching lines...)
396 } 396 }
397 397
398 DEFINE_TRACE(Response) 398 DEFINE_TRACE(Response)
399 { 399 {
400 Body::trace(visitor); 400 Body::trace(visitor);
401 visitor->trace(m_response); 401 visitor->trace(m_response);
402 visitor->trace(m_headers); 402 visitor->trace(m_headers);
403 } 403 }
404 404
405 } // namespace blink 405 } // 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