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

Side by Side Diff: Source/modules/serviceworkers/Request.cpp

Issue 786893004: [ServiceWorker] Use BodyStreamBuffer as the body data of the Response object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/modules/serviceworkers/Request.h ('k') | Source/modules/serviceworkers/Response.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 "Request.h" 6 #include "Request.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 Request::Request(ExecutionContext* context, const WebServiceWorkerRequest& webRe quest) 261 Request::Request(ExecutionContext* context, const WebServiceWorkerRequest& webRe quest)
262 : Body(context) 262 : Body(context)
263 , m_request(FetchRequestData::create(webRequest)) 263 , m_request(FetchRequestData::create(webRequest))
264 , m_headers(Headers::create(m_request->headerList())) 264 , m_headers(Headers::create(m_request->headerList()))
265 { 265 {
266 m_headers->setGuard(Headers::RequestGuard); 266 m_headers->setGuard(Headers::RequestGuard);
267 } 267 }
268 268
269 Request::Request(const Request& copy_from) 269 Request::Request(const Request& copy_from)
270 : Body(copy_from) 270 : Body(copy_from)
271 , m_request(copy_from.m_request) 271 , m_request(copy_from.m_request->createCopy())
272 , m_headers(copy_from.m_headers->createCopy()) 272 , m_headers(Headers::create(m_request->headerList()))
273 { 273 {
274 } 274 }
275 275
276 276
277 String Request::method() const 277 String Request::method() const
278 { 278 {
279 // "The method attribute's getter must return request's method." 279 // "The method attribute's getter must return request's method."
280 return m_request->method(); 280 return m_request->method();
281 } 281 }
282 282
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 ASSERT_NOT_REACHED(); 335 ASSERT_NOT_REACHED();
336 return ""; 336 return "";
337 } 337 }
338 338
339 Request* Request::clone(ExceptionState& exceptionState) const 339 Request* Request::clone(ExceptionState& exceptionState) const
340 { 340 {
341 if (bodyUsed()) { 341 if (bodyUsed()) {
342 exceptionState.throwTypeError("Request body is already used"); 342 exceptionState.throwTypeError("Request body is already used");
343 return nullptr; 343 return nullptr;
344 } 344 }
345 if (streamAccessed()) {
346 // FIXME: Support clone() of the stream accessed Request.
347 exceptionState.throwTypeError("clone() of the Request which .body is acc essed is not supported.");
348 return nullptr;
349 }
345 return Request::create(*this); 350 return Request::create(*this);
346 } 351 }
347 352
348 void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques t) const 353 void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques t) const
349 { 354 {
350 webRequest.setMethod(method()); 355 webRequest.setMethod(method());
351 webRequest.setURL(m_request->url()); 356 webRequest.setURL(m_request->url());
352 357
353 const FetchHeaderList* headerList = m_headers->headerList(); 358 const FetchHeaderList* headerList = m_headers->headerList();
354 for (size_t i = 0, size = headerList->size(); i < size; ++i) { 359 for (size_t i = 0, size = headerList->size(); i < size; ++i) {
355 const FetchHeaderList::Header& header = headerList->entry(i); 360 const FetchHeaderList::Header& header = headerList->entry(i);
356 webRequest.appendHeader(header.first, header.second); 361 webRequest.appendHeader(header.first, header.second);
357 } 362 }
358 363
359 webRequest.setReferrer(m_request->referrer().referrer().referrer, static_cas t<WebReferrerPolicy>(m_request->referrer().referrer().referrerPolicy)); 364 webRequest.setReferrer(m_request->referrer().referrer().referrer, static_cas t<WebReferrerPolicy>(m_request->referrer().referrer().referrerPolicy));
360 // FIXME: How can we set isReload properly? What is the correct place to loa d it in to the Request object? We should investigate the right way 365 // FIXME: How can we set isReload properly? What is the correct place to loa d it in to the Request object? We should investigate the right way
361 // to plumb this information in to here. 366 // to plumb this information in to here.
362 } 367 }
363 368
364 void Request::setBodyBlobHandle(PassRefPtr<BlobDataHandle> blobDataHandle) 369 void Request::setBodyBlobHandle(PassRefPtr<BlobDataHandle> blobDataHandle)
365 { 370 {
366 m_request->setBlobDataHandle(blobDataHandle); 371 m_request->setBlobDataHandle(blobDataHandle);
367 } 372 }
368 373
369 void Request::clearHeaderList() 374 void Request::clearHeaderList()
370 { 375 {
371 m_request->headerList()->clearList(); 376 m_request->headerList()->clearList();
372 } 377 }
373 378
374 PassRefPtr<BlobDataHandle> Request::blobDataHandle() 379 PassRefPtr<BlobDataHandle> Request::blobDataHandle() const
375 { 380 {
376 return m_request->blobDataHandle(); 381 return m_request->blobDataHandle();
377 } 382 }
378 383
384 BodyStreamBuffer* Request::buffer() const
385 {
386 return nullptr;
387 }
388
389 String Request::contentTypeForBuffer() const
390 {
391 // We don't support BodyStreamBuffer for Request yet.
392 ASSERT_NOT_REACHED();
393 return String();
394 }
395
379 void Request::trace(Visitor* visitor) 396 void Request::trace(Visitor* visitor)
380 { 397 {
381 Body::trace(visitor); 398 Body::trace(visitor);
382 visitor->trace(m_request); 399 visitor->trace(m_request);
383 visitor->trace(m_headers); 400 visitor->trace(m_headers);
384 } 401 }
385 402
386 } // namespace blink 403 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/Request.h ('k') | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698