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 "modules/fetch/Request.h" | 6 #include "modules/fetch/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 Request* Request::createRequestWithRequestOrString(ExecutionContext* context, Re
quest* inputRequest, const String& inputString, const RequestInit& init, Excepti
onState& exceptionState) | 44 Request* Request::createRequestWithRequestOrString(ExecutionContext* context, Re
quest* inputRequest, const String& inputString, const RequestInit& init, Excepti
onState& exceptionState) |
45 { | 45 { |
46 // "1. If input is a Request object, run these substeps:" | 46 // "1. If input is a Request object, run these substeps:" |
47 if (inputRequest) { | 47 if (inputRequest) { |
48 // "1. If input's used flag is set, throw a TypeError." | 48 // "1. If input's used flag is set, throw a TypeError." |
49 if (inputRequest->bodyUsed()) { | 49 if (inputRequest->bodyUsed()) { |
50 exceptionState.throwTypeError("Cannot construct a Request with a Req
uest object that has already been used."); | 50 exceptionState.throwTypeError("Cannot construct a Request with a Req
uest object that has already been used."); |
51 return 0; | 51 return 0; |
52 } | 52 } |
53 // "2. Set input's used flag." | 53 // "2. Set input's used flag." |
54 inputRequest->setBodyUsed(); | 54 inputRequest->lockBody(PassBody); |
55 } | 55 } |
56 | 56 |
57 // "2. Let |request| be |input|'s associated request, if |input| is a | 57 // "2. Let |request| be |input|'s associated request, if |input| is a |
58 // Request object, and a new request otherwise." | 58 // Request object, and a new request otherwise." |
59 // "3. Set |request| to a new request whose url is |request|'s url, method | 59 // "3. Set |request| to a new request whose url is |request|'s url, method |
60 // is |request|'s method, header list is a copy of |request|'s header list, | 60 // is |request|'s method, header list is a copy of |request|'s header list, |
61 // unsafe request flag is set, body is |request|'s body, client is entry | 61 // unsafe request flag is set, body is |request|'s body, client is entry |
62 // settings object, origin is entry settings object's origin, force Origin | 62 // settings object, origin is entry settings object's origin, force Origin |
63 // header flag is set, same-origin data URL flag is set, referrer is client, | 63 // header flag is set, same-origin data URL flag is set, referrer is client, |
64 // context is fetch, mode is |request|'s mode, credentials mode is | 64 // context is fetch, mode is |request|'s mode, credentials mode is |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 Headers* headers = Headers::create(request->headerList()); | 340 Headers* headers = Headers::create(request->headerList()); |
341 headers->setGuard(m_headers->guard()); | 341 headers->setGuard(m_headers->guard()); |
342 Request* r = new Request(executionContext(), request, headers); | 342 Request* r = new Request(executionContext(), request, headers); |
343 r->suspendIfNeeded(); | 343 r->suspendIfNeeded(); |
344 return r; | 344 return r; |
345 } | 345 } |
346 | 346 |
347 FetchRequestData* Request::passRequestData() | 347 FetchRequestData* Request::passRequestData() |
348 { | 348 { |
349 ASSERT(!bodyUsed()); | 349 ASSERT(!bodyUsed()); |
350 setBodyUsed(); | 350 lockBody(PassBody); |
351 return m_request->pass(); | 351 return m_request->pass(); |
352 } | 352 } |
353 | 353 |
354 void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques
t) const | 354 void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques
t) const |
355 { | 355 { |
356 webRequest.setMethod(method()); | 356 webRequest.setMethod(method()); |
357 // This strips off the fragment part. | 357 // This strips off the fragment part. |
358 webRequest.setURL(url()); | 358 webRequest.setURL(url()); |
359 | 359 |
360 const FetchHeaderList* headerList = m_headers->headerList(); | 360 const FetchHeaderList* headerList = m_headers->headerList(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 395 } |
396 | 396 |
397 DEFINE_TRACE(Request) | 397 DEFINE_TRACE(Request) |
398 { | 398 { |
399 Body::trace(visitor); | 399 Body::trace(visitor); |
400 visitor->trace(m_request); | 400 visitor->trace(m_request); |
401 visitor->trace(m_headers); | 401 visitor->trace(m_headers); |
402 } | 402 } |
403 | 403 |
404 } // namespace blink | 404 } // namespace blink |
OLD | NEW |