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

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

Issue 478693005: Oilpan: Ship Oilpan for serviceworkers/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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 blink { 12 namespace blink {
13 13
14 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::create() 14 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 adoptRefWillBeNoop(new FetchResponseData(DefaultType, 200, "OK")); 18 return new FetchResponseData(DefaultType, 200, "OK");
19 } 19 }
20 20
21 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createNetworkErrorR esponse() 21 FetchResponseData* FetchResponseData::createNetworkErrorResponse()
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 adoptRefWillBeNoop(new FetchResponseData(ErrorType, 0, "")); 26 return new FetchResponseData(ErrorType, 0, "");
27 } 27 }
28 28
29 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createBasicFiltered Response() 29 FetchResponseData* FetchResponseData::createBasicFilteredResponse()
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 RefPtrWillBeRawPtr<FetchResponseData> response = adoptRefWillBeNoop(new Fetc hResponseData(BasicType, m_status, m_statusMessage)); 34 FetchResponseData* response = new FetchResponseData(BasicType, m_status, m_s tatusMessage);
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;
45 } 45 }
46 46
47 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createCORSFilteredR esponse() 47 FetchResponseData* FetchResponseData::createCORSFilteredResponse()
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 RefPtrWillBeRawPtr<FetchResponseData> response = adoptRefWillBeNoop(new Fetc hResponseData(CORSType, m_status, m_statusMessage)); 56 FetchResponseData* response = new FetchResponseData(CORSType, m_status, m_st atusMessage);
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;
71 } 71 }
72 72
73 PassRefPtrWillBeRawPtr<FetchResponseData> FetchResponseData::createOpaqueFiltere dResponse() 73 FetchResponseData* FetchResponseData::createOpaqueFilteredResponse()
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 RefPtrWillBeRawPtr<FetchResponseData> response = adoptRefWillBeNoop(new Fetc hResponseData(OpaqueType, 0, "")); 78 FetchResponseData* response = new FetchResponseData(OpaqueType, 0, "");
79 response->m_internalResponse = this; 79 response->m_internalResponse = this;
80 return response.release(); 80 return response;
81 } 81 }
82 82
83 void FetchResponseData::populateWebServiceWorkerResponse(WebServiceWorkerRespons e& response) 83 void FetchResponseData::populateWebServiceWorkerResponse(WebServiceWorkerRespons e& 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());
(...skipping 13 matching lines...) Expand all
104 { 104 {
105 } 105 }
106 106
107 void FetchResponseData::trace(Visitor* visitor) 107 void FetchResponseData::trace(Visitor* visitor)
108 { 108 {
109 visitor->trace(m_headerList); 109 visitor->trace(m_headerList);
110 visitor->trace(m_internalResponse); 110 visitor->trace(m_internalResponse);
111 } 111 }
112 112
113 } // namespace blink 113 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/FetchResponseData.h ('k') | Source/modules/serviceworkers/Headers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698