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

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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 { 345 {
346 cancel(ResourceError()); 346 cancel(ResourceError());
347 } 347 }
348 348
349 void ResourceLoader::cancel(const ResourceError& error) 349 void ResourceLoader::cancel(const ResourceError& error)
350 { 350 {
351 // If the load has already completed - succeeded, failed, or previously canc elled - do nothing. 351 // If the load has already completed - succeeded, failed, or previously canc elled - do nothing.
352 if (m_reachedTerminalState) 352 if (m_reachedTerminalState)
353 return; 353 return;
354 354
355 ResourceError nonNullError = error.isNull() ? cancelledError() : error; 355 ResourceError nonNullError = error.isNull() ? ResourceError::createCancelled Error(m_request.url()) : error;
356 356
357 // This function calls out to clients at several points that might do 357 // This function calls out to clients at several points that might do
358 // something that causes the last reference to this object to go away. 358 // something that causes the last reference to this object to go away.
359 RefPtr<ResourceLoader> protector(this); 359 RefPtr<ResourceLoader> protector(this);
360 360
361 // If we re-enter cancel() from inside this if() block, we want to pick up f rom where we left 361 // If we re-enter cancel() from inside this if() block, we want to pick up f rom where we left
362 // off without re-running it 362 // off without re-running it
363 if (m_state == Initialized) { 363 if (m_state == Initialized) {
364 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().stri ng().latin1().data()); 364 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().stri ng().latin1().data());
365 m_state = Finishing; 365 m_state = Finishing;
(...skipping 21 matching lines...) Expand all
387 frameLoader()->notifier()->didFailToLoad(this, nonNullError); 387 frameLoader()->notifier()->didFailToLoad(this, nonNullError);
388 } 388 }
389 389
390 // If cancel() completed from within the call to willCancel() or didFailToLo ad(), 390 // If cancel() completed from within the call to willCancel() or didFailToLo ad(),
391 // we don't want to redo didCancel() or releasesResources(). 391 // we don't want to redo didCancel() or releasesResources().
392 if (m_reachedTerminalState) 392 if (m_reachedTerminalState)
393 return; 393 return;
394 releaseResources(); 394 releaseResources();
395 } 395 }
396 396
397 ResourceError ResourceLoader::cancelledError()
398 {
399 return frameLoader()->cancelledError(m_request);
400 }
401
402 ResourceError ResourceLoader::cannotShowURLError()
403 {
404 return frameLoader()->client()->cannotShowURLError(m_request);
405 }
406
407 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse) 397 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
408 { 398 {
409 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t his, request, redirectResponse)) 399 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t his, request, redirectResponse))
410 return; 400 return;
411 willSendRequest(request, redirectResponse); 401 willSendRequest(request, redirectResponse);
412 } 402 }
413 403
414 void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) 404 void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
415 { 405 {
416 ASSERT(m_state == Initialized); 406 ASSERT(m_state == Initialized);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 info.addMember(m_originalRequest, "originalRequest"); 489 info.addMember(m_originalRequest, "originalRequest");
500 info.addMember(m_resourceData, "resourceData"); 490 info.addMember(m_resourceData, "resourceData");
501 info.addMember(m_deferredRequest, "deferredRequest"); 491 info.addMember(m_deferredRequest, "deferredRequest");
502 info.addMember(m_options, "options"); 492 info.addMember(m_options, "options");
503 info.addMember(m_resource, "resource"); 493 info.addMember(m_resource, "resource");
504 info.addMember(m_documentLoader, "documentLoader"); 494 info.addMember(m_documentLoader, "documentLoader");
505 info.addMember(m_requestCountTracker, "requestCountTracker"); 495 info.addMember(m_requestCountTracker, "requestCountTracker");
506 } 496 }
507 497
508 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698