Changeset 137607 in webkit
- Timestamp:
- Dec 13, 2012, 10:27:51 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r137596 r137607 1 2012-12-13 Nate Chapin <japhet@chromium.org> 2 3 Route main resource loads through the memory cache. 4 https://bugs.webkit.org/show_bug.cgi?id=49246 5 6 Reviewed by Alexey Proskuryakov. 7 8 * http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: The error code for loads cancelled 9 by an embedder's willSendRequest() will show as standard load cancellations rather than as a content policy 10 failure. This was an odd quirk of how MainResourceLoader::willSendRequest() was implemented (namely, doing a 11 content policy check on ResourceRequests with empty urls). 12 * platform/chromium-linux/fast/replaced/border-radius-clip-content-edge-expected.png: 13 * platform/chromium/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: The error code for loads cancelled 14 by an embedder's willSendRequest() will show as standard load cancellations rather than as a content policy 15 failure. This was an odd quirk of how MainResourceLoader::willSendRequest() was implemented (namely, doing a 16 content policy check on ResourceRequests with empty urls). 17 1 18 2012-12-13 Joanmarie Diggs <jdiggs@igalia.com> 2 19 -
trunk/LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt
r137424 r137607 3 3 http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - willSendRequest <NSURLRequest URL http://www.example.com/, main document URL http://127.0.0.1:8000/misc/will-send-request-returns-null-on-redirect.html, http method GET> redirectResponse <NSURLResponse http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php, http status code 302> 4 4 Returning null for this redirect 5 http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 102>5 http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999> 6 6 https://bugs.webkit.org/show_bug.cgi?id=27595 7 7 This test checks to make sure that things behave as expected when the resource load delegate returns null in response to willSendRequest. -
trunk/LayoutTests/platform/chromium/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt
r137424 r137607 3 3 http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - willSendRequest <NSURLRequest URL http://www.example.com/, main document URL http://127.0.0.1:8000/misc/will-send-request-returns-null-on-redirect.html, http method GET> redirectResponse <NSURLResponse http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php, http status code 302> 4 4 Returning null for this redirect 5 http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - didFailLoadingWithError: <NSError domain WebKit, code -10000, failing URL "(null)">5 http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "(null)"> 6 6 https://bugs.webkit.org/show_bug.cgi?id=27595 7 7 This test checks to make sure that things behave as expected when the resource load delegate returns null in response to willSendRequest. -
trunk/Source/WebCore/ChangeLog
r137606 r137607 1 2012-12-13 Nate Chapin <japhet@chromium.org> 2 3 Route main resource loads through the memory cache. 4 https://bugs.webkit.org/show_bug.cgi?id=49246 5 6 Reviewed by Alexey Proskuryakov. 7 8 Note that this patch doesn't actually enable caching of main resources. That will be done in a later patch. 9 The MainResourceLoader actually has an underlying SubresourceLoader (with the cache layer between them). 10 In several places, the MainResourceLoader's SubresourceLoader is treated as special. 11 12 No new tests, as this is primarily a refactor. A couple of expected results changed slightly. 13 14 * loader/DocumentLoader.cpp: 15 (WebCore::DocumentLoader::setRequest): 16 (WebCore::DocumentLoader::subresource): 17 (WebCore::DocumentLoader::addSubresourceLoader): Because the SubresourceLoader underlying the main resource 18 needs special handling in certain cases, track it separately from the real SubresourceLoaders. 19 (WebCore::DocumentLoader::removeSubresourceLoader): 20 (WebCore::DocumentLoader::startLoadingMainResource): 21 * loader/MainResourceLoader.cpp: 22 (WebCore::MainResourceLoader::MainResourceLoader): 23 (WebCore::MainResourceLoader::receivedError): 24 (WebCore::MainResourceLoader::cancel): 25 (WebCore::MainResourceLoader::clearResource): 26 (WebCore): 27 (WebCore::MainResourceLoader::frameLoader): 28 (WebCore::MainResourceLoader::request): 29 (WebCore::MainResourceLoader::continueAfterNavigationPolicy): 30 (WebCore::MainResourceLoader::resourceData): 31 (WebCore::MainResourceLoader::redirectReceived): 32 (WebCore::MainResourceLoader::willSendRequest): 33 (WebCore::MainResourceLoader::continueAfterContentPolicy): 34 (WebCore::MainResourceLoader::responseReceived): 35 (WebCore::MainResourceLoader::dataReceived): 36 (WebCore::MainResourceLoader::didFinishLoading): 37 (WebCore::MainResourceLoader::notifyFinished): 38 (WebCore::MainResourceLoader::reportMemoryUsage): 39 (WebCore::MainResourceLoader::handleSubstituteDataLoadNow): 40 (WebCore::MainResourceLoader::load): 41 (WebCore::MainResourceLoader::setDefersLoading): 42 (WebCore::MainResourceLoader::defersLoading): 43 (WebCore::MainResourceLoader::setShouldBufferData): 44 (WebCore::MainResourceLoader::loader): 45 (WebCore::MainResourceLoader::identifier): 46 * loader/MainResourceLoader.h: 47 (MainResourceLoader): 48 (WebCore::MainResourceLoader::documentLoader): 49 * loader/ResourceLoader.cpp: 50 (WebCore::ResourceLoader::willSendRequest): 51 * loader/ResourceLoader.h: 52 (WebCore::ResourceLoader::defersLoading): 53 (WebCore::ResourceLoader::cancelled): 54 * loader/appcache/ApplicationCacheHost.cpp: 55 (WebCore::ApplicationCacheHost::maybeLoadFallbackForMainResponse): 56 (WebCore::ApplicationCacheHost::maybeLoadFallbackForMainError): 57 * loader/mac/DocumentLoaderMac.cpp: 58 (WebCore::DocumentLoader::schedule): 59 (WebCore::DocumentLoader::unschedule): 60 1 61 2012-12-13 Pratik Solanki <psolanki@apple.com> 2 62 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r137424 r137607 181 181 ASSERT(!m_committed); 182 182 183 KURL oldURL = m_request.url();184 183 m_request = req; 185 186 // Only dispatchDidReceiveServerRedirectForProvisionalLoad() if URL changed (and is non-null).187 // Also, don't send it when replacing unreachable URLs with alternate content.188 if (!handlingUnreachableURL && !req.url().isNull() && oldURL != req.url())189 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad();190 184 } 191 185 … … 586 580 return archiveResourceForURL(url); 587 581 582 if (resource->type() == CachedResource::MainResource) 583 return 0; 584 588 585 // FIXME: This has the side effect of making the resource non-purgeable. 589 586 // It would be better if it didn't have this permanent effect. … … 812 809 void DocumentLoader::addSubresourceLoader(ResourceLoader* loader) 813 810 { 811 // The main resource's underlying ResourceLoader will ask to be added here. 812 // It is much simpler to handle special casing of main resource loads if we don't 813 // let it be added. In the main resource load case, m_mainResourceLoader->loader() 814 // will still be null at this point, but m_gotFirstByte should be false here if and only 815 // if we are just starting the main resource load. 816 if (!m_gotFirstByte) 817 return; 818 ASSERT(!m_subresourceLoaders.contains(loader)); 819 ASSERT(!m_mainResourceLoader || m_mainResourceLoader->loader() != loader); 814 820 m_subresourceLoaders.add(loader); 815 821 } … … 817 823 void DocumentLoader::removeSubresourceLoader(ResourceLoader* loader) 818 824 { 825 if (!m_subresourceLoaders.contains(loader)) 826 return; 819 827 m_subresourceLoaders.remove(loader); 820 828 checkLoadComplete(); … … 882 890 if (m_request.isNull()) { 883 891 m_mainResourceLoader = 0; 892 // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost 893 // is now in a state where starting an empty load will be inconsistent. Replace it with 894 // a new ApplicationCacheHost. 895 m_applicationCacheHost = adoptPtr(new ApplicationCacheHost(this)); 884 896 maybeLoadEmpty(); 885 897 } -
trunk/Source/WebCore/loader/MainResourceLoader.cpp
r137424 r137607 33 33 #include "ApplicationCacheHost.h" 34 34 #include "BackForwardController.h" 35 #include "CachedResourceLoader.h" 36 #include "CachedResourceRequest.h" 35 37 #include "Console.h" 36 38 #include "DOMWindow.h" … … 45 47 #include "HistoryItem.h" 46 48 #include "InspectorInstrumentation.h" 47 #include "LoaderStrategy.h"48 49 #include "Page.h" 49 #include "PlatformStrategies.h" 50 #include "ProgressTracker.h" 51 #include "ResourceBuffer.h" 50 52 #include "ResourceError.h" 51 53 #include "ResourceHandle.h" 52 #include "ResourceLoadScheduler.h"53 54 #include "SchemeRegistry.h" 54 55 #include "SecurityOrigin.h" 55 56 #include "Settings.h" 57 #include "SubresourceLoader.h" 56 58 #include <wtf/CurrentTime.h> 57 59 … … 64 66 #endif 65 67 66 // FIXME: More that is in common with SubresourceLoader should move up into ResourceLoader.67 68 68 namespace WebCore { 69 69 70 70 MainResourceLoader::MainResourceLoader(DocumentLoader* documentLoader) 71 : ResourceLoader(documentLoader->frame(), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck))72 , m_d ataLoadTimer(this, &MainResourceLoader::handleSubstituteDataLoadNow)71 : m_dataLoadTimer(this, &MainResourceLoader::handleSubstituteDataLoadNow) 72 , m_documentLoader(documentLoader) 73 73 , m_loadingMultipartContent(false) 74 74 , m_waitingForContentPolicy(false) … … 82 82 MainResourceLoader::~MainResourceLoader() 83 83 { 84 clearResource(); 84 85 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 85 86 ASSERT(!m_filter); … … 103 104 // and didFailToLoad calls a ResourceLoadDelegate method and they need to be in the correct order. 104 105 documentLoader()->mainReceivedError(error); 105 106 if (!cancelled()) { 107 ASSERT(!reachedTerminalState()); 108 frameLoader()->notifier()->didFailToLoad(this, error); 109 110 releaseResources(); 111 } 112 113 ASSERT(reachedTerminalState()); 114 } 115 116 void MainResourceLoader::willCancel(const ResourceError&) 117 { 106 } 107 108 void MainResourceLoader::cancel() 109 { 110 cancel(ResourceError()); 111 } 112 113 void MainResourceLoader::cancel(const ResourceError& error) 114 { 115 RefPtr<MainResourceLoader> protect(this); 116 ResourceError resourceError = error.isNull() ? frameLoader()->cancelledError(request()) : error; 117 118 118 m_dataLoadTimer.stop(); 119 119 … … 122 122 ASSERT(m_waitingForContentPolicy); 123 123 m_waitingForContentPolicy = false; 124 deref(); // balances ref in didReceiveResponse 125 } 126 } 127 128 void MainResourceLoader::didCancel(const ResourceError& error) 129 { 130 // We should notify the frame loader after fully canceling the load, because it can do complicated work 131 // like calling DOMWindow::print(), during which a half-canceled load could try to finish. 132 documentLoader()->mainReceivedError(error); 124 deref(); // balances ref in responseReceived 125 } 126 127 if (loader()) 128 loader()->cancel(resourceError); 129 130 clearResource(); 131 receivedError(resourceError); 133 132 134 133 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 … … 138 137 } 139 138 #endif 139 } 140 141 void MainResourceLoader::clearResource() 142 { 143 if (m_resource) { 144 m_resource->removeClient(this); 145 m_resource = 0; 146 } 147 } 148 149 FrameLoader* MainResourceLoader::frameLoader() const 150 { 151 return m_documentLoader->frameLoader(); 152 } 153 154 const ResourceRequest& MainResourceLoader::request() const 155 { 156 return m_resource ? m_resource->resourceRequest() : m_initialRequest; 140 157 } 141 158 … … 164 181 // A redirect resulted in loading substitute data. 165 182 ASSERT(documentLoader()->timing()->redirectCount()); 166 handle()->cancel();183 clearResource(); 167 184 handleSubstituteDataLoadSoon(request); 168 185 } … … 184 201 } 185 202 186 void MainResourceLoader::addData(const char* data, int length, bool allAtOnce) 187 { 188 ResourceLoader::addData(data, length, allAtOnce); 189 documentLoader()->receivedData(data, length); 203 PassRefPtr<ResourceBuffer> MainResourceLoader::resourceData() 204 { 205 return m_resource ? m_resource->resourceBuffer() : 0; 206 } 207 208 void MainResourceLoader::redirectReceived(CachedResource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse) 209 { 210 ASSERT_UNUSED(resource, resource == m_resource); 211 willSendRequest(request, redirectResponse); 190 212 } 191 213 … … 240 262 } 241 263 242 ResourceLoader::willSendRequest(newRequest, redirectResponse);243 244 264 // Don't set this on the first request. It is set when the main load was started. 245 265 m_documentLoader->setRequest(newRequest); … … 278 298 frameLoader()->policyChecker()->cannotShowMIMEType(r); 279 299 // Check reachedTerminalState since the load may have already been canceled inside of _handleUnimplementablePolicyWithErrorCode::. 280 if (!reachedTerminalState()) 281 stopLoadingForPolicyChange(); 300 stopLoadingForPolicyChange(); 282 301 return; 283 302 } … … 286 305 287 306 case PolicyDownload: { 288 // m_ handle can be null, e.g. when loading a substitute resource from application cache.289 if (!m_ handle) {290 receivedError( cannotShowURLError());307 // m_resource can be null, e.g. when loading a substitute resource from application cache. 308 if (!m_resource) { 309 receivedError(frameLoader()->client()->cannotShowURLError(request())); 291 310 return; 292 311 } … … 298 317 frameLoader()->setOriginalURLForDownloadRequest(request); 299 318 300 frameLoader()->client()->download( m_handle.get(), request, r);319 frameLoader()->client()->download(loader()->handle(), request, r); 301 320 302 321 // It might have gone missing … … 330 349 } 331 350 332 // we may have cancelled this load as part of switching to fallback content 333 if (!reachedTerminalState()) 334 ResourceLoader::didReceiveResponse(r); 335 336 if (m_documentLoader && !m_documentLoader->isStopping() && m_substituteData.isValid()) { 351 if (!m_documentLoader->isStopping() && m_substituteData.isValid()) { 337 352 if (m_substituteData.content()->size()) 338 d idReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);353 dataReceived(0, m_substituteData.content()->data(), m_substituteData.content()->size()); 339 354 if (!m_documentLoader->isStopping()) 340 355 didFinishLoading(0); … … 353 368 if (!m_documentLoader->isStopping()) 354 369 continueAfterContentPolicy(policy, m_response); 355 deref(); // balances ref in didReceiveResponse 356 } 357 358 void MainResourceLoader::didReceiveResponse(const ResourceResponse& r) 359 { 370 deref(); // balances ref in responseReceived 371 } 372 373 void MainResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& r) 374 { 375 ASSERT_UNUSED(resource, m_resource == resource); 360 376 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r)) 361 377 return; … … 383 399 if (m_loadingMultipartContent) { 384 400 m_documentLoader->setupForReplace(); 385 clearResourceData();401 m_resource->clear(); 386 402 } 387 403 … … 399 415 ASSERT(!m_waitingForContentPolicy); 400 416 m_waitingForContentPolicy = true; 401 ref(); // balanced by deref in continueAfterContentPolicy and didCancel417 ref(); // balanced by deref in continueAfterContentPolicy and cancel 402 418 403 419 // Always show content with valid substitute data. … … 424 440 } 425 441 426 void MainResourceLoader::d idReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)442 void MainResourceLoader::dataReceived(CachedResource* resource, const char* data, int length) 427 443 { 428 444 ASSERT(data); 429 445 ASSERT(length != 0); 430 446 ASSERT_UNUSED(resource, resource == m_resource); 431 447 ASSERT(!m_response.isNull()); 432 448 … … 453 469 if (!blockedData) { 454 470 // Transition to committed state. 455 ResourceLoader::didReceiveData("", 0, 0, false);471 documentLoader()->receivedData(0, 0); 456 472 return; 457 473 } 458 474 459 475 data = blockedData; 460 encodedDataLength = -1; 461 } 462 #endif 463 464 documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, encodedDataLength, allAtOnce); 476 } 477 #endif 478 479 documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, -1, false); 465 480 466 481 // The additional processing can do anything including possibly removing the last … … 470 485 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); 471 486 472 ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);487 documentLoader()->receivedData(data, length); 473 488 474 489 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 … … 491 506 // See <rdar://problem/6304600> for more details. 492 507 #if !USE(CF) 493 ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_ frame.get()));508 ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_documentLoader->frame())); 494 509 #endif 495 510 … … 507 522 m_filter = 0; 508 523 if (data) 509 d idReceiveData(data, length, -1, false);524 dataReceived(m_resource.get(), data, length); 510 525 wkFilterRelease(filter); 511 526 } … … 517 532 documentLoader()->timing()->setResponseEnd(finishTime ? finishTime : (m_timeOfLastDataReceived ? m_timeOfLastDataReceived : monotonicallyIncreasingTime())); 518 533 documentLoader()->finishedLoading(); 519 ResourceLoader::didFinishLoading(finishTime);520 534 521 535 dl->applicationCacheHost()->finishedLoadingMainResource(); 522 536 } 523 537 524 void MainResourceLoader::didFail(const ResourceError& error) 525 { 538 void MainResourceLoader::notifyFinished(CachedResource* resource) 539 { 540 ASSERT_UNUSED(resource, m_resource == resource); 541 if (!m_resource || (!m_resource->errorOccurred() && !m_resource->wasCanceled())) { 542 didFinishLoading(m_resource->loadFinishTime()); 543 return; 544 } 545 526 546 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 527 547 if (m_filter) { … … 531 551 #endif 532 552 553 const ResourceError& error = m_resource->resourceError(); 533 554 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainError(request(), error)) 534 555 return; … … 546 567 { 547 568 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); 548 ResourceLoader::reportMemoryUsage(memoryObjectInfo);549 569 info.addMember(m_initialRequest); 550 570 info.addMember(m_substituteData); … … 565 585 566 586 ResourceResponse response(url, m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding(), ""); 567 didReceiveResponse(response);587 responseReceived(0, response); 568 588 } 569 589 … … 588 608 } 589 609 590 void MainResourceLoader::loadNow(ResourceRequest& r) 591 { 592 ASSERT(!m_handle); 593 ASSERT(!defersLoading()); 594 595 #if USE(PLATFORM_STRATEGIES) 596 platformStrategies()->loaderStrategy()->resourceLoadScheduler()->addMainResourceLoad(this); 597 #else 598 resourceLoadScheduler()->addMainResourceLoad(this); 599 #endif 600 601 if (m_substituteData.isValid()) 602 handleSubstituteDataLoadSoon(r); 603 else 604 m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), r, this, false, true); 605 606 return; 607 } 608 609 void MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& substituteData) 610 { 611 ASSERT(!m_handle); 612 610 void MainResourceLoader::load(const ResourceRequest& initialRequest, const SubstituteData& substituteData) 611 { 613 612 // It appears that it is possible for this load to be cancelled and derefenced by the DocumentLoader 614 613 // in willSendRequest() if loadNow() is called. … … 620 619 ASSERT(!documentLoader()->timing()->fetchStart()); 621 620 documentLoader()->timing()->markFetchStart(); 622 ResourceRequest request( r);621 ResourceRequest request(initialRequest); 623 622 624 623 // Send this synthetic delegate callback since clients expect it, and … … 628 627 ASSERT(!deletionHasBegun()); 629 628 630 // <rdar://problem/4801066> 631 // willSendRequest() is liable to make the call to frameLoader() return null, so we need to check that here 632 if (!frameLoader() || request.isNull()) { 633 if (!reachedTerminalState()) 634 releaseResources(); 635 return; 636 } 629 // willSendRequest() may lead to our DocumentLoader being detached or cancelling the load via nulling the ResourceRequest. 630 if (!documentLoader()->frame() || request.isNull()) 631 return; 637 632 638 633 documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData); 639 634 640 if (defersLoading()) 641 m_initialRequest = request; 642 else 643 loadNow(request); 635 if (m_substituteData.isValid()) { 636 handleSubstituteDataLoadSoon(request); 637 return; 638 } 639 640 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 641 (SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck)); 642 CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions); 643 m_resource = documentLoader()->cachedResourceLoader()->requestMainResource(cachedResourceRequest); 644 if (!m_resource) { 645 documentLoader()->setRequest(ResourceRequest()); 646 return; 647 } 648 m_resource->addClient(this); 649 650 // We need to wait until after requestMainResource() is called to setRequest(), because there are a bunch of headers set when 651 // the underlying ResourceLoader is created, and DocumentLoader::m_request needs to include those. However, the cache will 652 // strip the fragment identifier (which DocumentLoader::m_request should also include), so add that back in. 653 if (loader()) 654 request = loader()->originalRequest(); 655 documentLoader()->setRequest(request); 644 656 } 645 657 646 658 void MainResourceLoader::setDefersLoading(bool defers) 647 659 { 648 ResourceLoader::setDefersLoading(defers); 649 650 if (defers) { 651 if (m_dataLoadTimer.isActive()) 652 m_dataLoadTimer.stop(); 653 } else { 654 if (m_initialRequest.isNull()) 655 return; 656 657 ResourceRequest initialRequest(m_initialRequest); 658 m_initialRequest = ResourceRequest(); 659 loadNow(initialRequest); 660 } 661 } 662 663 } 660 if (loader()) 661 loader()->setDefersLoading(defers); 662 } 663 664 bool MainResourceLoader::defersLoading() const 665 { 666 return loader() ? loader()->defersLoading() : false; 667 } 668 669 void MainResourceLoader::setShouldBufferData(DataBufferingPolicy shouldBufferData) 670 { 671 ASSERT(m_resource); 672 m_resource->setShouldBufferData(shouldBufferData); 673 } 674 675 ResourceLoader* MainResourceLoader::loader() const 676 { 677 return m_resource ? m_resource->loader() : 0; 678 } 679 680 unsigned long MainResourceLoader::identifier() const 681 { 682 if (ResourceLoader* resourceLoader = loader()) 683 return resourceLoader->identifier(); 684 return 0; 685 } 686 687 } -
trunk/Source/WebCore/loader/MainResourceLoader.h
r137424 r137607 30 30 #define MainResourceLoader_h 31 31 32 #include "CachedRawResource.h" 33 #include "CachedResourceHandle.h" 32 34 #include "FrameLoaderTypes.h" 33 35 #include "ResourceLoader.h" … … 50 52 class ResourceRequest; 51 53 52 class MainResourceLoader : public ResourceLoader { 54 class MainResourceLoader : public RefCounted<MainResourceLoader>, public CachedRawResourceClient { 55 WTF_MAKE_FAST_ALLOCATED; 53 56 public: 54 57 static PassRefPtr<MainResourceLoader> create(DocumentLoader*); … … 56 59 57 60 void load(const ResourceRequest&, const SubstituteData&); 58 virtual void addData(const char*, int, bool allAtOnce) OVERRIDE; 61 void cancel(); 62 void cancel(const ResourceError&); 63 ResourceLoader* loader() const; 64 PassRefPtr<ResourceBuffer> resourceData(); 59 65 60 virtual void setDefersLoading(bool) OVERRIDE; 61 62 virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse) OVERRIDE; 63 virtual void didReceiveResponse(const ResourceResponse&) OVERRIDE; 64 virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce) OVERRIDE; 65 virtual void didFinishLoading(double finishTime) OVERRIDE; 66 virtual void didFail(const ResourceError&) OVERRIDE; 66 void setDefersLoading(bool); 67 void setShouldBufferData(DataBufferingPolicy); 67 68 68 69 #if HAVE(RUNLOOP_TIMER) … … 72 73 #endif 73 74 75 unsigned long identifier() const; 74 76 bool isLoadingMultipartContent() const { return m_loadingMultipartContent; } 75 77 76 v irtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;78 void reportMemoryUsage(MemoryObjectInfo*) const; 77 79 78 80 private: 79 81 explicit MainResourceLoader(DocumentLoader*); 80 82 81 virtual void willCancel(const ResourceError&) OVERRIDE; 82 virtual void didCancel(const ResourceError&) OVERRIDE; 83 virtual void redirectReceived(CachedResource*, ResourceRequest&, const ResourceResponse&) OVERRIDE; 84 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE; 85 virtual void dataReceived(CachedResource*, const char* data, int dataLength) OVERRIDE; 86 virtual void notifyFinished(CachedResource*) OVERRIDE; 83 87 84 void loadNow(ResourceRequest&);85 88 void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse); 89 void didFinishLoading(double finishTime); 86 90 void handleSubstituteDataLoadSoon(const ResourceRequest&); 87 91 void handleSubstituteDataLoadNow(MainResourceLoaderTimer*); … … 105 109 #endif 106 110 111 FrameLoader* frameLoader() const; 112 DocumentLoader* documentLoader() const { return m_documentLoader.get(); } 113 114 const ResourceRequest& request() const; 115 void clearResource(); 116 117 bool defersLoading() const; 118 119 CachedResourceHandle<CachedRawResource> m_resource; 120 107 121 ResourceRequest m_initialRequest; 108 122 SubstituteData m_substituteData; 123 ResourceResponse m_response; 109 124 110 125 MainResourceLoaderTimer m_dataLoadTimer; 126 RefPtr<DocumentLoader> m_documentLoader; 111 127 112 128 bool m_loadingMultipartContent; -
trunk/Source/WebCore/loader/ResourceLoader.cpp
r137424 r137607 252 252 } 253 253 m_request = request; 254 255 if (!redirectResponse.isNull() && !m_documentLoader->isCommitted()) 256 frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad(); 254 257 } 255 258 -
trunk/Source/WebCore/loader/ResourceLoader.h
r137424 r137607 66 66 67 67 virtual void setDefersLoading(bool); 68 bool defersLoading() const { return m_defersLoading; } 68 69 69 70 unsigned long identifier() const { return m_identifier; } … … 168 169 169 170 bool cancelled() const { return m_cancelled; } 170 bool defersLoading() const { return m_defersLoading; }171 171 172 172 RefPtr<ResourceHandle> m_handle; -
trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
r137424 r137607 104 104 m_mainResourceApplicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request, documentLoader()); 105 105 106 if (scheduleLoadFallbackResourceFromApplicationCache(documentLoader()->mainResourceLoader() , m_mainResourceApplicationCache.get()))106 if (scheduleLoadFallbackResourceFromApplicationCache(documentLoader()->mainResourceLoader()->loader(), m_mainResourceApplicationCache.get())) 107 107 return true; 108 108 } … … 118 118 m_mainResourceApplicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request, m_documentLoader); 119 119 120 if (scheduleLoadFallbackResourceFromApplicationCache(documentLoader()->mainResourceLoader() , m_mainResourceApplicationCache.get()))120 if (scheduleLoadFallbackResourceFromApplicationCache(documentLoader()->mainResourceLoader()->loader(), m_mainResourceApplicationCache.get())) 121 121 return true; 122 122 } -
trunk/Source/WebCore/loader/cache/CachedRawResource.cpp
r137424 r137607 99 99 void CachedRawResource::willSendRequest(ResourceRequest& request, const ResourceResponse& response) 100 100 { 101 CachedResourceHandle<CachedRawResource> protect(this); 101 102 if (!response.isNull()) { 102 103 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r137604 r137607 704 704 705 705 #if ENABLE(RESOURCE_TIMING) 706 if (resource && !resource->errorOccurred() && !resource->wasCanceled()) { 706 // FIXME: Add resource timing support for main resources. 707 if (resource && resource->type() != CachedResource::MainResource && !resource->errorOccurred() && !resource->wasCanceled()) { 707 708 HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initiatorMap.find(resource); 708 709 if (initiatorIt != m_initiatorMap.end()) { -
trunk/Source/WebCore/loader/mac/DocumentLoaderMac.cpp
r137424 r137607 56 56 void DocumentLoader::schedule(SchedulePair* pair) 57 57 { 58 if (m_mainResourceLoader && m_mainResourceLoader-> handle())59 m_mainResourceLoader-> handle()->schedule(pair);58 if (m_mainResourceLoader && m_mainResourceLoader->loader() && m_mainResourceLoader->loader()->handle()) 59 m_mainResourceLoader->loader()->handle()->schedule(pair); 60 60 scheduleAll(m_subresourceLoaders, pair); 61 61 scheduleAll(m_plugInStreamLoaders, pair); … … 65 65 void DocumentLoader::unschedule(SchedulePair* pair) 66 66 { 67 if (m_mainResourceLoader && m_mainResourceLoader-> handle())68 m_mainResourceLoader-> handle()->unschedule(pair);67 if (m_mainResourceLoader && m_mainResourceLoader->loader() && m_mainResourceLoader->loader()->handle()) 68 m_mainResourceLoader->loader()->handle()->unschedule(pair); 69 69 unscheduleAll(m_subresourceLoaders, pair); 70 70 unscheduleAll(m_plugInStreamLoaders, pair);
Note:
See TracChangeset
for help on using the changeset viewer.