| OLD | NEW | 
|---|
| 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  Loading... | 
| 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  Loading... | 
| 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::contentType() const | 
|  | 390 { | 
|  | 391     return m_request->contentType(); | 
|  | 392 } | 
|  | 393 | 
| 379 void Request::trace(Visitor* visitor) | 394 void Request::trace(Visitor* visitor) | 
| 380 { | 395 { | 
| 381     Body::trace(visitor); | 396     Body::trace(visitor); | 
| 382     visitor->trace(m_request); | 397     visitor->trace(m_request); | 
| 383     visitor->trace(m_headers); | 398     visitor->trace(m_headers); | 
| 384 } | 399 } | 
| 385 | 400 | 
| 386 } // namespace blink | 401 } // namespace blink | 
| OLD | NEW | 
|---|