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/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/fetch/FetchUtils.h" | 10 #include "core/fetch/FetchUtils.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 exceptionState.throwTypeError("Invalid URL"); | 180 exceptionState.throwTypeError("Invalid URL"); |
181 return 0; | 181 return 0; |
182 } | 182 } |
183 // "3. Set |request|'s url to |parsedURL|." | 183 // "3. Set |request|'s url to |parsedURL|." |
184 request->setURL(parsedURL); | 184 request->setURL(parsedURL); |
185 // "4. Set |fallbackMode| to CORS." | 185 // "4. Set |fallbackMode| to CORS." |
186 // "5. Set |fallbackCredentials| to omit." | 186 // "5. Set |fallbackCredentials| to omit." |
187 return createRequestWithRequestData(request, RequestInit(context, init, exce
ptionState), FetchRequestData::CORSMode, FetchRequestData::OmitCredentials, exce
ptionState); | 187 return createRequestWithRequestData(request, RequestInit(context, init, exce
ptionState), FetchRequestData::CORSMode, FetchRequestData::OmitCredentials, exce
ptionState); |
188 } | 188 } |
189 | 189 |
190 Request* Request::create(ExecutionContext* context, Request* input, ExceptionSta
te& exceptionState) | 190 Request* Request::create(ExecutionContext* context, const Request* input, Except
ionState& exceptionState) |
191 { | 191 { |
192 return create(context, input, Dictionary(), exceptionState); | 192 return create(context, input, Dictionary(), exceptionState); |
193 } | 193 } |
194 | 194 |
195 Request* Request::create(ExecutionContext* context, Request* input, const Dictio
nary& init, ExceptionState& exceptionState) | 195 Request* Request::create(ExecutionContext* context, const Request* input, const
Dictionary& init, ExceptionState& exceptionState) |
196 { | 196 { |
197 // "1. Let |request| be |input|'s associated request, if |input| is a | 197 // "1. Let |request| be |input|'s associated request, if |input| is a |
198 // Request object, and a new request otherwise." | 198 // Request object, and a new request otherwise." |
199 // "2. Set |request| to a restricted copy of itself." | 199 // "2. Set |request| to a restricted copy of itself." |
200 FetchRequestData* request(input->request()->createRestrictedCopy(context, Se
curityOrigin::create(context->url()))); | 200 FetchRequestData* request(input->request()->createRestrictedCopy(context, Se
curityOrigin::create(context->url()))); |
201 // "3. Let |fallbackMode| be null." | 201 // "3. Let |fallbackMode| be null." |
202 // "4. Let |fallbackCredentials| be null." | 202 // "4. Let |fallbackCredentials| be null." |
203 // Instead of using null as a special fallback value, just pass the current | 203 // Instead of using null as a special fallback value, just pass the current |
204 // mode and credentials; it has the same effect. | 204 // mode and credentials; it has the same effect. |
205 const FetchRequestData::Mode currentMode = request->mode(); | 205 const FetchRequestData::Mode currentMode = request->mode(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 return "omit"; | 294 return "omit"; |
295 case FetchRequestData::SameOriginCredentials: | 295 case FetchRequestData::SameOriginCredentials: |
296 return "same-origin"; | 296 return "same-origin"; |
297 case FetchRequestData::IncludeCredentials: | 297 case FetchRequestData::IncludeCredentials: |
298 return "include"; | 298 return "include"; |
299 } | 299 } |
300 ASSERT_NOT_REACHED(); | 300 ASSERT_NOT_REACHED(); |
301 return ""; | 301 return ""; |
302 } | 302 } |
303 | 303 |
304 void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques
t) | 304 void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques
t) const |
305 { | 305 { |
306 webRequest.setMethod(method()); | 306 webRequest.setMethod(method()); |
307 webRequest.setURL(m_request->url()); | 307 webRequest.setURL(m_request->url()); |
308 m_headers->forEach(adoptPtrWillBeNoop(new FillWebRequestHeaders(&webRequest)
)); | 308 m_headers->forEach(adoptPtrWillBeNoop(new FillWebRequestHeaders(&webRequest)
)); |
309 webRequest.setReferrer(m_request->referrer().referrer().referrer, static_cas
t<WebReferrerPolicy>(m_request->referrer().referrer().referrerPolicy)); | 309 webRequest.setReferrer(m_request->referrer().referrer().referrer, static_cas
t<WebReferrerPolicy>(m_request->referrer().referrer().referrerPolicy)); |
310 // 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 | 310 // 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 |
311 // to plumb this information in to here. | 311 // to plumb this information in to here. |
312 } | 312 } |
313 | 313 |
314 void Request::setBodyBlobHandle(PassRefPtr<BlobDataHandle>blobHandle) | 314 void Request::setBodyBlobHandle(PassRefPtr<BlobDataHandle>blobHandle) |
315 { | 315 { |
316 m_request->setBlobDataHandle(blobHandle); | 316 m_request->setBlobDataHandle(blobHandle); |
317 } | 317 } |
318 | 318 |
319 void Request::trace(Visitor* visitor) | 319 void Request::trace(Visitor* visitor) |
320 { | 320 { |
321 visitor->trace(m_request); | 321 visitor->trace(m_request); |
322 visitor->trace(m_headers); | 322 visitor->trace(m_headers); |
323 visitor->trace(m_fetchBodyStream); | 323 visitor->trace(m_fetchBodyStream); |
324 } | 324 } |
325 | 325 |
326 } // namespace blink | 326 } // namespace blink |
OLD | NEW |