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

Side by Side Diff: third_party/WebKit/Source/core/fetch/RawResource.cpp

Issue 1852663002: Oilpan: Remove WillBe types (part 9) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #include "core/fetch/RawResource.h" 26 #include "core/fetch/RawResource.h"
27 27
28 #include "core/fetch/FetchRequest.h" 28 #include "core/fetch/FetchRequest.h"
29 #include "core/fetch/MemoryCache.h" 29 #include "core/fetch/MemoryCache.h"
30 #include "core/fetch/ResourceClientOrObserverWalker.h" 30 #include "core/fetch/ResourceClientOrObserverWalker.h"
31 #include "core/fetch/ResourceFetcher.h" 31 #include "core/fetch/ResourceFetcher.h"
32 #include "core/fetch/ResourceLoader.h" 32 #include "core/fetch/ResourceLoader.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 PassRefPtrWillBeRawPtr<Resource> RawResource::fetchSynchronously(FetchRequest& r equest, ResourceFetcher* fetcher) 36 RawPtr<Resource> RawResource::fetchSynchronously(FetchRequest& request, Resource Fetcher* fetcher)
37 { 37 {
38 request.mutableResourceRequest().setTimeoutInterval(10); 38 request.mutableResourceRequest().setTimeoutInterval(10);
39 ResourceLoaderOptions options(request.options()); 39 ResourceLoaderOptions options(request.options());
40 options.synchronousPolicy = RequestSynchronously; 40 options.synchronousPolicy = RequestSynchronously;
41 request.setOptions(options); 41 request.setOptions(options);
42 return fetcher->requestResource(request, RawResourceFactory(Resource::Raw)); 42 return fetcher->requestResource(request, RawResourceFactory(Resource::Raw));
43 } 43 }
44 44
45 PassRefPtrWillBeRawPtr<RawResource> RawResource::fetchImport(FetchRequest& reque st, ResourceFetcher* fetcher) 45 RawPtr<RawResource> RawResource::fetchImport(FetchRequest& request, ResourceFetc her* fetcher)
46 { 46 {
47 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 47 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
48 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textImport); 48 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textImport);
49 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::ImportResource))); 49 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::ImportResource)));
50 } 50 }
51 51
52 PassRefPtrWillBeRawPtr<RawResource> RawResource::fetch(FetchRequest& request, Re sourceFetcher* fetcher) 52 RawPtr<RawResource> RawResource::fetch(FetchRequest& request, ResourceFetcher* f etcher)
53 { 53 {
54 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 54 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
55 ASSERT(request.resourceRequest().requestContext() != WebURLRequest::RequestC ontextUnspecified); 55 ASSERT(request.resourceRequest().requestContext() != WebURLRequest::RequestC ontextUnspecified);
56 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::Raw))); 56 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::Raw)));
57 } 57 }
58 58
59 PassRefPtrWillBeRawPtr<RawResource> RawResource::fetchMainResource(FetchRequest& request, ResourceFetcher* fetcher, const SubstituteData& substituteData) 59 RawPtr<RawResource> RawResource::fetchMainResource(FetchRequest& request, Resour ceFetcher* fetcher, const SubstituteData& substituteData)
60 { 60 {
61 ASSERT(request.resourceRequest().frameType() != WebURLRequest::FrameTypeNone ); 61 ASSERT(request.resourceRequest().frameType() != WebURLRequest::FrameTypeNone );
62 ASSERT(request.resourceRequest().requestContext() == WebURLRequest::RequestC ontextForm || request.resourceRequest().requestContext() == WebURLRequest::Reque stContextFrame || request.resourceRequest().requestContext() == WebURLRequest::R equestContextHyperlink || request.resourceRequest().requestContext() == WebURLRe quest::RequestContextIframe || request.resourceRequest().requestContext() == Web URLRequest::RequestContextInternal || request.resourceRequest().requestContext() == WebURLRequest::RequestContextLocation); 62 ASSERT(request.resourceRequest().requestContext() == WebURLRequest::RequestC ontextForm || request.resourceRequest().requestContext() == WebURLRequest::Reque stContextFrame || request.resourceRequest().requestContext() == WebURLRequest::R equestContextHyperlink || request.resourceRequest().requestContext() == WebURLRe quest::RequestContextIframe || request.resourceRequest().requestContext() == Web URLRequest::RequestContextInternal || request.resourceRequest().requestContext() == WebURLRequest::RequestContextLocation);
63 63
64 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::MainResource), substituteData)); 64 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::MainResource), substituteData));
65 } 65 }
66 66
67 PassRefPtrWillBeRawPtr<RawResource> RawResource::fetchMedia(FetchRequest& reques t, ResourceFetcher* fetcher) 67 RawPtr<RawResource> RawResource::fetchMedia(FetchRequest& request, ResourceFetch er* fetcher)
68 { 68 {
69 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 69 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
70 ASSERT(request.resourceRequest().requestContext() == WebURLRequest::RequestC ontextAudio || request.resourceRequest().requestContext() == WebURLRequest::Requ estContextVideo); 70 ASSERT(request.resourceRequest().requestContext() == WebURLRequest::RequestC ontextAudio || request.resourceRequest().requestContext() == WebURLRequest::Requ estContextVideo);
71 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::Media))); 71 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::Media)));
72 } 72 }
73 73
74 PassRefPtrWillBeRawPtr<RawResource> RawResource::fetchTextTrack(FetchRequest& re quest, ResourceFetcher* fetcher) 74 RawPtr<RawResource> RawResource::fetchTextTrack(FetchRequest& request, ResourceF etcher* fetcher)
75 { 75 {
76 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 76 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
77 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textTrack); 77 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textTrack);
78 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::TextTrack))); 78 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::TextTrack)));
79 } 79 }
80 80
81 PassRefPtrWillBeRawPtr<RawResource> RawResource::fetchManifest(FetchRequest& req uest, ResourceFetcher* fetcher) 81 RawPtr<RawResource> RawResource::fetchManifest(FetchRequest& request, ResourceFe tcher* fetcher)
82 { 82 {
83 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 83 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
84 ASSERT(request.resourceRequest().requestContext() == WebURLRequest::RequestC ontextManifest); 84 ASSERT(request.resourceRequest().requestContext() == WebURLRequest::RequestC ontextManifest);
85 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::Manifest))); 85 return toRawResource(fetcher->requestResource(request, RawResourceFactory(Re source::Manifest)));
86 } 86 }
87 87
88 RawResource::RawResource(const ResourceRequest& resourceRequest, Type type, cons t ResourceLoaderOptions& options) 88 RawResource::RawResource(const ResourceRequest& resourceRequest, Type type, cons t ResourceLoaderOptions& options)
89 : Resource(resourceRequest, type, options) 89 : Resource(resourceRequest, type, options)
90 { 90 {
91 } 91 }
92 92
93 void RawResource::appendData(const char* data, size_t length) 93 void RawResource::appendData(const char* data, size_t length)
94 { 94 {
95 Resource::appendData(data, length); 95 Resource::appendData(data, length);
96 96
97 RefPtrWillBeRawPtr<RawResource> protect(this); 97 RawPtr<RawResource> protect(this);
98 ResourceClientWalker<RawResourceClient> w(m_clients); 98 ResourceClientWalker<RawResourceClient> w(m_clients);
99 while (RawResourceClient* c = w.next()) 99 while (RawResourceClient* c = w.next())
100 c->dataReceived(this, data, length); 100 c->dataReceived(this, data, length);
101 } 101 }
102 102
103 void RawResource::didAddClient(ResourceClient* c) 103 void RawResource::didAddClient(ResourceClient* c)
104 { 104 {
105 if (!hasClient(c)) 105 if (!hasClient(c))
106 return; 106 return;
107 // The calls to the client can result in events running, potentially causing 107 // The calls to the client can result in events running, potentially causing
108 // this resource to be evicted from the cache and all clients to be removed, 108 // this resource to be evicted from the cache and all clients to be removed,
109 // so a protector is necessary. 109 // so a protector is necessary.
110 RefPtrWillBeRawPtr<RawResource> protect(this); 110 RawPtr<RawResource> protect(this);
111 ASSERT(RawResourceClient::isExpectedType(c)); 111 ASSERT(RawResourceClient::isExpectedType(c));
112 RawResourceClient* client = static_cast<RawResourceClient*>(c); 112 RawResourceClient* client = static_cast<RawResourceClient*>(c);
113 for (const auto& redirect : redirectChain()) { 113 for (const auto& redirect : redirectChain()) {
114 ResourceRequest request(redirect.m_request); 114 ResourceRequest request(redirect.m_request);
115 client->redirectReceived(this, request, redirect.m_redirectResponse); 115 client->redirectReceived(this, request, redirect.m_redirectResponse);
116 if (!hasClient(c)) 116 if (!hasClient(c))
117 return; 117 return;
118 } 118 }
119 119
120 if (!m_response.isNull()) 120 if (!m_response.isNull())
121 client->responseReceived(this, m_response, nullptr); 121 client->responseReceived(this, m_response, nullptr);
122 if (!hasClient(c)) 122 if (!hasClient(c))
123 return; 123 return;
124 if (m_data) 124 if (m_data)
125 client->dataReceived(this, m_data->data(), m_data->size()); 125 client->dataReceived(this, m_data->data(), m_data->size());
126 if (!hasClient(c)) 126 if (!hasClient(c))
127 return; 127 return;
128 Resource::didAddClient(client); 128 Resource::didAddClient(client);
129 } 129 }
130 130
131 void RawResource::willFollowRedirect(ResourceRequest& newRequest, const Resource Response& redirectResponse) 131 void RawResource::willFollowRedirect(ResourceRequest& newRequest, const Resource Response& redirectResponse)
132 { 132 {
133 Resource::willFollowRedirect(newRequest, redirectResponse); 133 Resource::willFollowRedirect(newRequest, redirectResponse);
134 134
135 RefPtrWillBeRawPtr<RawResource> protect(this); 135 RawPtr<RawResource> protect(this);
136 ASSERT(!redirectResponse.isNull()); 136 ASSERT(!redirectResponse.isNull());
137 ResourceClientWalker<RawResourceClient> w(m_clients); 137 ResourceClientWalker<RawResourceClient> w(m_clients);
138 while (RawResourceClient* c = w.next()) 138 while (RawResourceClient* c = w.next())
139 c->redirectReceived(this, newRequest, redirectResponse); 139 c->redirectReceived(this, newRequest, redirectResponse);
140 } 140 }
141 141
142 void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr< WebDataConsumerHandle> handle) 142 void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr< WebDataConsumerHandle> handle)
143 { 143 {
144 RefPtrWillBeRawPtr<RawResource> protect(this); 144 RawPtr<RawResource> protect(this);
145 145
146 bool isSuccessfulRevalidation = isCacheValidator() && response.httpStatusCod e() == 304; 146 bool isSuccessfulRevalidation = isCacheValidator() && response.httpStatusCod e() == 304;
147 Resource::responseReceived(response, nullptr); 147 Resource::responseReceived(response, nullptr);
148 148
149 ResourceClientWalker<RawResourceClient> w(m_clients); 149 ResourceClientWalker<RawResourceClient> w(m_clients);
150 ASSERT(count() <= 1 || !handle); 150 ASSERT(count() <= 1 || !handle);
151 while (RawResourceClient* c = w.next()) { 151 while (RawResourceClient* c = w.next()) {
152 // |handle| is cleared when passed, but it's not a problem because 152 // |handle| is cleared when passed, but it's not a problem because
153 // |handle| is null when there are two or more clients, as asserted. 153 // |handle| is null when there are two or more clients, as asserted.
154 c->responseReceived(this, m_response, handle); 154 c->responseReceived(this, m_response, handle);
155 } 155 }
156 156
157 // If we successfully revalidated, we won't get appendData() calls. 157 // If we successfully revalidated, we won't get appendData() calls.
158 // Forward the data to clients now instead. 158 // Forward the data to clients now instead.
159 // Note: |m_data| can be null when no data is appended to the original 159 // Note: |m_data| can be null when no data is appended to the original
160 // resource. 160 // resource.
161 if (isSuccessfulRevalidation && m_data) { 161 if (isSuccessfulRevalidation && m_data) {
162 ResourceClientWalker<RawResourceClient> w(m_clients); 162 ResourceClientWalker<RawResourceClient> w(m_clients);
163 while (RawResourceClient* c = w.next()) 163 while (RawResourceClient* c = w.next())
164 c->dataReceived(this, m_data->data(), m_data->size()); 164 c->dataReceived(this, m_data->data(), m_data->size());
165 } 165 }
166 } 166 }
167 167
168 void RawResource::setSerializedCachedMetadata(const char* data, size_t size) 168 void RawResource::setSerializedCachedMetadata(const char* data, size_t size)
169 { 169 {
170 RefPtrWillBeRawPtr<RawResource> protect(this); 170 RawPtr<RawResource> protect(this);
171 Resource::setSerializedCachedMetadata(data, size); 171 Resource::setSerializedCachedMetadata(data, size);
172 ResourceClientWalker<RawResourceClient> w(m_clients); 172 ResourceClientWalker<RawResourceClient> w(m_clients);
173 while (RawResourceClient* c = w.next()) 173 while (RawResourceClient* c = w.next())
174 c->setSerializedCachedMetadata(this, data, size); 174 c->setSerializedCachedMetadata(this, data, size);
175 } 175 }
176 176
177 void RawResource::didSendData(unsigned long long bytesSent, unsigned long long t otalBytesToBeSent) 177 void RawResource::didSendData(unsigned long long bytesSent, unsigned long long t otalBytesToBeSent)
178 { 178 {
179 RefPtrWillBeRawPtr<RawResource> protect(this); 179 RawPtr<RawResource> protect(this);
180 ResourceClientWalker<RawResourceClient> w(m_clients); 180 ResourceClientWalker<RawResourceClient> w(m_clients);
181 while (RawResourceClient* c = w.next()) 181 while (RawResourceClient* c = w.next())
182 c->dataSent(this, bytesSent, totalBytesToBeSent); 182 c->dataSent(this, bytesSent, totalBytesToBeSent);
183 } 183 }
184 184
185 void RawResource::didDownloadData(int dataLength) 185 void RawResource::didDownloadData(int dataLength)
186 { 186 {
187 RefPtrWillBeRawPtr<RawResource> protect(this); 187 RawPtr<RawResource> protect(this);
188 ResourceClientWalker<RawResourceClient> w(m_clients); 188 ResourceClientWalker<RawResourceClient> w(m_clients);
189 while (RawResourceClient* c = w.next()) 189 while (RawResourceClient* c = w.next())
190 c->dataDownloaded(this, dataLength); 190 c->dataDownloaded(this, dataLength);
191 } 191 }
192 192
193 void RawResource::reportResourceTimingToClients(const ResourceTimingInfo& info) 193 void RawResource::reportResourceTimingToClients(const ResourceTimingInfo& info)
194 { 194 {
195 ResourceClientWalker<RawResourceClient> w(m_clients); 195 ResourceClientWalker<RawResourceClient> w(m_clients);
196 while (RawResourceClient* c = w.next()) 196 while (RawResourceClient* c = w.next())
197 c->didReceiveResourceTiming(this, info); 197 c->didReceiveResourceTiming(this, info);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 for (const auto& header : oldHeaders) { 259 for (const auto& header : oldHeaders) {
260 AtomicString headerName = header.key; 260 AtomicString headerName = header.key;
261 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH eaders.get(headerName)) 261 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH eaders.get(headerName))
262 return false; 262 return false;
263 } 263 }
264 264
265 return true; 265 return true;
266 } 266 }
267 267
268 } // namespace blink 268 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/RawResource.h ('k') | third_party/WebKit/Source/core/fetch/RawResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698