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

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

Issue 2487763003: [ImageLoader 2d] Set DecodeError by calling ResourceLoader::cancel()
Patch Set: Rebase Created 4 years, 1 month 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) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, 126 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority,
127 int intraPriorityValue) { 127 int intraPriorityValue) {
128 if (m_loader) { 128 if (m_loader) {
129 m_loader->didChangePriority( 129 m_loader->didChangePriority(
130 static_cast<WebURLRequest::Priority>(loadPriority), intraPriorityValue); 130 static_cast<WebURLRequest::Priority>(loadPriority), intraPriorityValue);
131 } 131 }
132 } 132 }
133 133
134 void ResourceLoader::cancel() { 134 void ResourceLoader::cancel(Resource::Status errorStatus) {
135 didFail( 135 didFail(
136 ResourceError::cancelledError(m_resource->lastResourceRequest().url())); 136 ResourceError::cancelledError(m_resource->lastResourceRequest().url()),
137 errorStatus);
137 } 138 }
138 139
139 void ResourceLoader::cancelForRedirectAccessCheckError(const KURL& newURL) { 140 void ResourceLoader::cancelForRedirectAccessCheckError(const KURL& newURL) {
140 m_resource->willNotFollowRedirect(); 141 m_resource->willNotFollowRedirect();
141 142
142 if (m_loader) 143 if (m_loader) {
143 didFail(ResourceError::cancelledDueToAccessCheckError(newURL)); 144 didFail(ResourceError::cancelledDueToAccessCheckError(newURL),
145 Resource::LoadError);
146 }
144 } 147 }
145 148
146 bool ResourceLoader::willFollowRedirect( 149 bool ResourceLoader::willFollowRedirect(
147 WebURLLoader*, 150 WebURLLoader*,
148 WebURLRequest& passedNewRequest, 151 WebURLRequest& passedNewRequest,
149 const WebURLResponse& passedRedirectResponse) { 152 const WebURLResponse& passedRedirectResponse) {
150 DCHECK(!passedNewRequest.isNull()); 153 DCHECK(!passedNewRequest.isNull());
151 DCHECK(!passedRedirectResponse.isNull()); 154 DCHECK(!passedRedirectResponse.isNull());
152 155
153 if (m_isCacheAwareLoadingActivated) { 156 if (m_isCacheAwareLoadingActivated) {
154 // Fail as cache miss if cached response is a redirect. 157 // Fail as cache miss if cached response is a redirect.
155 didFail( 158 didFail(
156 ResourceError::cacheMissError(m_resource->lastResourceRequest().url())); 159 ResourceError::cacheMissError(m_resource->lastResourceRequest().url()),
160 Resource::LoadError);
157 return false; 161 return false;
158 } 162 }
159 163
160 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); 164 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
161 const ResourceResponse& redirectResponse( 165 const ResourceResponse& redirectResponse(
162 passedRedirectResponse.toResourceResponse()); 166 passedRedirectResponse.toResourceResponse());
163 newRequest.setRedirectStatus( 167 newRequest.setRedirectStatus(
164 ResourceRequest::RedirectStatus::FollowedRedirect); 168 ResourceRequest::RedirectStatus::FollowedRedirect);
165 169
166 const KURL originalURL = newRequest.url(); 170 const KURL originalURL = newRequest.url();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 239
236 void ResourceLoader::didFinishLoading(WebURLLoader*, 240 void ResourceLoader::didFinishLoading(WebURLLoader*,
237 double finishTime, 241 double finishTime,
238 int64_t encodedDataLength) { 242 int64_t encodedDataLength) {
239 m_loader.reset(); 243 m_loader.reset();
240 m_fetcher->didFinishLoading(m_resource.get(), finishTime, encodedDataLength, 244 m_fetcher->didFinishLoading(m_resource.get(), finishTime, encodedDataLength,
241 ResourceFetcher::DidFinishLoading); 245 ResourceFetcher::DidFinishLoading);
242 } 246 }
243 247
244 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) { 248 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) {
245 didFail(error); 249 didFail(error, Resource::LoadError);
246 } 250 }
247 251
248 void ResourceLoader::didFail(const ResourceError& error) { 252 void ResourceLoader::didFail(const ResourceError& error,
253 Resource::Status errorStatus) {
254 if (!m_loader)
255 return;
256
249 if (m_isCacheAwareLoadingActivated && error.isCacheMiss()) { 257 if (m_isCacheAwareLoadingActivated && error.isCacheMiss()) {
250 m_resource->willReloadAfterDiskCacheMiss(); 258 m_resource->willReloadAfterDiskCacheMiss();
251 m_isCacheAwareLoadingActivated = false; 259 m_isCacheAwareLoadingActivated = false;
252 restart(m_resource->resourceRequest(), 260 restart(m_resource->resourceRequest(),
253 m_fetcher->context().loadingTaskRunner(), 261 m_fetcher->context().loadingTaskRunner(),
254 m_fetcher->context().defersLoading()); 262 m_fetcher->context().defersLoading());
255 return; 263 return;
256 } 264 }
257 265
258 m_loader.reset(); 266 m_loader.reset();
259 m_fetcher->didFailLoading(m_resource.get(), error); 267 m_fetcher->didFailLoading(m_resource.get(), error, errorStatus);
260 } 268 }
261 269
262 void ResourceLoader::requestSynchronously(const ResourceRequest& request) { 270 void ResourceLoader::requestSynchronously(const ResourceRequest& request) {
263 // downloadToFile is not supported for synchronous requests. 271 // downloadToFile is not supported for synchronous requests.
264 DCHECK(!request.downloadToFile()); 272 DCHECK(!request.downloadToFile());
265 DCHECK(m_loader); 273 DCHECK(m_loader);
266 DCHECK_EQ(request.priority(), ResourceLoadPriorityHighest); 274 DCHECK_EQ(request.priority(), ResourceLoadPriorityHighest);
267 275
268 WrappedResourceRequest requestIn(request); 276 WrappedResourceRequest requestIn(request);
269 WebURLResponse responseOut; 277 WebURLResponse responseOut;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 return; 323 return;
316 324
317 // Don't activate if cache policy is explicitly set. 325 // Don't activate if cache policy is explicitly set.
318 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) 326 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy)
319 return; 327 return;
320 328
321 m_isCacheAwareLoadingActivated = true; 329 m_isCacheAwareLoadingActivated = true;
322 } 330 }
323 331
324 } // namespace blink 332 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698