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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 <memory> 7 #include <memory>
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 response->setResponseTime(webResponse.responseTime()); 56 response->setResponseTime(webResponse.responseTime());
57 response->setCacheStorageCacheName(webResponse.cacheStorageCacheName()); 57 response->setCacheStorageCacheName(webResponse.cacheStorageCacheName());
58 58
59 for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(), 59 for (HTTPHeaderMap::const_iterator i = webResponse.headers().begin(),
60 end = webResponse.headers().end(); 60 end = webResponse.headers().end();
61 i != end; ++i) { 61 i != end; ++i) {
62 response->headerList()->append(i->key, i->value); 62 response->headerList()->append(i->key, i->value);
63 } 63 }
64 64
65 response->replaceBodyStreamBuffer(new BodyStreamBuffer( 65 response->replaceBodyStreamBuffer(new BodyStreamBuffer(
66 scriptState, new BlobBytesConsumer(scriptState->getExecutionContext(), 66 scriptState,
67 webResponse.blobDataHandle()))); 67 new BlobBytesConsumer(scriptState->getExecutionContext(),
68 webResponse.blobDataHandle())));
68 69
69 // Filter the response according to |webResponse|'s ResponseType. 70 // Filter the response according to |webResponse|'s ResponseType.
70 switch (webResponse.responseType()) { 71 switch (webResponse.responseType()) {
71 case WebServiceWorkerResponseTypeBasic: 72 case WebServiceWorkerResponseTypeBasic:
72 response = response->createBasicFilteredResponse(); 73 response = response->createBasicFilteredResponse();
73 break; 74 break;
74 case WebServiceWorkerResponseTypeCORS: { 75 case WebServiceWorkerResponseTypeCORS: {
75 HTTPHeaderSet headerNames; 76 HTTPHeaderSet headerNames;
76 for (const auto& header : webResponse.corsExposedHeaderNames()) 77 for (const auto& header : webResponse.corsExposedHeaderNames())
77 headerNames.insert(String(header)); 78 headerNames.insert(String(header));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (bodyValue.isUndefined() || bodyValue.isNull()) { 140 if (bodyValue.isUndefined() || bodyValue.isNull()) {
140 // Note: The IDL processor cannot handle this situation. See 141 // Note: The IDL processor cannot handle this situation. See
141 // https://crbug.com/335871. 142 // https://crbug.com/335871.
142 } else if (V8Blob::hasInstance(body, isolate)) { 143 } else if (V8Blob::hasInstance(body, isolate)) {
143 Blob* blob = V8Blob::toImpl(body.As<v8::Object>()); 144 Blob* blob = V8Blob::toImpl(body.As<v8::Object>());
144 bodyBuffer = new BodyStreamBuffer( 145 bodyBuffer = new BodyStreamBuffer(
145 scriptState, 146 scriptState,
146 new BlobBytesConsumer(executionContext, blob->blobDataHandle())); 147 new BlobBytesConsumer(executionContext, blob->blobDataHandle()));
147 contentType = blob->type(); 148 contentType = blob->type();
148 } else if (body->IsArrayBuffer()) { 149 } else if (body->IsArrayBuffer()) {
149 bodyBuffer = new BodyStreamBuffer( 150 bodyBuffer =
150 scriptState, new FormDataBytesConsumer( 151 new BodyStreamBuffer(scriptState,
151 V8ArrayBuffer::toImpl(body.As<v8::Object>()))); 152 new FormDataBytesConsumer(
153 V8ArrayBuffer::toImpl(body.As<v8::Object>())));
152 } else if (body->IsArrayBufferView()) { 154 } else if (body->IsArrayBufferView()) {
153 bodyBuffer = new BodyStreamBuffer( 155 bodyBuffer = new BodyStreamBuffer(
154 scriptState, new FormDataBytesConsumer( 156 scriptState,
155 V8ArrayBufferView::toImpl(body.As<v8::Object>()))); 157 new FormDataBytesConsumer(
158 V8ArrayBufferView::toImpl(body.As<v8::Object>())));
156 } else if (V8FormData::hasInstance(body, isolate)) { 159 } else if (V8FormData::hasInstance(body, isolate)) {
157 RefPtr<EncodedFormData> formData = 160 RefPtr<EncodedFormData> formData =
158 V8FormData::toImpl(body.As<v8::Object>())->encodeMultiPartFormData(); 161 V8FormData::toImpl(body.As<v8::Object>())->encodeMultiPartFormData();
159 // Here we handle formData->boundary() as a C-style string. See 162 // Here we handle formData->boundary() as a C-style string. See
160 // FormDataEncoder::generateUniqueBoundaryString. 163 // FormDataEncoder::generateUniqueBoundaryString.
161 contentType = AtomicString("multipart/form-data; boundary=") + 164 contentType = AtomicString("multipart/form-data; boundary=") +
162 formData->boundary().data(); 165 formData->boundary().data();
163 bodyBuffer = new BodyStreamBuffer( 166 bodyBuffer = new BodyStreamBuffer(
164 scriptState, 167 scriptState,
165 new FormDataBytesConsumer(executionContext, formData.release())); 168 new FormDataBytesConsumer(executionContext, formData.release()));
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 460 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
458 } 461 }
459 462
460 DEFINE_TRACE(Response) { 463 DEFINE_TRACE(Response) {
461 Body::trace(visitor); 464 Body::trace(visitor);
462 visitor->trace(m_response); 465 visitor->trace(m_response);
463 visitor->trace(m_headers); 466 visitor->trace(m_headers);
464 } 467 }
465 468
466 } // namespace blink 469 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698