Changeset 137333 in webkit
- Timestamp:
- Dec 11, 2012 10:28:26 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r137332 r137333 1 2012-12-11 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 Antti Koivisto. 7 8 * http/tests/inspector/resource-parameters.html: The main resource's url will exclude the fragment identifier here. 9 * http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: The error code for loads cancelled 10 by an embedder's willSendRequest() will show as standard load cancellations rather than as a content policy 11 failure. This was an odd quirk of how MainResourceLoader::willSendRequest() was implemented (namely, doing a 12 content policy check on ResourceRequests with empty urls). 13 * platform/chromium/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: See previous. 14 1 15 2012-12-11 Aaron Colwell <acolwell@chromium.org> 2 16 -
trunk/LayoutTests/http/tests/inspector/resource-parameters.html
r113863 r137333 18 18 { 19 19 var request = event.data; 20 if (request.url !== "http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2= #fragmentParam1=fragmentValue1&fragmentParam2=")20 if (request.url !== "http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2=") 21 21 return; 22 22 InspectorTest.addObject(new WebInspector.HAREntry(request).build(), InspectorTest.HARPropertyFormatters); -
trunk/LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt
r84742 r137333 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
r117009 r137333 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
r137332 r137333 1 2012-12-11 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 Antti Koivisto. 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-11 Aaron Colwell <acolwell@chromium.org> 2 62 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r136412 r137333 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
r137318 r137333 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) … … 103 103 // and didFailToLoad calls a ResourceLoadDelegate method and they need to be in the correct order. 104 104 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 { 105 } 106 107 void MainResourceLoader::cancel() 108 { 109 cancel(ResourceError()); 110 } 111 112 void MainResourceLoader::cancel(const ResourceError& error) 113 { 114 RefPtr<MainResourceLoader> protect(this); 115 ResourceError resourceError = error.isNull() ? frameLoader()->cancelledError(request()) : error; 116 118 117 m_dataLoadTimer.stop(); 119 118 … … 122 121 ASSERT(m_waitingForContentPolicy); 123 122 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); 123 deref(); // balances ref in responseReceived 124 } 125 126 if (loader()) 127 loader()->cancel(resourceError); 128 129 clearResource(); 130 receivedError(resourceError); 133 131 134 132 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 … … 138 136 } 139 137 #endif 138 } 139 140 void MainResourceLoader::clearResource() 141 { 142 if (m_resource) { 143 m_resource->removeClient(this); 144 m_resource = 0; 145 } 146 } 147 148 FrameLoader* MainResourceLoader::frameLoader() const 149 { 150 return m_documentLoader->frameLoader(); 151 } 152 153 const ResourceRequest& MainResourceLoader::request() const 154 { 155 return m_resource ? m_resource->resourceRequest() : m_initialRequest; 140 156 } 141 157 … … 164 180 // A redirect resulted in loading substitute data. 165 181 ASSERT(documentLoader()->timing()->redirectCount()); 166 handle()->cancel();182 clearResource(); 167 183 handleSubstituteDataLoadSoon(request); 168 184 } … … 184 200 } 185 201 186 void MainResourceLoader::addData(const char* data, int length, bool allAtOnce) 187 { 188 ResourceLoader::addData(data, length, allAtOnce); 189 documentLoader()->receivedData(data, length); 202 PassRefPtr<ResourceBuffer> MainResourceLoader::resourceData() 203 { 204 return m_resource ? m_resource->resourceBuffer() : 0; 205 } 206 207 void MainResourceLoader::redirectReceived(CachedResource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse) 208 { 209 ASSERT_UNUSED(resource, resource == m_resource); 210 willSendRequest(request, redirectResponse); 190 211 } 191 212 … … 240 261 } 241 262 242 ResourceLoader::willSendRequest(newRequest, redirectResponse);243 244 263 // Don't set this on the first request. It is set when the main load was started. 245 264 m_documentLoader->setRequest(newRequest); … … 278 297 frameLoader()->policyChecker()->cannotShowMIMEType(r); 279 298 // Check reachedTerminalState since the load may have already been canceled inside of _handleUnimplementablePolicyWithErrorCode::. 280 if (!reachedTerminalState()) 281 stopLoadingForPolicyChange(); 299 stopLoadingForPolicyChange(); 282 300 return; 283 301 } … … 286 304 287 305 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());306 // m_resource can be null, e.g. when loading a substitute resource from application cache. 307 if (!m_resource) { 308 receivedError(frameLoader()->client()->cannotShowURLError(request())); 291 309 return; 292 310 } … … 298 316 frameLoader()->setOriginalURLForDownloadRequest(request); 299 317 300 frameLoader()->client()->download( m_handle.get(), request, r);318 frameLoader()->client()->download(loader()->handle(), request, r); 301 319 302 320 // It might have gone missing … … 330 348 } 331 349 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()) { 350 if (!m_documentLoader->isStopping() && m_substituteData.isValid()) { 337 351 if (m_substituteData.content()->size()) 338 d idReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);352 dataReceived(0, m_substituteData.content()->data(), m_substituteData.content()->size()); 339 353 if (!m_documentLoader->isStopping()) 340 354 didFinishLoading(0); … … 353 367 if (!m_documentLoader->isStopping()) 354 368 continueAfterContentPolicy(policy, m_response); 355 deref(); // balances ref in didReceiveResponse 356 } 357 358 void MainResourceLoader::didReceiveResponse(const ResourceResponse& r) 359 { 369 deref(); // balances ref in responseReceived 370 } 371 372 void MainResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& r) 373 { 374 ASSERT_UNUSED(resource, m_resource == resource); 360 375 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r)) 361 376 return; … … 383 398 if (m_loadingMultipartContent) { 384 399 m_documentLoader->setupForReplace(); 385 clearResourceData();400 m_resource->clear(); 386 401 } 387 402 … … 399 414 ASSERT(!m_waitingForContentPolicy); 400 415 m_waitingForContentPolicy = true; 401 ref(); // balanced by deref in continueAfterContentPolicy and didCancel416 ref(); // balanced by deref in continueAfterContentPolicy and cancel 402 417 403 418 // Always show content with valid substitute data. … … 424 439 } 425 440 426 void MainResourceLoader::d idReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)441 void MainResourceLoader::dataReceived(CachedResource* resource, const char* data, int length) 427 442 { 428 443 ASSERT(data); 429 444 ASSERT(length != 0); 430 445 ASSERT_UNUSED(resource, resource == m_resource); 431 446 ASSERT(!m_response.isNull()); 432 447 … … 453 468 if (!blockedData) { 454 469 // Transition to committed state. 455 ResourceLoader::didReceiveData("", 0, 0, false);470 documentLoader()->receivedData(0, 0); 456 471 return; 457 472 } 458 473 459 474 data = blockedData; 460 encodedDataLength = -1; 461 } 462 #endif 463 464 documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, encodedDataLength, allAtOnce); 475 } 476 #endif 477 478 documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, -1, false); 465 479 466 480 // The additional processing can do anything including possibly removing the last … … 470 484 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); 471 485 472 ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);486 documentLoader()->receivedData(data, length); 473 487 474 488 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 … … 491 505 // See <rdar://problem/6304600> for more details. 492 506 #if !USE(CF) 493 ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_ frame.get()));507 ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_documentLoader->frame())); 494 508 #endif 495 509 … … 507 521 m_filter = 0; 508 522 if (data) 509 d idReceiveData(data, length, -1, false);523 dataReceived(m_resource.get(), data, length); 510 524 wkFilterRelease(filter); 511 525 } … … 517 531 documentLoader()->timing()->setResponseEnd(finishTime ? finishTime : (m_timeOfLastDataReceived ? m_timeOfLastDataReceived : monotonicallyIncreasingTime())); 518 532 documentLoader()->finishedLoading(); 519 ResourceLoader::didFinishLoading(finishTime);520 533 521 534 dl->applicationCacheHost()->finishedLoadingMainResource(); 522 535 } 523 536 524 void MainResourceLoader::didFail(const ResourceError& error) 525 { 537 void MainResourceLoader::notifyFinished(CachedResource* resource) 538 { 539 ASSERT_UNUSED(resource, m_resource == resource); 540 if (!m_resource || (!m_resource->errorOccurred() && !m_resource->wasCanceled())) { 541 didFinishLoading(m_resource->loadFinishTime()); 542 return; 543 } 544 526 545 #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 527 546 if (m_filter) { … … 531 550 #endif 532 551 552 const ResourceError& error = m_resource->resourceError(); 533 553 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainError(request(), error)) 534 554 return; … … 546 566 { 547 567 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); 548 ResourceLoader::reportMemoryUsage(memoryObjectInfo);549 568 info.addMember(m_initialRequest); 550 569 info.addMember(m_substituteData); … … 565 584 566 585 ResourceResponse response(url, m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding(), ""); 567 didReceiveResponse(response);586 responseReceived(0, response); 568 587 } 569 588 … … 588 607 } 589 608 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 609 void MainResourceLoader::load(const ResourceRequest& initialRequest, const SubstituteData& substituteData) 610 { 613 611 // It appears that it is possible for this load to be cancelled and derefenced by the DocumentLoader 614 612 // in willSendRequest() if loadNow() is called. … … 620 618 ASSERT(!documentLoader()->timing()->fetchStart()); 621 619 documentLoader()->timing()->markFetchStart(); 622 ResourceRequest request( r);620 ResourceRequest request(initialRequest); 623 621 624 622 // Send this synthetic delegate callback since clients expect it, and … … 628 626 ASSERT(!deletionHasBegun()); 629 627 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 } 628 // willSendRequest() may lead to our DocumentLoader being detached or cancelling the load via nulling the ResourceRequest. 629 if (!documentLoader()->frame() || request.isNull()) 630 return; 637 631 638 632 documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData); 639 633 640 if (defersLoading()) 641 m_initialRequest = request; 642 else 643 loadNow(request); 634 if (m_substituteData.isValid()) { 635 handleSubstituteDataLoadSoon(request); 636 return; 637 } 638 639 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 640 (SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck)); 641 CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions); 642 m_resource = documentLoader()->cachedResourceLoader()->requestMainResource(cachedResourceRequest); 643 if (!m_resource) { 644 documentLoader()->setRequest(ResourceRequest()); 645 return; 646 } 647 m_resource->addClient(this); 648 649 // We need to wait until after requestMainResource() is called to setRequest(), because there are a bunch of headers set when 650 // the underlying ResourceLoader is created, and DocumentLoader::m_request needs to include those. However, the cache will 651 // strip the fragment identifier (which DocumentLoader::m_request should also include), so add that back in. 652 if (loader()) 653 request = loader()->originalRequest(); 654 if (initialRequest.url() != request.url()) { 655 ASSERT(equalIgnoringFragmentIdentifier(initialRequest.url(), request.url())); 656 request.setURL(initialRequest.url()); 657 } 658 documentLoader()->setRequest(request); 644 659 } 645 660 646 661 void MainResourceLoader::setDefersLoading(bool defers) 647 662 { 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 } 663 if (loader()) 664 loader()->setDefersLoading(defers); 665 } 666 667 bool MainResourceLoader::defersLoading() const 668 { 669 return loader() ? loader()->defersLoading() : false; 670 } 671 672 void MainResourceLoader::setShouldBufferData(DataBufferingPolicy shouldBufferData) 673 { 674 ASSERT(m_resource); 675 m_resource->setShouldBufferData(shouldBufferData); 676 } 677 678 ResourceLoader* MainResourceLoader::loader() const 679 { 680 return m_resource ? m_resource->loader() : 0; 681 } 682 683 unsigned long MainResourceLoader::identifier() const 684 { 685 if (ResourceLoader* resourceLoader = loader()) 686 return resourceLoader->identifier(); 687 return 0; 688 } 689 690 } -
trunk/Source/WebCore/loader/MainResourceLoader.h
r136412 r137333 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
r136998 r137333 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
r136998 r137333 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
r130612 r137333 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
r132520 r137333 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
r137318 r137333 707 707 708 708 #if ENABLE(RESOURCE_TIMING) 709 if (resource) { 709 // FIXME: Add resource timing support for main resources. 710 if (resource && resource->type() != CachedResource::MainResource) { 710 711 HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initiatorMap.find(resource); 711 712 if (initiatorIt != m_initiatorMap.end()) { -
trunk/Source/WebCore/loader/mac/DocumentLoaderMac.cpp
r95901 r137333 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.