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

Side by Side Diff: Source/WebCore/loader/ResourceLoader.cpp

Issue 14264012: Create errors (especially cancellation errors) internally to WebCore, rather (Closed) Base URL: svn://svn.chromium.org/blink/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
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 14 matching lines...) Expand all
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "ResourceLoader.h" 31 #include "ResourceLoader.h"
32 32
33 #include "ApplicationCacheHost.h" 33 #include "ApplicationCacheHost.h"
34 #include "CachedResourceLoader.h" 34 #include "CachedResourceLoader.h"
35 #include "CancelledResourceError.h"
35 #include "DocumentLoader.h" 36 #include "DocumentLoader.h"
36 #include "Frame.h" 37 #include "Frame.h"
37 #include "FrameLoader.h" 38 #include "FrameLoader.h"
38 #include "FrameLoaderClient.h" 39 #include "FrameLoaderClient.h"
39 #include "InspectorInstrumentation.h" 40 #include "InspectorInstrumentation.h"
40 #include "Logging.h" 41 #include "Logging.h"
41 #include "MemoryCache.h" 42 #include "MemoryCache.h"
42 #include "Page.h" 43 #include "Page.h"
43 #include "ProgressTracker.h" 44 #include "ProgressTracker.h"
44 #include "ResourceBuffer.h" 45 #include "ResourceBuffer.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 { 289 {
289 cancel(ResourceError()); 290 cancel(ResourceError());
290 } 291 }
291 292
292 void ResourceLoader::cancel(const ResourceError& error) 293 void ResourceLoader::cancel(const ResourceError& error)
293 { 294 {
294 // If the load has already completed - succeeded, failed, or previously canc elled - do nothing. 295 // If the load has already completed - succeeded, failed, or previously canc elled - do nothing.
295 if (m_reachedTerminalState) 296 if (m_reachedTerminalState)
296 return; 297 return;
297 298
298 ResourceError nonNullError = error.isNull() ? cancelledError() : error; 299 ResourceError nonNullError = error.isNull() ? CancelledResourceError(m_reque st.url()) : error;
darin (slow to review) 2013/04/17 18:58:11 I think some compilers will actually complain here
299 300
300 // This function calls out to clients at several points that might do 301 // This function calls out to clients at several points that might do
301 // something that causes the last reference to this object to go away. 302 // something that causes the last reference to this object to go away.
302 RefPtr<ResourceLoader> protector(this); 303 RefPtr<ResourceLoader> protector(this);
303 304
304 // If we re-enter cancel() from inside this if() block, we want to pick up f rom where we left 305 // If we re-enter cancel() from inside this if() block, we want to pick up f rom where we left
305 // off without re-running it 306 // off without re-running it
306 if (m_state == Initialized) { 307 if (m_state == Initialized) {
307 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().stri ng().latin1().data()); 308 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().stri ng().latin1().data());
308 m_state = Finishing; 309 m_state = Finishing;
(...skipping 21 matching lines...) Expand all
330 frameLoader()->notifier()->didFailToLoad(this, nonNullError); 331 frameLoader()->notifier()->didFailToLoad(this, nonNullError);
331 } 332 }
332 333
333 // If cancel() completed from within the call to willCancel() or didFailToLo ad(), 334 // If cancel() completed from within the call to willCancel() or didFailToLo ad(),
334 // we don't want to redo didCancel() or releasesResources(). 335 // we don't want to redo didCancel() or releasesResources().
335 if (m_reachedTerminalState) 336 if (m_reachedTerminalState)
336 return; 337 return;
337 releaseResources(); 338 releaseResources();
338 } 339 }
339 340
340 ResourceError ResourceLoader::cancelledError()
341 {
342 return frameLoader()->cancelledError(m_request);
343 }
344
345 ResourceError ResourceLoader::cannotShowURLError()
346 {
347 return frameLoader()->client()->cannotShowURLError(m_request);
348 }
349
350 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse) 341 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
351 { 342 {
352 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t his, request, redirectResponse)) 343 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t his, request, redirectResponse))
353 return; 344 return;
354 345
355 // Store the previous URL because we may modify it. 346 // Store the previous URL because we may modify it.
356 KURL previousURL = m_request.url(); 347 KURL previousURL = m_request.url();
357 RefPtr<ResourceLoader> protect(this); 348 RefPtr<ResourceLoader> protect(this);
358 349
359 ASSERT(!request.isNull()); 350 ASSERT(!request.isNull());
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 info.addMember(m_originalRequest, "originalRequest"); 591 info.addMember(m_originalRequest, "originalRequest");
601 info.addMember(m_resourceData, "resourceData"); 592 info.addMember(m_resourceData, "resourceData");
602 info.addMember(m_deferredRequest, "deferredRequest"); 593 info.addMember(m_deferredRequest, "deferredRequest");
603 info.addMember(m_options, "options"); 594 info.addMember(m_options, "options");
604 info.addMember(m_resource, "resource"); 595 info.addMember(m_resource, "resource");
605 info.addMember(m_documentLoader, "documentLoader"); 596 info.addMember(m_documentLoader, "documentLoader");
606 info.addMember(m_requestCountTracker, "requestCountTracker"); 597 info.addMember(m_requestCountTracker, "requestCountTracker");
607 } 598 }
608 599
609 } 600 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698