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 "FetchRequestData.h" | 6 #include "FetchRequestData.h" |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/fetch/ResourceLoaderOptions.h" | 10 #include "core/fetch/ResourceLoaderOptions.h" |
11 #include "core/loader/ThreadableLoader.h" | 11 #include "core/loader/ThreadableLoader.h" |
12 #include "modules/serviceworkers/FetchHeaderList.h" | 12 #include "modules/serviceworkers/FetchHeaderList.h" |
13 #include "platform/network/ResourceRequest.h" | 13 #include "platform/network/ResourceRequest.h" |
14 #include "public/platform/WebServiceWorkerRequest.h" | 14 #include "public/platform/WebServiceWorkerRequest.h" |
15 | 15 |
16 namespace WebCore { | 16 namespace WebCore { |
17 | 17 |
18 PassRefPtr<FetchRequestData> FetchRequestData::create(ExecutionContext* context) | 18 PassRefPtrWillBeRawPtr<FetchRequestData> FetchRequestData::create() |
19 { | 19 { |
20 RefPtr<FetchRequestData> request(adoptRef(new FetchRequestData())); | 20 return adoptRefWillBeNoop(new FetchRequestData()); |
| 21 } |
| 22 |
| 23 PassRefPtrWillBeRawPtr<FetchRequestData> FetchRequestData::create(ExecutionConte
xt* context) |
| 24 { |
| 25 RefPtrWillBeRawPtr<FetchRequestData> request = FetchRequestData::create(); |
21 if (context->isDocument()) | 26 if (context->isDocument()) |
22 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), toDocument(context)->referrerPolicy())); | 27 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), toDocument(context)->referrerPolicy())); |
23 else | 28 else |
24 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), ReferrerPolicyDefault)); | 29 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), ReferrerPolicyDefault)); |
25 return request.release(); | 30 return request.release(); |
26 } | 31 } |
27 | 32 |
28 PassRefPtr<FetchRequestData> FetchRequestData::create(const blink::WebServiceWor
kerRequest& webRequest) | 33 PassRefPtrWillBeRawPtr<FetchRequestData> FetchRequestData::create(const blink::W
ebServiceWorkerRequest& webRequest) |
29 { | 34 { |
30 RefPtr<FetchRequestData> request(adoptRef(new FetchRequestData())); | 35 RefPtrWillBeRawPtr<FetchRequestData> request = FetchRequestData::create(); |
31 request->m_url = webRequest.url(); | 36 request->m_url = webRequest.url(); |
32 request->m_method = webRequest.method(); | 37 request->m_method = webRequest.method(); |
33 for (HTTPHeaderMap::const_iterator it = webRequest.headers().begin(); it !=
webRequest.headers().end(); ++it) | 38 for (HTTPHeaderMap::const_iterator it = webRequest.headers().begin(); it !=
webRequest.headers().end(); ++it) |
34 request->m_headerList->append(it->key, it->value); | 39 request->m_headerList->append(it->key, it->value); |
35 request->m_referrer.setURL(webRequest.referrer()); | 40 request->m_referrer.setURL(webRequest.referrer()); |
36 return request.release(); | 41 return request.release(); |
37 } | 42 } |
38 | 43 |
39 PassRefPtr<FetchRequestData> FetchRequestData::createRestrictedCopy(ExecutionCon
text* context, PassRefPtr<SecurityOrigin> origin) const | 44 PassRefPtrWillBeRawPtr<FetchRequestData> FetchRequestData::createRestrictedCopy(
ExecutionContext* context, PassRefPtr<SecurityOrigin> origin) const |
40 { | 45 { |
41 // "To make a restricted copy of a request |request|, run these steps: | 46 // "To make a restricted copy of a request |request|, run these steps: |
42 // 1. Let |r| be a new request whose url is |request|'s url, method is | 47 // 1. Let |r| be a new request whose url is |request|'s url, method is |
43 // |request|'s method, header list is a copy of |request|'s header list, | 48 // |request|'s method, header list is a copy of |request|'s header list, |
44 // body is a tee of |request|'s body, client is entry settings object's | 49 // body is a tee of |request|'s body, client is entry settings object's |
45 // global object, origin is entry settings object's origin, referrer is | 50 // global object, origin is entry settings object's origin, referrer is |
46 // |client|, context is |connect|, mode is |request|'s mode, and credentials | 51 // |client|, context is |connect|, mode is |request|'s mode, and credentials |
47 // mode is |request|'s credentials mode." | 52 // mode is |request|'s credentials mode." |
48 RefPtr<FetchRequestData> request = adoptRef(new FetchRequestData()); | 53 RefPtrWillBeRawPtr<FetchRequestData> request = FetchRequestData::create(); |
49 request->m_url = m_url; | 54 request->m_url = m_url; |
50 request->m_method = m_method; | 55 request->m_method = m_method; |
51 request->m_headerList = m_headerList->createCopy(); | 56 request->m_headerList = m_headerList->createCopy(); |
52 // FIXME: Support body. | 57 // FIXME: Support body. |
53 request->m_origin = origin; | 58 request->m_origin = origin; |
54 if (context->isDocument()) | 59 if (context->isDocument()) |
55 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), toDocument(context)->referrerPolicy())); | 60 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), toDocument(context)->referrerPolicy())); |
56 else | 61 else |
57 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), ReferrerPolicyDefault)); | 62 request->m_referrer.setClient(WebCore::Referrer(context->url().strippedF
orUseAsReferrer(), ReferrerPolicyDefault)); |
58 request->m_context = ConnectContext; | 63 request->m_context = ConnectContext; |
(...skipping 12 matching lines...) Expand all Loading... |
71 , m_headerList(FetchHeaderList::create()) | 76 , m_headerList(FetchHeaderList::create()) |
72 , m_unsafeRequestFlag(false) | 77 , m_unsafeRequestFlag(false) |
73 , m_context(NullContext) | 78 , m_context(NullContext) |
74 , m_sameOriginDataURLFlag(false) | 79 , m_sameOriginDataURLFlag(false) |
75 , m_mode(NoCORSMode) | 80 , m_mode(NoCORSMode) |
76 , m_credentials(OmitCredentials) | 81 , m_credentials(OmitCredentials) |
77 , m_responseTainting(BasicTainting) | 82 , m_responseTainting(BasicTainting) |
78 { | 83 { |
79 } | 84 } |
80 | 85 |
| 86 void FetchRequestData::trace(Visitor* visitor) |
| 87 { |
| 88 visitor->trace(m_headerList); |
| 89 } |
| 90 |
81 } // namespace WebCore | 91 } // namespace WebCore |
OLD | NEW |