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

Side by Side Diff: Source/core/loader/DocumentLoader.cpp

Issue 14785010: Remove a bunch of ApplicationCacheHost functions and parameters we don't use. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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
« no previous file with comments | « Source/WebKit/chromium/src/ApplicationCacheHost.cpp ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 void DocumentLoader::setMainDocumentError(const ResourceError& error) 203 void DocumentLoader::setMainDocumentError(const ResourceError& error)
204 { 204 {
205 m_mainDocumentError = error; 205 m_mainDocumentError = error;
206 frameLoader()->client()->setMainDocumentError(this, error); 206 frameLoader()->client()->setMainDocumentError(this, error);
207 } 207 }
208 208
209 void DocumentLoader::mainReceivedError(const ResourceError& error) 209 void DocumentLoader::mainReceivedError(const ResourceError& error)
210 { 210 {
211 ASSERT(!error.isNull()); 211 ASSERT(!error.isNull());
212 if (m_applicationCacheHost->maybeLoadFallbackForMainError(request(), error))
213 return;
214
215 if (m_identifierForLoadWithoutResourceLoader) { 212 if (m_identifierForLoadWithoutResourceLoader) {
216 ASSERT(!mainResourceLoader()); 213 ASSERT(!mainResourceLoader());
217 frameLoader()->client()->dispatchDidFailLoading(this, m_identifierForLoa dWithoutResourceLoader, error); 214 frameLoader()->client()->dispatchDidFailLoading(this, m_identifierForLoa dWithoutResourceLoader, error);
218 } 215 }
219 216
220 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); 217 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());
221 218
222 m_applicationCacheHost->failedLoadingMainResource(); 219 m_applicationCacheHost->failedLoadingMainResource();
223 220
224 if (!frameLoader()) 221 if (!frameLoader())
(...skipping 21 matching lines...) Expand all
246 // Attempt to stop the frame if the document loader is loading, or if it is done loading but 243 // Attempt to stop the frame if the document loader is loading, or if it is done loading but
247 // still parsing. Failure to do so can cause a world leak. 244 // still parsing. Failure to do so can cause a world leak.
248 Document* doc = m_frame->document(); 245 Document* doc = m_frame->document();
249 246
250 if (loading || doc->parsing()) 247 if (loading || doc->parsing())
251 m_frame->loader()->stopLoading(UnloadEventPolicyNone); 248 m_frame->loader()->stopLoading(UnloadEventPolicyNone);
252 } 249 }
253 250
254 // Always cancel multipart loaders 251 // Always cancel multipart loaders
255 cancelAll(m_multipartResourceLoaders); 252 cancelAll(m_multipartResourceLoaders);
256
257 // Appcache uses ResourceHandle directly, DocumentLoader doesn't count these loads.
258 m_applicationCacheHost->stopLoadingInFrame(m_frame);
259 253
260 clearArchiveResources(); 254 clearArchiveResources();
261 255
262 if (!loading) { 256 if (!loading) {
263 // If something above restarted loading we might run into mysterious cra shes like 257 // If something above restarted loading we might run into mysterious cra shes like
264 // https://bugs.webkit.org/show_bug.cgi?id=62764 and <rdar://problem/932 8684> 258 // https://bugs.webkit.org/show_bug.cgi?id=62764 and <rdar://problem/932 8684>
265 ASSERT(!isLoading()); 259 ASSERT(!isLoading());
266 return; 260 return;
267 } 261 }
268 262
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 cancelMainResourceLoad(frameLoader()->cancelledError(newRequest)); 482 cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
489 return; 483 return;
490 } 484 }
491 } 485 }
492 486
493 setRequest(newRequest); 487 setRequest(newRequest);
494 488
495 if (redirectResponse.isNull()) 489 if (redirectResponse.isNull())
496 return; 490 return;
497 491
498 // We checked application cache for initial URL, now we need to check it for redirected one. 492 if (!shouldContinueForNavigationPolicy(newRequest))
499 ASSERT(!m_substituteData.isValid());
500 m_applicationCacheHost->maybeLoadMainResourceForRedirect(newRequest, m_subst ituteData);
501 if (m_substituteData.isValid())
502 m_identifierForLoadWithoutResourceLoader = mainResourceLoader()->identif ier();
503
504 if (!shouldContinueForNavigationPolicy(newRequest)) {
505 stopLoadingForPolicyChange(); 493 stopLoadingForPolicyChange();
506 return;
507 }
508
509 if (!m_substituteData.isValid())
510 return;
511 // A redirect resulted in loading substitute data.
512 ASSERT(timing()->redirectCount());
513
514 // We need to remove our reference to the CachedResource in favor of a Subst ituteData load.
515 // This will probably trigger the cancellation of the CachedResource's under lying ResourceLoader, though there is a
516 // small chance that the resource is being loaded by a different Frame, prev enting the ResourceLoader from being cancelled.
517 // If the ResourceLoader is indeed cancelled, it would normally send resourc e load callbacks.
518 // However, from an API perspective, this isn't a cancellation. Therefore, s ever our relationship with the network load,
519 // but prevent the ResourceLoader from sending ResourceLoadNotifier callback s.
520 RefPtr<ResourceLoader> resourceLoader = mainResourceLoader();
521 ASSERT(resourceLoader->shouldSendResourceLoadCallbacks());
522 resourceLoader->setSendCallbackPolicy(DoNotSendCallbacks);
523 if (m_mainResource) {
524 m_mainResource->removeClient(this);
525 m_mainResource = 0;
526 }
527 resourceLoader->setSendCallbackPolicy(SendCallbacks);
528 handleSubstituteDataLoadSoon();
529 } 494 }
530 495
531 bool DocumentLoader::shouldContinueForResponse() const 496 bool DocumentLoader::shouldContinueForResponse() const
532 { 497 {
533 if (m_substituteData.isValid()) 498 if (m_substituteData.isValid())
534 return true; 499 return true;
535 500
536 int statusCode = m_response.httpStatusCode(); 501 int statusCode = m_response.httpStatusCode();
537 if (statusCode == 204 || statusCode == 205) { 502 if (statusCode == 204 || statusCode == 205) {
538 // The server does not want us to replace the page contents. 503 // The server does not want us to replace the page contents.
(...skipping 15 matching lines...) Expand all
554 return false; 519 return false;
555 520
556 return true; 521 return true;
557 } 522 }
558 523
559 void DocumentLoader::responseReceived(CachedResource* resource, const ResourceRe sponse& response) 524 void DocumentLoader::responseReceived(CachedResource* resource, const ResourceRe sponse& response)
560 { 525 {
561 ASSERT_UNUSED(resource, m_mainResource == resource); 526 ASSERT_UNUSED(resource, m_mainResource == resource);
562 RefPtr<DocumentLoader> protect(this); 527 RefPtr<DocumentLoader> protect(this);
563 528
564 m_applicationCacheHost->maybeLoadFallbackForMainResponse(request(), response ); 529 m_applicationCacheHost->didReceiveResponseForMainResource(response);
565 530
566 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served 531 // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
567 // from the application cache, ensure we don't save the result for future us e. All responses loaded 532 // from the application cache, ensure we don't save the result for future us e. All responses loaded
568 // from appcache will have a non-zero appCacheID(). 533 // from appcache will have a non-zero appCacheID().
569 if (response.appCacheID()) 534 if (response.appCacheID())
570 memoryCache()->remove(m_mainResource.get()); 535 memoryCache()->remove(m_mainResource.get());
571 536
572 DEFINE_STATIC_LOCAL(AtomicString, xFrameOptionHeader, ("x-frame-options", At omicString::ConstructFromLiteral)); 537 DEFINE_STATIC_LOCAL(AtomicString, xFrameOptionHeader, ("x-frame-options", At omicString::ConstructFromLiteral));
573 HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(xFrameOp tionHeader); 538 HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(xFrameOp tionHeader);
574 if (it != response.httpHeaderFields().end()) { 539 if (it != response.httpHeaderFields().end()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 { 697 {
733 ASSERT(data); 698 ASSERT(data);
734 ASSERT(length); 699 ASSERT(length);
735 ASSERT_UNUSED(resource, resource == m_mainResource); 700 ASSERT_UNUSED(resource, resource == m_mainResource);
736 ASSERT(!m_response.isNull()); 701 ASSERT(!m_response.isNull());
737 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); 702 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());
738 703
739 if (m_identifierForLoadWithoutResourceLoader) 704 if (m_identifierForLoadWithoutResourceLoader)
740 frameLoader()->notifier()->dispatchDidReceiveData(this, m_identifierForL oadWithoutResourceLoader, data, length, -1); 705 frameLoader()->notifier()->dispatchDidReceiveData(this, m_identifierForL oadWithoutResourceLoader, data, length, -1);
741 706
742 m_applicationCacheHost->mainResourceDataReceived(data, length, -1, false); 707 m_applicationCacheHost->mainResourceDataReceived(data, length);
743 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); 708 m_timeOfLastDataReceived = monotonicallyIncreasingTime();
744 709
745 if (!isMultipartReplacingLoad()) 710 if (!isMultipartReplacingLoad())
746 commitLoad(data, length); 711 commitLoad(data, length);
747 } 712 }
748 713
749 void DocumentLoader::setupForReplace() 714 void DocumentLoader::setupForReplace()
750 { 715 {
751 if (!mainResourceData()) 716 if (!mainResourceData())
752 return; 717 return;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1051
1087 ASSERT(timing()->navigationStart()); 1052 ASSERT(timing()->navigationStart());
1088 ASSERT(!timing()->fetchStart()); 1053 ASSERT(!timing()->fetchStart());
1089 timing()->markFetchStart(); 1054 timing()->markFetchStart();
1090 willSendRequest(m_request, ResourceResponse()); 1055 willSendRequest(m_request, ResourceResponse());
1091 1056
1092 // willSendRequest() may lead to our Frame being detached or cancelling the load via nulling the ResourceRequest. 1057 // willSendRequest() may lead to our Frame being detached or cancelling the load via nulling the ResourceRequest.
1093 if (!m_frame || m_request.isNull()) 1058 if (!m_frame || m_request.isNull())
1094 return; 1059 return;
1095 1060
1096 m_applicationCacheHost->maybeLoadMainResource(m_request, m_substituteData); 1061 m_applicationCacheHost->willStartLoadingMainResource(m_request);
1097 1062
1098 if (m_substituteData.isValid()) { 1063 if (m_substituteData.isValid()) {
1099 m_identifierForLoadWithoutResourceLoader = createUniqueIdentifier(); 1064 m_identifierForLoadWithoutResourceLoader = createUniqueIdentifier();
1100 frameLoader()->notifier()->dispatchWillSendRequest(this, m_identifierFor LoadWithoutResourceLoader, m_request, ResourceResponse()); 1065 frameLoader()->notifier()->dispatchWillSendRequest(this, m_identifierFor LoadWithoutResourceLoader, m_request, ResourceResponse());
1101 handleSubstituteDataLoadSoon(); 1066 handleSubstituteDataLoadSoon();
1102 return; 1067 return;
1103 } 1068 }
1104 1069
1105 ResourceRequest request(m_request); 1070 ResourceRequest request(m_request);
1106 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 1071 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 commitLoad(resourceData->data(), resourceData->size()); 1130 commitLoad(resourceData->data(), resourceData->size());
1166 } 1131 }
1167 1132
1168 void DocumentLoader::handledOnloadEvents() 1133 void DocumentLoader::handledOnloadEvents()
1169 { 1134 {
1170 m_wasOnloadHandled = true; 1135 m_wasOnloadHandled = true;
1171 applicationCacheHost()->stopDeferringEvents(); 1136 applicationCacheHost()->stopDeferringEvents();
1172 } 1137 }
1173 1138
1174 } // namespace WebCore 1139 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/ApplicationCacheHost.cpp ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698