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

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

Issue 2526293002: [wrapper-tracing] Untangle non-trivial mixin ctors (Closed)
Patch Set: s/new BodyStreamBuffer/BodyStreamBuffer::create/ Created 4 years 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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 response->setStatusMessage(webResponse.statusText()); 49 response->setStatusMessage(webResponse.statusText());
50 response->setResponseTime(webResponse.responseTime()); 50 response->setResponseTime(webResponse.responseTime());
51 response->setCacheStorageCacheName(webResponse.cacheStorageCacheName()); 51 response->setCacheStorageCacheName(webResponse.cacheStorageCacheName());
52 52
53 for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(), 53 for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(),
54 end = webResponse.headers().end(); 54 end = webResponse.headers().end();
55 i != end; ++i) { 55 i != end; ++i) {
56 response->headerList()->append(i->key, i->value); 56 response->headerList()->append(i->key, i->value);
57 } 57 }
58 58
59 response->replaceBodyStreamBuffer(new BodyStreamBuffer( 59 response->replaceBodyStreamBuffer(BodyStreamBuffer::create(
60 scriptState, new BlobBytesConsumer(scriptState->getExecutionContext(), 60 scriptState, new BlobBytesConsumer(scriptState->getExecutionContext(),
61 webResponse.blobDataHandle()))); 61 webResponse.blobDataHandle())));
62 62
63 // Filter the response according to |webResponse|'s ResponseType. 63 // Filter the response according to |webResponse|'s ResponseType.
64 switch (webResponse.responseType()) { 64 switch (webResponse.responseType()) {
65 case WebServiceWorkerResponseTypeBasic: 65 case WebServiceWorkerResponseTypeBasic:
66 response = response->createBasicFilteredResponse(); 66 response = response->createBasicFilteredResponse();
67 break; 67 break;
68 case WebServiceWorkerResponseTypeCORS: { 68 case WebServiceWorkerResponseTypeCORS: {
69 HTTPHeaderSet headerNames; 69 HTTPHeaderSet headerNames;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 v8::Isolate* isolate = scriptState->isolate(); 129 v8::Isolate* isolate = scriptState->isolate();
130 ExecutionContext* executionContext = scriptState->getExecutionContext(); 130 ExecutionContext* executionContext = scriptState->getExecutionContext();
131 131
132 BodyStreamBuffer* bodyBuffer = nullptr; 132 BodyStreamBuffer* bodyBuffer = nullptr;
133 String contentType; 133 String contentType;
134 if (bodyValue.isUndefined() || bodyValue.isNull()) { 134 if (bodyValue.isUndefined() || bodyValue.isNull()) {
135 // Note: The IDL processor cannot handle this situation. See 135 // Note: The IDL processor cannot handle this situation. See
136 // https://crbug.com/335871. 136 // https://crbug.com/335871.
137 } else if (V8Blob::hasInstance(body, isolate)) { 137 } else if (V8Blob::hasInstance(body, isolate)) {
138 Blob* blob = V8Blob::toImpl(body.As<v8::Object>()); 138 Blob* blob = V8Blob::toImpl(body.As<v8::Object>());
139 bodyBuffer = new BodyStreamBuffer( 139 bodyBuffer = BodyStreamBuffer::create(
140 scriptState, 140 scriptState,
141 new BlobBytesConsumer(executionContext, blob->blobDataHandle())); 141 new BlobBytesConsumer(executionContext, blob->blobDataHandle()));
142 contentType = blob->type(); 142 contentType = blob->type();
143 } else if (body->IsArrayBuffer()) { 143 } else if (body->IsArrayBuffer()) {
144 bodyBuffer = new BodyStreamBuffer( 144 bodyBuffer = BodyStreamBuffer::create(
145 scriptState, new FormDataBytesConsumer( 145 scriptState, new FormDataBytesConsumer(
146 V8ArrayBuffer::toImpl(body.As<v8::Object>()))); 146 V8ArrayBuffer::toImpl(body.As<v8::Object>())));
147 } else if (body->IsArrayBufferView()) { 147 } else if (body->IsArrayBufferView()) {
148 bodyBuffer = new BodyStreamBuffer( 148 bodyBuffer = BodyStreamBuffer::create(
149 scriptState, new FormDataBytesConsumer( 149 scriptState, new FormDataBytesConsumer(
150 V8ArrayBufferView::toImpl(body.As<v8::Object>()))); 150 V8ArrayBufferView::toImpl(body.As<v8::Object>())));
151 } else if (V8FormData::hasInstance(body, isolate)) { 151 } else if (V8FormData::hasInstance(body, isolate)) {
152 RefPtr<EncodedFormData> formData = 152 RefPtr<EncodedFormData> formData =
153 V8FormData::toImpl(body.As<v8::Object>())->encodeMultiPartFormData(); 153 V8FormData::toImpl(body.As<v8::Object>())->encodeMultiPartFormData();
154 // Here we handle formData->boundary() as a C-style string. See 154 // Here we handle formData->boundary() as a C-style string. See
155 // FormDataEncoder::generateUniqueBoundaryString. 155 // FormDataEncoder::generateUniqueBoundaryString.
156 contentType = AtomicString("multipart/form-data; boundary=") + 156 contentType = AtomicString("multipart/form-data; boundary=") +
157 formData->boundary().data(); 157 formData->boundary().data();
158 bodyBuffer = new BodyStreamBuffer( 158 bodyBuffer = BodyStreamBuffer::create(
159 scriptState, 159 scriptState,
160 new FormDataBytesConsumer(executionContext, formData.release())); 160 new FormDataBytesConsumer(executionContext, formData.release()));
161 } else if (V8URLSearchParams::hasInstance(body, isolate)) { 161 } else if (V8URLSearchParams::hasInstance(body, isolate)) {
162 RefPtr<EncodedFormData> formData = 162 RefPtr<EncodedFormData> formData =
163 V8URLSearchParams::toImpl(body.As<v8::Object>())->toEncodedFormData(); 163 V8URLSearchParams::toImpl(body.As<v8::Object>())->toEncodedFormData();
164 bodyBuffer = new BodyStreamBuffer( 164 bodyBuffer = BodyStreamBuffer::create(
165 scriptState, 165 scriptState,
166 new FormDataBytesConsumer(executionContext, formData.release())); 166 new FormDataBytesConsumer(executionContext, formData.release()));
167 contentType = "application/x-www-form-urlencoded;charset=UTF-8"; 167 contentType = "application/x-www-form-urlencoded;charset=UTF-8";
168 } else if (ReadableStreamOperations::isReadableStream(scriptState, 168 } else if (ReadableStreamOperations::isReadableStream(scriptState,
169 bodyValue)) { 169 bodyValue)) {
170 bodyBuffer = new BodyStreamBuffer(scriptState, bodyValue); 170 bodyBuffer = BodyStreamBuffer::create(scriptState, bodyValue);
171 } else { 171 } else {
172 String string = toUSVString(isolate, body, exceptionState); 172 String string = toUSVString(isolate, body, exceptionState);
173 if (exceptionState.hadException()) 173 if (exceptionState.hadException())
174 return nullptr; 174 return nullptr;
175 bodyBuffer = 175 bodyBuffer = BodyStreamBuffer::create(scriptState,
176 new BodyStreamBuffer(scriptState, new FormDataBytesConsumer(string)); 176 new FormDataBytesConsumer(string));
177 contentType = "text/plain;charset=UTF-8"; 177 contentType = "text/plain;charset=UTF-8";
178 } 178 }
179 Response* response = 179 Response* response =
180 create(scriptState, bodyBuffer, contentType, 180 create(scriptState, bodyBuffer, contentType,
181 ResponseInit(init, exceptionState), exceptionState); 181 ResponseInit(init, exceptionState), exceptionState);
182 if (!exceptionState.hadException() && !reader.isEmpty()) { 182 if (!exceptionState.hadException() && !reader.isEmpty()) {
183 // Add a hidden reference so that the weak persistent in the 183 // Add a hidden reference so that the weak persistent in the
184 // ReadableStreamBytesConsumer will be valid as long as the 184 // ReadableStreamBytesConsumer will be valid as long as the
185 // Response is valid. 185 // Response is valid.
186 v8::Local<v8::Value> wrapper = toV8(response, scriptState); 186 v8::Local<v8::Value> wrapper = toV8(response, scriptState);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 461 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
462 } 462 }
463 463
464 DEFINE_TRACE(Response) { 464 DEFINE_TRACE(Response) {
465 Body::trace(visitor); 465 Body::trace(visitor);
466 visitor->trace(m_response); 466 visitor->trace(m_response);
467 visitor->trace(m_headers); 467 visitor->trace(m_headers);
468 } 468 }
469 469
470 } // namespace blink 470 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698