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

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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 { 288 {
289 cancel(ResourceError()); 289 cancel(ResourceError());
290 } 290 }
291 291
292 void ResourceLoader::cancel(const ResourceError& error) 292 void ResourceLoader::cancel(const ResourceError& error)
293 { 293 {
294 // If the load has already completed - succeeded, failed, or previously canc elled - do nothing. 294 // If the load has already completed - succeeded, failed, or previously canc elled - do nothing.
295 if (m_reachedTerminalState) 295 if (m_reachedTerminalState)
296 return; 296 return;
297 297
298 ResourceError nonNullError = error.isNull() ? cancelledError() : error; 298 ResourceError nonNullError = error.isNull() ? ResourceError::createCancelled Error(m_request.url()) : error;
299 299
300 // This function calls out to clients at several points that might do 300 // 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. 301 // something that causes the last reference to this object to go away.
302 RefPtr<ResourceLoader> protector(this); 302 RefPtr<ResourceLoader> protector(this);
303 303
304 // If we re-enter cancel() from inside this if() block, we want to pick up f rom where we left 304 // 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 305 // off without re-running it
306 if (m_state == Initialized) { 306 if (m_state == Initialized) {
307 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().stri ng().latin1().data()); 307 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().stri ng().latin1().data());
308 m_state = Finishing; 308 m_state = Finishing;
(...skipping 21 matching lines...) Expand all
330 frameLoader()->notifier()->didFailToLoad(this, nonNullError); 330 frameLoader()->notifier()->didFailToLoad(this, nonNullError);
331 } 331 }
332 332
333 // If cancel() completed from within the call to willCancel() or didFailToLo ad(), 333 // If cancel() completed from within the call to willCancel() or didFailToLo ad(),
334 // we don't want to redo didCancel() or releasesResources(). 334 // we don't want to redo didCancel() or releasesResources().
335 if (m_reachedTerminalState) 335 if (m_reachedTerminalState)
336 return; 336 return;
337 releaseResources(); 337 releaseResources();
338 } 338 }
339 339
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) 340 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
351 { 341 {
352 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t his, request, redirectResponse)) 342 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t his, request, redirectResponse))
353 return; 343 return;
354 344
355 // Store the previous URL because we may modify it. 345 // Store the previous URL because we may modify it.
356 KURL previousURL = m_request.url(); 346 KURL previousURL = m_request.url();
357 RefPtr<ResourceLoader> protect(this); 347 RefPtr<ResourceLoader> protect(this);
358 348
359 ASSERT(!request.isNull()); 349 ASSERT(!request.isNull());
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 info.addMember(m_originalRequest, "originalRequest"); 589 info.addMember(m_originalRequest, "originalRequest");
600 info.addMember(m_resourceData, "resourceData"); 590 info.addMember(m_resourceData, "resourceData");
601 info.addMember(m_deferredRequest, "deferredRequest"); 591 info.addMember(m_deferredRequest, "deferredRequest");
602 info.addMember(m_options, "options"); 592 info.addMember(m_options, "options");
603 info.addMember(m_resource, "resource"); 593 info.addMember(m_resource, "resource");
604 info.addMember(m_documentLoader, "documentLoader"); 594 info.addMember(m_documentLoader, "documentLoader");
605 info.addMember(m_requestCountTracker, "requestCountTracker"); 595 info.addMember(m_requestCountTracker, "requestCountTracker");
606 } 596 }
607 597
608 } 598 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698