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

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

Issue 384633002: Oilpan: add transition types to remaining Fetch and ServiceWorker objects (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 5 months 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
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 "FetchResponseData.h" 6 #include "FetchResponseData.h"
7 7
8 #include "core/fetch/CrossOriginAccessControl.h" 8 #include "core/fetch/CrossOriginAccessControl.h"
9 #include "modules/serviceworkers/FetchHeaderList.h" 9 #include "modules/serviceworkers/FetchHeaderList.h"
10 #include "public/platform/WebServiceWorkerResponse.h" 10 #include "public/platform/WebServiceWorkerResponse.h"
11 11
12 namespace WebCore { 12 namespace WebCore {
13 13
14 PassRefPtr<FetchResponseData> FetchResponseData::create() 14 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::create()
15 { 15 {
16 // "Unless stated otherwise, a response's url is null, status is 200, status 16 // "Unless stated otherwise, a response's url is null, status is 200, status
17 // message is `OK`, header list is an empty header list, and body is null." 17 // message is `OK`, header list is an empty header list, and body is null."
18 return adoptRef(new FetchResponseData(DefaultType, 200, "OK")); 18 return adoptRefWillBeNoop(new FetchResponseData(DefaultType, 200, "OK"));
19 } 19 }
20 20
21 PassRefPtr<FetchResponseData> FetchResponseData::createNetworkErrorResponse() 21 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createNetworkErrorR esponse()
22 { 22 {
23 // "A network error is a response whose status is always 0, status message 23 // "A network error is a response whose status is always 0, status message
24 // is always the empty byte sequence, header list is aways an empty list, 24 // is always the empty byte sequence, header list is aways an empty list,
25 // and body is always null." 25 // and body is always null."
26 return adoptRef(new FetchResponseData(ErrorType, 0, "")); 26 return adoptRefWillBeNoop(new FetchResponseData(ErrorType, 0, ""));
27 } 27 }
28 28
29 PassRefPtr<FetchResponseData> FetchResponseData::createBasicFilteredResponse() 29 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createBasicFiltered Response()
30 { 30 {
31 // "A basic filtered response is a filtered response whose type is |basic|, 31 // "A basic filtered response is a filtered response whose type is |basic|,
32 // header list excludes any headers in internal response's header list whose 32 // header list excludes any headers in internal response's header list whose
33 // name is `Set-Cookie` or `Set-Cookie2`." 33 // name is `Set-Cookie` or `Set-Cookie2`."
34 RefPtr<FetchResponseData> response = adoptRef(new FetchResponseData(BasicTyp e, m_status, m_statusMessage)); 34 RefPtrWillBeRawPtr<FetchResponseData> response = adoptRefWillBeNoop(new Fetc hResponseData(BasicType, m_status, m_statusMessage));
35 response->m_url = m_url; 35 response->m_url = m_url;
36 for (size_t i = 0; i < m_headerList->size(); ++i) { 36 for (size_t i = 0; i < m_headerList->size(); ++i) {
37 const FetchHeaderList::Header* header = m_headerList->list()[i].get(); 37 const FetchHeaderList::Header* header = m_headerList->list()[i].get();
38 if (header->first == "set-cookie" || header->first == "set-cookie2") 38 if (header->first == "set-cookie" || header->first == "set-cookie2")
39 continue; 39 continue;
40 response->m_headerList->append(header->first, header->second); 40 response->m_headerList->append(header->first, header->second);
41 } 41 }
42 response->m_blobDataHandle = m_blobDataHandle; 42 response->m_blobDataHandle = m_blobDataHandle;
43 response->m_internalResponse = this; 43 response->m_internalResponse = this;
44 return response.release(); 44 return response.release();
45 } 45 }
46 46
47 PassRefPtr<FetchResponseData> FetchResponseData::createCORSFilteredResponse() 47 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createCORSFilteredR esponse()
48 { 48 {
49 // "A CORS filtered response is a filtered response whose type is |CORS|, 49 // "A CORS filtered response is a filtered response whose type is |CORS|,
50 // header list excludes all headers in internal response's header list, 50 // header list excludes all headers in internal response's header list,
51 // except those whose name is either one of `Cache-Control`, 51 // except those whose name is either one of `Cache-Control`,
52 // `Content-Language`, `Content-Type`, `Expires`, `Last-Modified`, and 52 // `Content-Language`, `Content-Type`, `Expires`, `Last-Modified`, and
53 // `Pragma`, and except those whose name is one of the values resulting from 53 // `Pragma`, and except those whose name is one of the values resulting from
54 // parsing `Access-Control-Expose-Headers` in internal response's header 54 // parsing `Access-Control-Expose-Headers` in internal response's header
55 // list." 55 // list."
56 RefPtr<FetchResponseData> response = adoptRef(new FetchResponseData(CORSType , m_status, m_statusMessage)); 56 RefPtrWillBeRawPtr<FetchResponseData> response = adoptRefWillBeNoop(new Fetc hResponseData(CORSType, m_status, m_statusMessage));
57 response->m_url = m_url; 57 response->m_url = m_url;
58 HTTPHeaderSet accessControlExposeHeaderSet; 58 HTTPHeaderSet accessControlExposeHeaderSet;
59 String accessControlExposeHeaders; 59 String accessControlExposeHeaders;
60 if (m_headerList->get("access-control-expose-headers", accessControlExposeHe aders)) 60 if (m_headerList->get("access-control-expose-headers", accessControlExposeHe aders))
61 parseAccessControlExposeHeadersAllowList(accessControlExposeHeaders, acc essControlExposeHeaderSet); 61 parseAccessControlExposeHeadersAllowList(accessControlExposeHeaders, acc essControlExposeHeaderSet);
62 for (size_t i = 0; i < m_headerList->size(); ++i) { 62 for (size_t i = 0; i < m_headerList->size(); ++i) {
63 const FetchHeaderList::Header* header = m_headerList->list()[i].get(); 63 const FetchHeaderList::Header* header = m_headerList->list()[i].get();
64 if (!isOnAccessControlResponseHeaderWhitelist(header->first) && !accessC ontrolExposeHeaderSet.contains(header->first)) 64 if (!isOnAccessControlResponseHeaderWhitelist(header->first) && !accessC ontrolExposeHeaderSet.contains(header->first))
65 continue; 65 continue;
66 response->m_headerList->append(header->first, header->second); 66 response->m_headerList->append(header->first, header->second);
67 } 67 }
68 response->m_blobDataHandle = m_blobDataHandle; 68 response->m_blobDataHandle = m_blobDataHandle;
69 response->m_internalResponse = this; 69 response->m_internalResponse = this;
70 return response.release(); 70 return response.release();
71 } 71 }
72 72
73 PassRefPtr<FetchResponseData> FetchResponseData::createOpaqueFilteredResponse() 73 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createOpaqueFiltere dResponse()
74 { 74 {
75 // "An opaque filtered response is a filtered response whose type is 75 // "An opaque filtered response is a filtered response whose type is
76 // |opaque|, status is 0, status message is the empty byte sequence, header 76 // |opaque|, status is 0, status message is the empty byte sequence, header
77 // list is an empty list, and body is null." 77 // list is an empty list, and body is null."
78 RefPtr<FetchResponseData> response = adoptRef(new FetchResponseData(OpaqueTy pe, 0, "")); 78 RefPtrWillBeRawPtr<FetchResponseData> response = adoptRefWillBeNoop(new Fetc hResponseData(OpaqueType, 0, ""));
79 response->m_internalResponse = this; 79 response->m_internalResponse = this;
80 return response.release(); 80 return response.release();
81 } 81 }
82 82
83 void FetchResponseData::populateWebServiceWorkerResponse(blink::WebServiceWorker Response& response) 83 void FetchResponseData::populateWebServiceWorkerResponse(blink::WebServiceWorker Response& response)
84 { 84 {
85 if (m_internalResponse) { 85 if (m_internalResponse) {
86 m_internalResponse->populateWebServiceWorkerResponse(response); 86 m_internalResponse->populateWebServiceWorkerResponse(response);
87 return; 87 return;
88 } 88 }
89 response.setURL(url()); 89 response.setURL(url());
90 response.setStatus(status()); 90 response.setStatus(status());
91 response.setStatusText(statusMessage()); 91 response.setStatusText(statusMessage());
92 for (size_t i = 0; i < headerList()->size(); ++i) { 92 for (size_t i = 0; i < headerList()->size(); ++i) {
93 const FetchHeaderList::Header* header = headerList()->list()[i].get(); 93 const FetchHeaderList::Header* header = headerList()->list()[i].get();
94 response.setHeader(header->first, header->second); 94 response.setHeader(header->first, header->second);
95 } 95 }
96 response.setBlobDataHandle(blobDataHandle()); 96 response.setBlobDataHandle(blobDataHandle());
97 } 97 }
98 98
99 FetchResponseData::FetchResponseData(Type type, unsigned short status, AtomicStr ing statusMessage) 99 FetchResponseData::FetchResponseData(Type type, unsigned short status, AtomicStr ing statusMessage)
100 : m_type(type) 100 : m_type(type)
101 , m_status(status) 101 , m_status(status)
102 , m_statusMessage(statusMessage) 102 , m_statusMessage(statusMessage)
103 , m_headerList(FetchHeaderList::create()) 103 , m_headerList(FetchHeaderList::create())
104 { 104 {
105 } 105 }
106 106
107 void FetchResponseData::trace(Visitor* visitor)
108 {
109 visitor->trace(m_headerList);
110 visitor->trace(m_internalResponse);
111 }
112
107 } // namespace WebCore 113 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698