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

Side by Side Diff: Source/modules/fetch/FetchManager.cpp

Issue 1233573002: [Fetch API] Remove DrainingBuffer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/fetch/BodyStreamBufferTest.cpp ('k') | Source/modules/fetch/FetchRequestData.h » ('j') | 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 "config.h" 5 #include "config.h"
6 #include "modules/fetch/FetchManager.h" 6 #include "modules/fetch/FetchManager.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 break; 114 break;
115 case WebURLRequest::FetchRequestModeNoCORS: 115 case WebURLRequest::FetchRequestModeNoCORS:
116 m_request->setResponseTainting(FetchRequestData::OpaqueTainting); 116 m_request->setResponseTainting(FetchRequestData::OpaqueTainting);
117 break; 117 break;
118 case WebURLRequest::FetchRequestModeCORS: 118 case WebURLRequest::FetchRequestModeCORS:
119 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 119 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
120 m_request->setResponseTainting(FetchRequestData::CORSTainting); 120 m_request->setResponseTainting(FetchRequestData::CORSTainting);
121 break; 121 break;
122 } 122 }
123 } 123 }
124 FetchResponseData* responseData = FetchResponseData::createWithBuffer(BodySt reamBuffer::create(createFetchDataConsumerHandleFromWebHandle(handle))); 124 FetchResponseData* responseData = FetchResponseData::createWithBuffer(new Bo dyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(handle)));
125 responseData->setStatus(response.httpStatusCode()); 125 responseData->setStatus(response.httpStatusCode());
126 responseData->setStatusMessage(response.httpStatusText()); 126 responseData->setStatusMessage(response.httpStatusText());
127 for (auto& it : response.httpHeaderFields()) 127 for (auto& it : response.httpHeaderFields())
128 responseData->headerList()->append(it.key, it.value); 128 responseData->headerList()->append(it.key, it.value);
129 responseData->setURL(response.url()); 129 responseData->setURL(response.url());
130 responseData->setMIMEType(response.mimeType()); 130 responseData->setMIMEType(response.mimeType());
131 131
132 FetchResponseData* taintedResponse = responseData; 132 FetchResponseData* taintedResponse = responseData;
133 switch (m_request->tainting()) { 133 switch (m_request->tainting()) {
134 case FetchRequestData::BasicTainting: 134 case FetchRequestData::BasicTainting:
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 ResourceRequest request(m_request->url()); 320 ResourceRequest request(m_request->url());
321 request.setRequestContext(m_request->context()); 321 request.setRequestContext(m_request->context());
322 request.setHTTPMethod(m_request->method()); 322 request.setHTTPMethod(m_request->method());
323 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list(); 323 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list();
324 for (size_t i = 0; i < list.size(); ++i) { 324 for (size_t i = 0; i < list.size(); ++i) {
325 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second)); 325 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second));
326 } 326 }
327 327
328 if (m_request->method() != "GET" && m_request->method() != "HEAD") { 328 if (m_request->method() != "GET" && m_request->method() != "HEAD") {
329 if (BodyStreamBuffer* buffer = m_request->buffer()) { 329 if (BodyStreamBuffer* buffer = m_request->buffer()) {
330 RefPtr<BlobDataHandle> blobDataHandle = buffer->handle()->obtainRead er(nullptr)->drainAsBlobDataHandle(FetchDataConsumerHandle::Reader::AllowBlobWit hInvalidSize); 330 RefPtr<BlobDataHandle> blobDataHandle = buffer->drainAsBlobDataHandl e(FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize);
331 RefPtr<FormData> httpBody(FormData::create()); 331 RefPtr<FormData> httpBody(FormData::create());
332 if (blobDataHandle) 332 if (blobDataHandle)
333 httpBody->appendBlob(blobDataHandle->uuid(), blobDataHandle); 333 httpBody->appendBlob(blobDataHandle->uuid(), blobDataHandle);
334 request.setHTTPBody(httpBody); 334 request.setHTTPBody(httpBody);
335 } 335 }
336 } 336 }
337 337
338 request.setUseStreamOnResponse(true); 338 request.setUseStreamOnResponse(true);
339 339
340 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer| 340 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer|
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 454
455 DEFINE_TRACE(FetchManager) 455 DEFINE_TRACE(FetchManager)
456 { 456 {
457 #if ENABLE(OILPAN) 457 #if ENABLE(OILPAN)
458 visitor->trace(m_executionContext); 458 visitor->trace(m_executionContext);
459 visitor->trace(m_loaders); 459 visitor->trace(m_loaders);
460 #endif 460 #endif
461 } 461 }
462 462
463 } // namespace blink 463 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/fetch/BodyStreamBufferTest.cpp ('k') | Source/modules/fetch/FetchRequestData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698