diff options
author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
tree | f478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/loader | |
parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/loader')
21 files changed, 229 insertions, 240 deletions
diff --git a/Source/WebCore/loader/CrossOriginAccessControl.h b/Source/WebCore/loader/CrossOriginAccessControl.h index c44963b..50c231e 100644 --- a/Source/WebCore/loader/CrossOriginAccessControl.h +++ b/Source/WebCore/loader/CrossOriginAccessControl.h @@ -24,6 +24,9 @@ * */ +#ifndef CrossOriginAccessControl_h +#define CrossOriginAccessControl_h + #include <wtf/Forward.h> namespace WebCore { @@ -40,3 +43,5 @@ namespace WebCore { bool passesAccessControlCheck(const ResourceResponse&, bool includeCredentials, SecurityOrigin*, String& errorDescription); } // namespace WebCore + +#endif // CrossOriginAccessControl_h diff --git a/Source/WebCore/loader/DocumentLoader.h b/Source/WebCore/loader/DocumentLoader.h index 2328160..241102d 100644 --- a/Source/WebCore/loader/DocumentLoader.h +++ b/Source/WebCore/loader/DocumentLoader.h @@ -36,6 +36,9 @@ #include "ResourceResponse.h" #include "SubstituteData.h" #include "Timer.h" +#include <wtf/HashSet.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> namespace WebCore { diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h index a9541b3..e04d22d 100644 --- a/Source/WebCore/loader/EmptyClients.h +++ b/Source/WebCore/loader/EmptyClients.h @@ -461,6 +461,8 @@ public: virtual NSString* userVisibleString(NSURL*) { return 0; } virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<RefPtr<ArchiveResource> >&) { return 0; }; virtual void setInsertionPasteboard(NSPasteboard*) { }; + virtual NSURL* canonicalizeURL(NSURL*) { return 0; } + virtual NSURL* canonicalizeURLString(NSString*) { return 0; } #ifdef BUILDING_ON_TIGER virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; } #endif diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp index d11399c..9c6257b 100644 --- a/Source/WebCore/loader/FrameLoader.cpp +++ b/Source/WebCore/loader/FrameLoader.cpp @@ -72,6 +72,7 @@ #include "IconDatabase.h" #include "IconLoader.h" #include "InspectorController.h" +#include "InspectorInstrumentation.h" #include "Logging.h" #include "MIMETypeRegistry.h" #include "MainResourceLoader.h" @@ -974,9 +975,16 @@ void FrameLoader::loadArchive(PassRefPtr<Archive> prpArchive) ObjectContentType FrameLoader::defaultObjectContentType(const KURL& url, const String& mimeTypeIn) { String mimeType = mimeTypeIn; + String extension = url.path().substring(url.path().reverseFind('.') + 1); + // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure if (mimeType.isEmpty()) - mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); + mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); + +#if !PLATFORM(MAC) && !PLATFORM(CHROMIUM) && !PLATFORM(EFL) // Mac has no PluginDatabase, nor does Chromium or EFL + if (mimeType.isEmpty()) + mimeType = PluginDatabase::installedPlugins()->MIMETypeForExtension(extension); +#endif if (mimeType.isEmpty()) return ObjectContentFrame; // Go ahead and hope that we can display the content. @@ -2358,8 +2366,9 @@ void FrameLoader::checkLoadCompleteForThisFrame() // Check all children first. RefPtr<HistoryItem> item; if (Page* page = m_frame->page()) - if (isBackForwardLoadType(loadType()) && m_frame == page->mainFrame()) - item = history()->currentItem(); + if (isBackForwardLoadType(loadType())) + // Reset the back forward list to the last committed history item at the top level. + item = page->mainFrame()->loader()->history()->currentItem(); bool shouldReset = true; if (!(pdl->isLoadingInAPISense() && !pdl->isStopping())) { @@ -2602,10 +2611,7 @@ void FrameLoader::detachFromParent() // handlers might start a new subresource load in this frame. stopAllLoaders(); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->frameDetachedFromParent(m_frame); -#endif + InspectorInstrumentation::frameDetachedFromParent(m_frame); detachViewsAndDocumentLoader(); @@ -3071,9 +3077,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource) return; if (!page->areMemoryCacheClientCallsEnabled()) { -#if ENABLE(INSPECTOR) - page->inspectorController()->didLoadResourceFromMemoryCache(m_documentLoader.get(), resource); -#endif + InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource); m_documentLoader->recordMemoryCacheLoadForFutureClientNotification(resource->url()); m_documentLoader->didTellClientAboutLoad(resource->url()); return; @@ -3081,9 +3085,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource) ResourceRequest request(resource->url()); if (m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, resource->response(), resource->encodedSize())) { -#if ENABLE(INSPECTOR) - page->inspectorController()->didLoadResourceFromMemoryCache(m_documentLoader.get(), resource); -#endif + InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource); m_documentLoader->didTellClientAboutLoad(resource->url()); return; } @@ -3091,9 +3093,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource) unsigned long identifier; ResourceError error; requestFromDelegate(request, identifier, error); -#if ENABLE(INSPECTOR) - page->inspectorController()->markResourceAsCached(identifier); -#endif + InspectorInstrumentation::markResourceAsCached(page, identifier); notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, resource->response(), resource->encodedSize(), error); } @@ -3399,15 +3399,7 @@ void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) m_client->dispatchDidClearWindowObjectInWorld(world); -#if ENABLE(INSPECTOR) - if (world != mainThreadNormalWorld()) - return; - - if (Page* page = m_frame->page()) { - if (InspectorController* inspector = page->inspectorController()) - inspector->inspectedWindowScriptObjectCleared(m_frame); - } -#endif + InspectorInstrumentation::didClearWindowObjectInWorld(m_frame, world); } void FrameLoader::updateSandboxFlags() @@ -3454,10 +3446,7 @@ void FrameLoader::dispatchDidCommitLoad() m_client->dispatchDidCommitLoad(); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didCommitLoad(m_documentLoader.get()); -#endif + InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); } void FrameLoader::tellClientAboutPastMemoryCacheLoads() @@ -3473,7 +3462,7 @@ void FrameLoader::tellClientAboutPastMemoryCacheLoads() size_t size = pastLoads.size(); for (size_t i = 0; i < size; ++i) { - CachedResource* resource = cache()->resourceForURL(KURL(ParsedURLString, pastLoads[i])); + CachedResource* resource = memoryCache()->resourceForURL(KURL(ParsedURLString, pastLoads[i])); // FIXME: These loads, loaded from cache, but now gone from the cache by the time // Page::setMemoryCacheClientCallsEnabled(true) is called, will not be seen by the client. @@ -3504,8 +3493,6 @@ Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadReque if (!request.frameName().isEmpty() && request.frameName() != "_blank") { Frame* frame = lookupFrame->tree()->find(request.frameName()); if (frame && openerFrame->loader()->shouldAllowNavigation(frame)) { - if (!request.resourceRequest().url().isEmpty()) - frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer); if (Page* page = frame->page()) page->chrome()->focus(); created = false; diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h index 95755d6..0cc1fa7 100644 --- a/Source/WebCore/loader/FrameLoader.h +++ b/Source/WebCore/loader/FrameLoader.h @@ -36,15 +36,13 @@ #include "FrameLoaderStateMachine.h" #include "FrameLoaderTypes.h" #include "HistoryController.h" -#include "NavigationScheduler.h" -#include "PolicyCallback.h" #include "PolicyChecker.h" #include "ResourceLoadNotifier.h" -#include "ResourceRequest.h" #include "SubframeLoader.h" #include "ThreadableLoader.h" #include "Timer.h" #include <wtf/Forward.h> +#include <wtf/HashSet.h> namespace WebCore { @@ -75,6 +73,7 @@ class Page; class ProtectionSpace; class ResourceError; class ResourceLoader; +class ResourceRequest; class ResourceResponse; class ScriptSourceCode; class ScriptValue; diff --git a/Source/WebCore/loader/HistoryController.cpp b/Source/WebCore/loader/HistoryController.cpp index ff733a9..dda4e56 100644 --- a/Source/WebCore/loader/HistoryController.cpp +++ b/Source/WebCore/loader/HistoryController.cpp @@ -80,6 +80,8 @@ void HistoryController::saveScrollPositionAndViewStateToItem(HistoryItem* item) return; item->setScrollPoint(m_frame->view()->scrollPosition()); + item->setPageScaleFactor(m_frame->pageScaleFactor()); + // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client. m_frame->loader()->client()->saveViewStateToItem(item); } @@ -114,9 +116,12 @@ void HistoryController::restoreScrollPositionAndViewState() // through to the client. It's currently used only for the PDF view on Mac. m_frame->loader()->client()->restoreViewState(); - if (FrameView* view = m_frame->view()) - if (!view->wasScrolledByUser()) + if (FrameView* view = m_frame->view()) { + if (!view->wasScrolledByUser()) { view->setScrollPosition(m_currentItem->scrollPoint()); + m_frame->scalePage(m_currentItem->pageScaleFactor(), m_currentItem->scrollPoint()); + } + } } void HistoryController::updateBackForwardListForFragmentScroll() @@ -235,6 +240,13 @@ void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type) page->backForward()->setCurrentItem(targetItem); Settings* settings = m_frame->settings(); page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem); + + // First set the provisional item of any frames that are not actually navigating. + // This must be done before trying to navigate the desired frame, because some + // navigations can commit immediately (such as about:blank). We must be sure that + // all frames have provisional items set before the commit. + recursiveSetProvisionalItem(targetItem, currentItem, type); + // Now that all other frames have provisional items, do the actual navigation. recursiveGoToItem(targetItem, currentItem, type); } @@ -399,9 +411,50 @@ void HistoryController::updateForCommit() ASSERT(m_provisionalItem); m_currentItem = m_provisionalItem; m_provisionalItem = 0; + + // Tell all other frames in the tree to commit their provisional items and + // restore their scroll position. We'll avoid this frame (which has already + // committed) and its children (which will be replaced). + Page* page = m_frame->page(); + ASSERT(page); + page->mainFrame()->loader()->history()->recursiveUpdateForCommit(); } } +void HistoryController::recursiveUpdateForCommit() +{ + // The frame that navigated will now have a null provisional item. + // Ignore it and its children. + if (!m_provisionalItem) + return; + + // For each frame that already had the content the item requested (based on + // (a matching URL and frame tree snapshot), just restore the scroll position. + // Save form state (works from currentItem, since m_frameLoadComplete is true) + ASSERT(m_frameLoadComplete); + saveDocumentState(); + saveScrollPositionAndViewStateToItem(m_currentItem.get()); + + if (FrameView* view = m_frame->view()) + view->setWasScrolledByUser(false); + + // Now commit the provisional item + m_frameLoadComplete = false; + m_previousItem = m_currentItem; + m_currentItem = m_provisionalItem; + m_provisionalItem = 0; + + // Restore form state (works from currentItem) + restoreDocumentState(); + + // Restore the scroll position (we choose to do this rather than going back to the anchor point) + restoreScrollPositionAndViewState(); + + // Iterate over the rest of the tree + for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) + child->loader()->history()->recursiveUpdateForCommit(); +} + void HistoryController::updateForSameDocumentNavigation() { if (m_frame->loader()->url().isEmpty()) @@ -551,44 +604,42 @@ PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bo // The general idea here is to traverse the frame tree and the item tree in parallel, // tracking whether each frame already has the content the item requests. If there is -// a match (by URL), we just restore scroll position and recurse. Otherwise we must -// reload that frame, and all its kids. -void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type) +// a match, we set the provisional item and recurse. Otherwise we will reload that +// frame and all its kids in recursiveGoToItem. +void HistoryController::recursiveSetProvisionalItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type) { ASSERT(item); ASSERT(fromItem); - // If the item we're going to is a clone of the item we're at, then do - // not load it again, and continue history traversal to its children. - // The current frame tree and the frame tree snapshot in the item have - // to match. - // Note: If item and fromItem are the same, then we need to create a new - // document. - if (item != fromItem - && item->itemSequenceNumber() == fromItem->itemSequenceNumber() - && currentFramesMatchItem(item) - && fromItem->hasSameFrames(item)) - { - // This content is good, so leave it alone and look for children that need reloading - // Save form state (works from currentItem, since m_frameLoadComplete is true) - ASSERT(m_frameLoadComplete); - saveDocumentState(); - saveScrollPositionAndViewStateToItem(m_currentItem.get()); + if (itemsAreClones(item, fromItem)) { + // Set provisional item, which will be committed in recursiveUpdateForCommit. + m_provisionalItem = item; - if (FrameView* view = m_frame->view()) - view->setWasScrolledByUser(false); + const HistoryItemVector& childItems = item->children(); - m_previousItem = m_currentItem; - m_currentItem = item; - - // Restore form state (works from currentItem) - restoreDocumentState(); - - // Restore the scroll position (we choose to do this rather than going back to the anchor point) - restoreScrollPositionAndViewState(); - + int size = childItems.size(); + for (int i = 0; i < size; ++i) { + String childFrameName = childItems[i]->target(); + HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFrameName); + ASSERT(fromChildItem); + Frame* childFrame = m_frame->tree()->child(childFrameName); + ASSERT(childFrame); + childFrame->loader()->history()->recursiveSetProvisionalItem(childItems[i].get(), fromChildItem, type); + } + } +} + +// We now traverse the frame tree and item tree a second time, loading frames that +// do have the content the item requests. +void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type) +{ + ASSERT(item); + ASSERT(fromItem); + + if (itemsAreClones(item, fromItem)) { + // Just iterate over the rest, looking for frames to navigate. const HistoryItemVector& childItems = item->children(); - + int size = childItems.size(); for (int i = 0; i < size; ++i) { String childFrameName = childItems[i]->target(); @@ -603,6 +654,21 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt } } +bool HistoryController::itemsAreClones(HistoryItem* item1, HistoryItem* item2) const +{ + // If the item we're going to is a clone of the item we're at, then we do + // not need to load it again. The current frame tree and the frame tree + // snapshot in the item have to match. + // Note: Some clients treat a navigation to the current history item as + // a reload. Thus, if item1 and item2 are the same, we need to create a + // new document and should not consider them clones. + // (See http://webkit.org/b/35532 for details.) + return item1 != item2 + && item1->itemSequenceNumber() == item2->itemSequenceNumber() + && currentFramesMatchItem(item1) + && item2->hasSameFrames(item1); +} + // Helper method that determines whether the current frame tree matches given history item's. bool HistoryController::currentFramesMatchItem(HistoryItem* item) const { diff --git a/Source/WebCore/loader/HistoryController.h b/Source/WebCore/loader/HistoryController.h index 1bf5072..9923179 100644 --- a/Source/WebCore/loader/HistoryController.h +++ b/Source/WebCore/loader/HistoryController.h @@ -87,7 +87,10 @@ private: PassRefPtr<HistoryItem> createItem(bool useOriginal); PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget); + void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*, FrameLoadType); void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType); + void recursiveUpdateForCommit(); + bool itemsAreClones(HistoryItem*, HistoryItem*) const; bool currentFramesMatchItem(HistoryItem*) const; void updateBackForwardListClippedAtTarget(bool doClip); diff --git a/Source/WebCore/loader/NetscapePlugInStreamLoader.h b/Source/WebCore/loader/NetscapePlugInStreamLoader.h index 4d7d03b..8db555e 100644 --- a/Source/WebCore/loader/NetscapePlugInStreamLoader.h +++ b/Source/WebCore/loader/NetscapePlugInStreamLoader.h @@ -26,6 +26,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef NetscapePlugInStreamLoader_h +#define NetscapePlugInStreamLoader_h + #include "ResourceLoader.h" #include <wtf/Forward.h> @@ -68,3 +71,5 @@ namespace WebCore { }; } + +#endif // NetscapePlugInStreamLoader_h diff --git a/Source/WebCore/loader/ResourceLoadNotifier.cpp b/Source/WebCore/loader/ResourceLoadNotifier.cpp index d002ef3..c928557 100644 --- a/Source/WebCore/loader/ResourceLoadNotifier.cpp +++ b/Source/WebCore/loader/ResourceLoadNotifier.cpp @@ -35,7 +35,7 @@ #include "Frame.h" #include "FrameLoader.h" #include "FrameLoaderClient.h" -#include "InspectorController.h" +#include "InspectorInstrumentation.h" #include "Page.h" #include "ProgressTracker.h" #include "ResourceLoader.h" @@ -97,20 +97,14 @@ void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceE if (!error.isNull()) m_frame->loader()->client()->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didFailLoading(loader->identifier(), error); -#endif + InspectorInstrumentation::didFailLoading(m_frame, loader->identifier(), error); } void ResourceLoadNotifier::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) { m_frame->loader()->client()->assignIdentifierToInitialRequest(identifier, loader, request); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->identifierForInitialRequest(identifier, loader, request); -#endif + InspectorInstrumentation::identifierForInitialRequest(m_frame, identifier, loader, request); } void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) @@ -124,40 +118,32 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig if (!request.isNull() && oldRequestURL != request.url().string().impl()) m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url()); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->willSendRequest(identifier, request, redirectResponse); -#endif + InspectorInstrumentation::willSendRequest(m_frame, identifier, request, redirectResponse); + + // Report WebTiming for all frames. + if (loader && !request.isNull() && request.url() == loader->requestURL()) + request.setReportLoadTiming(true); } void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r) { + InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame, identifier, r); m_frame->loader()->client()->dispatchDidReceiveResponse(loader, identifier, r); - -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didReceiveResponse(identifier, loader, r); -#endif + InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r); } void ResourceLoadNotifier::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length) { m_frame->loader()->client()->dispatchDidReceiveContentLength(loader, identifier, length); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didReceiveContentLength(identifier, length); -#endif + InspectorInstrumentation::didReceiveContentLength(m_frame, identifier, length); } void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier, double finishTime) { m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier); -#if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didFinishLoading(identifier, finishTime); -#endif + InspectorInstrumentation::didFinishLoading(m_frame, identifier, finishTime); } void ResourceLoadNotifier::dispatchTransferLoadingResourceFromPage(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, Page* oldPage) diff --git a/Source/WebCore/loader/ResourceLoader.cpp b/Source/WebCore/loader/ResourceLoader.cpp index bc56000..85216fb 100644 --- a/Source/WebCore/loader/ResourceLoader.cpp +++ b/Source/WebCore/loader/ResourceLoader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. * (C) 2007 Graham Dennis (graham.dennis@gmail.com) * * Redistribution and use in source and binary forms, with or without @@ -129,14 +129,13 @@ bool ResourceLoader::init(const ResourceRequest& r) clientRequest.setFirstPartyForCookies(document->firstPartyForCookies()); } - m_request = clientRequest; - - willSendRequest(m_request, ResourceResponse()); - if (m_request.isNull()) { + willSendRequest(clientRequest, ResourceResponse()); + if (clientRequest.isNull()) { didFail(frameLoader()->cancelledError(m_request)); return false; } + m_request = clientRequest; return true; } @@ -431,9 +430,7 @@ void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(this, response)) return; #endif - InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame.get(), identifier(), response); didReceiveResponse(response); - InspectorInstrumentation::didReceiveResourceResponse(cookie); } void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int lengthReceived) diff --git a/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp b/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp index 6454b90..514ef19 100644 --- a/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp +++ b/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp @@ -40,6 +40,7 @@ #include "Frame.h" #include "FrameLoader.h" #include "FrameLoaderClient.h" +#include "InspectorInstrumentation.h" #include "MainResourceLoader.h" #include "ManifestParser.h" #include "Page.h" @@ -48,11 +49,7 @@ #include <wtf/HashMap.h> #if ENABLE(INSPECTOR) -#include "InspectorApplicationCacheAgent.h" -#include "InspectorController.h" #include "ProgressTracker.h" -#else -#include <wtf/UnusedParam.h> #endif namespace WebCore { @@ -395,30 +392,13 @@ void ApplicationCacheGroup::stopLoadingInFrame(Frame* frame) stopLoading(); } -#if ENABLE(INSPECTOR) -static void inspectorUpdateApplicationCacheStatus(Frame* frame) -{ - if (!frame) - return; - - if (Page *page = frame->page()) { - if (InspectorApplicationCacheAgent* applicationCacheAgent = page->inspectorController()->applicationCacheAgent()) { - ApplicationCacheHost::Status status = frame->loader()->documentLoader()->applicationCacheHost()->status(); - applicationCacheAgent->updateApplicationCacheStatus(status); - } - } -} -#endif - void ApplicationCacheGroup::setNewestCache(PassRefPtr<ApplicationCache> newestCache) { m_newestCache = newestCache; m_caches.add(m_newestCache.get()); m_newestCache->setGroup(this); -#if ENABLE(INSPECTOR) - inspectorUpdateApplicationCacheStatus(m_frame); -#endif + InspectorInstrumentation::updateApplicationCacheStatus(m_frame); } void ApplicationCacheGroup::makeObsolete() @@ -429,9 +409,7 @@ void ApplicationCacheGroup::makeObsolete() m_isObsolete = true; cacheStorage().cacheGroupMadeObsolete(this); ASSERT(!m_storageID); -#if ENABLE(INSPECTOR) - inspectorUpdateApplicationCacheStatus(m_frame); -#endif + InspectorInstrumentation::updateApplicationCacheStatus(m_frame); } void ApplicationCacheGroup::update(Frame* frame, ApplicationCacheUpdateOption updateOption) @@ -496,35 +474,19 @@ PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const KUR // Because willSendRequest only gets called during redirects, we initialize // the identifier and the first willSendRequest here. m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdentifier(); - if (Page* page = m_frame->page()) { - InspectorController* inspectorController = page->inspectorController(); - inspectorController->identifierForInitialRequest(m_currentResourceIdentifier, m_frame->loader()->documentLoader(), handle->firstRequest()); - ResourceResponse redirectResponse = ResourceResponse(); - inspectorController->willSendRequest(m_currentResourceIdentifier, request, redirectResponse); - } + InspectorInstrumentation::identifierForInitialRequest(m_frame, m_currentResourceIdentifier, m_frame->loader()->documentLoader(), handle->firstRequest()); + ResourceResponse redirectResponse = ResourceResponse(); + InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifier, request, redirectResponse); #endif return handle; } -#if ENABLE(INSPECTOR) -void ApplicationCacheGroup::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse) -{ - // This only gets called by ResourceHandleMac if there is a redirect. - if (Page* page = m_frame->page()) - page->inspectorController()->willSendRequest(m_currentResourceIdentifier, request, redirectResponse); -} -#endif - void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response) { #if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) { - if (handle == m_manifestHandle) { - if (InspectorApplicationCacheAgent* applicationCacheAgent = page->inspectorController()->applicationCacheAgent()) - applicationCacheAgent->didReceiveManifestResponse(m_currentResourceIdentifier, response); - } else - page->inspectorController()->didReceiveResponse(m_currentResourceIdentifier, m_frame->loader()->documentLoader(), response); - } + DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader()->documentLoader(); + InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame, m_currentResourceIdentifier, response); + InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResourceIdentifier, loader, response); #endif if (handle == m_manifestHandle) { @@ -594,10 +556,7 @@ void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* data, int length, int lengthReceived) { #if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didReceiveContentLength(m_currentResourceIdentifier, lengthReceived); -#else - UNUSED_PARAM(lengthReceived); + InspectorInstrumentation::didReceiveContentLength(m_frame, m_currentResourceIdentifier, lengthReceived); #endif if (handle == m_manifestHandle) { @@ -616,8 +575,7 @@ void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double finishTime) { #if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didFinishLoading(m_currentResourceIdentifier, finishTime); + InspectorInstrumentation::didFinishLoading(m_frame, m_currentResourceIdentifier, finishTime); #endif if (handle == m_manifestHandle) { @@ -658,10 +616,7 @@ void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double fini void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError& error) { #if ENABLE(INSPECTOR) - if (Page* page = m_frame->page()) - page->inspectorController()->didFailLoading(m_currentResourceIdentifier, error); -#else - UNUSED_PARAM(error); + InspectorInstrumentation::didFailLoading(m_frame, m_currentResourceIdentifier, error); #endif if (handle == m_manifestHandle) { @@ -1161,9 +1116,7 @@ void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID event void ApplicationCacheGroup::setUpdateStatus(UpdateStatus status) { m_updateStatus = status; -#if ENABLE(INSPECTOR) - inspectorUpdateApplicationCacheStatus(m_frame); -#endif + InspectorInstrumentation::updateApplicationCacheStatus(m_frame); } void ApplicationCacheGroup::clearStorageID() diff --git a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h index 29d0749..2d8b83e 100644 --- a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h +++ b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h @@ -110,9 +110,6 @@ private: // the existing client callback cannot be used, so assume that any client that enables application cache also wants it to use credential storage. virtual bool shouldUseCredentialStorage(ResourceHandle*) { return true; } -#if ENABLE(INSPECTOR) - virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&); -#endif virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&); virtual void didReceiveData(ResourceHandle*, const char*, int length, int lengthReceived); virtual void didFinishLoading(ResourceHandle*, double finishTime); diff --git a/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp b/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp index ddd564e..d9575fe 100644 --- a/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp +++ b/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp @@ -529,7 +529,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString continue; } - CachedResource *cachedResource = cache()->resourceForURL(subresourceURL); + CachedResource* cachedResource = memoryCache()->resourceForURL(subresourceURL); if (cachedResource) { resource = ArchiveResource::create(cachedResource->data(), subresourceURL, cachedResource->response()); if (resource) { diff --git a/Source/WebCore/loader/cache/CachedFont.cpp b/Source/WebCore/loader/cache/CachedFont.cpp index d6967bf..fe3281e 100644 --- a/Source/WebCore/loader/cache/CachedFont.cpp +++ b/Source/WebCore/loader/cache/CachedFont.cpp @@ -137,18 +137,13 @@ bool CachedFont::ensureSVGFontData() ASSERT(m_isSVGFont); if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) { m_externalSVGDocument = SVGDocument::create(0, KURL()); - m_externalSVGDocument->open(); RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml"); - m_externalSVGDocument->write(decoder->decode(m_data->data(), m_data->size())); - m_externalSVGDocument->write(decoder->flush()); - if (decoder->sawError()) { - m_externalSVGDocument.clear(); - return 0; - } - - m_externalSVGDocument->finishParsing(); - m_externalSVGDocument->close(); + + m_externalSVGDocument->setContent(decoder->decode(m_data->data(), m_data->size()) + decoder->flush()); + + if (decoder->sawError()) + m_externalSVGDocument = 0; } return m_externalSVGDocument; diff --git a/Source/WebCore/loader/cache/CachedImage.cpp b/Source/WebCore/loader/cache/CachedImage.cpp index c550eec..7d9ce3d 100644 --- a/Source/WebCore/loader/cache/CachedImage.cpp +++ b/Source/WebCore/loader/cache/CachedImage.cpp @@ -111,7 +111,7 @@ void CachedImage::allClientsRemoved() { if (m_image && !errorOccurred()) m_image->resetAnimation(); - if (double interval = cache()->deadDecodedDataDeletionInterval()) + if (double interval = memoryCache()->deadDecodedDataDeletionInterval()) m_decodedDataDeletionTimer.startOneShot(interval); } @@ -284,7 +284,7 @@ void CachedImage::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) if (m_image->isNull() || (maxDecodedImageSize > 0 && estimatedDecodedImageSize > maxDecodedImageSize)) { error(errorOccurred() ? status() : DecodeError); if (inCache()) - cache()->remove(this); + memoryCache()->remove(this); return; } diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp index a9d9b0a..06b3131 100644 --- a/Source/WebCore/loader/cache/CachedResource.cpp +++ b/Source/WebCore/loader/cache/CachedResource.cpp @@ -116,7 +116,7 @@ CachedResource::~CachedResource() ASSERT(canDelete()); ASSERT(!inCache()); ASSERT(!m_deleted); - ASSERT(url().isNull() || cache()->resourceForURL(KURL(ParsedURLString, url())) != this); + ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this); #ifndef NDEBUG m_deleted = true; cachedResourceLeakCounter.decrement(); @@ -259,7 +259,7 @@ void CachedResource::addClientToSet(CachedResourceClient* client) m_preloadResult = PreloadReferenced; } if (!hasClients() && inCache()) - cache()->addToLiveResourcesSize(this); + memoryCache()->addToLiveResourcesSize(this); m_clients.add(client); } @@ -271,8 +271,8 @@ void CachedResource::removeClient(CachedResourceClient* client) if (canDelete() && !inCache()) delete this; else if (!hasClients() && inCache()) { - cache()->removeFromLiveResourcesSize(this); - cache()->removeFromLiveDecodedResourcesList(this); + memoryCache()->removeFromLiveResourcesSize(this); + memoryCache()->removeFromLiveDecodedResourcesList(this); allClientsRemoved(); if (response().cacheControlContainsNoStore()) { // RFC2616 14.9.2: @@ -280,9 +280,9 @@ void CachedResource::removeClient(CachedResourceClient* client) // "... History buffers MAY store such responses as part of their normal operation." // We allow non-secure content to be reused in history, but we do not allow secure content to be reused. if (protocolIs(url(), "https")) - cache()->remove(this); + memoryCache()->remove(this); } else - cache()->prune(); + memoryCache()->prune(); } // This object may be dead here. } @@ -304,13 +304,13 @@ void CachedResource::setDecodedSize(unsigned size) // We have to remove explicitly before updating m_decodedSize, so that we find the correct previous // queue. if (inCache()) - cache()->removeFromLRUList(this); + memoryCache()->removeFromLRUList(this); m_decodedSize = size; if (inCache()) { // Now insert into the new LRU list. - cache()->insertInLRUList(this); + memoryCache()->insertInLRUList(this); // Insert into or remove from the live decoded list if necessary. // When inserting into the LiveDecodedResourcesList it is possible @@ -320,12 +320,12 @@ void CachedResource::setDecodedSize(unsigned size) // by access time. The weakening of the invariant does not pose // a problem. For more details please see: https://bugs.webkit.org/show_bug.cgi?id=30209 if (m_decodedSize && !m_inLiveDecodedResourcesList && hasClients()) - cache()->insertInLiveDecodedResourcesList(this); + memoryCache()->insertInLiveDecodedResourcesList(this); else if (!m_decodedSize && m_inLiveDecodedResourcesList) - cache()->removeFromLiveDecodedResourcesList(this); + memoryCache()->removeFromLiveDecodedResourcesList(this); // Update the cache's size totals. - cache()->adjustSize(hasClients(), delta); + memoryCache()->adjustSize(hasClients(), delta); } } @@ -343,16 +343,16 @@ void CachedResource::setEncodedSize(unsigned size) // We have to remove explicitly before updating m_encodedSize, so that we find the correct previous // queue. if (inCache()) - cache()->removeFromLRUList(this); + memoryCache()->removeFromLRUList(this); m_encodedSize = size; if (inCache()) { // Now insert into the new LRU list. - cache()->insertInLRUList(this); + memoryCache()->insertInLRUList(this); // Update the cache's size totals. - cache()->adjustSize(hasClients(), delta); + memoryCache()->adjustSize(hasClients(), delta); } } @@ -362,10 +362,10 @@ void CachedResource::didAccessDecodedData(double timeStamp) if (inCache()) { if (m_inLiveDecodedResourcesList) { - cache()->removeFromLiveDecodedResourcesList(this); - cache()->insertInLiveDecodedResourcesList(this); + memoryCache()->removeFromLiveDecodedResourcesList(this); + memoryCache()->insertInLiveDecodedResourcesList(this); } - cache()->prune(); + memoryCache()->prune(); } } diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp index 3fcace6..de02758 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp @@ -43,8 +43,10 @@ #include "Logging.h" #include "MemoryCache.h" #include "PingLoader.h" +#include "ResourceLoadScheduler.h" #include "SecurityOrigin.h" #include "Settings.h" +#include <wtf/text/CString.h> #include <wtf/text/StringConcatenate.h> #define PRELOAD_DEBUG 0 @@ -76,8 +78,7 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url } CachedResourceLoader::CachedResourceLoader(Document* document) - : m_cache(cache()) - , m_document(document) + : m_document(document) , m_requestCount(0) #ifdef ANDROID_BLOCK_NETWORK_IMAGE , m_blockNetworkImage(false) @@ -86,7 +87,6 @@ CachedResourceLoader::CachedResourceLoader(Document* document) , m_loadFinishing(false) , m_allowStaleResources(false) { - m_cache->addCachedResourceLoader(this); } CachedResourceLoader::~CachedResourceLoader() @@ -96,7 +96,6 @@ CachedResourceLoader::~CachedResourceLoader() DocumentResourceMap::iterator end = m_documentResources.end(); for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) it->second->setOwningCachedResourceLoader(0); - m_cache->removeCachedResourceLoader(this); // Make sure no requests still point to this CachedResourceLoader ASSERT(m_requestCount == 0); @@ -160,14 +159,14 @@ CachedCSSStyleSheet* CachedResourceLoader::requestUserCSSStyleSheet(const String { KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(KURL(KURL(), requestURL)); - if (CachedResource* existing = cache()->resourceForURL(url)) { + if (CachedResource* existing = memoryCache()->resourceForURL(url)) { if (existing->type() == CachedResource::CSSStyleSheet) return static_cast<CachedCSSStyleSheet*>(existing); - cache()->remove(existing); + memoryCache()->remove(existing); } CachedCSSStyleSheet* userSheet = new CachedCSSStyleSheet(url, charset); - bool inCache = cache()->add(userSheet); + bool inCache = memoryCache()->add(userSheet); if (!inCache) userSheet->setInCache(true); @@ -290,7 +289,7 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, return 0; } - if (cache()->disabled()) { + if (memoryCache()->disabled()) { DocumentResourceMap::iterator it = m_documentResources.find(url.string()); if (it != m_documentResources.end()) { it->second->setOwningCachedResourceLoader(0); @@ -299,21 +298,21 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, } // See if we can use an existing resource from the cache. - CachedResource* resource = cache()->resourceForURL(url); + CachedResource* resource = memoryCache()->resourceForURL(url); switch (determineRevalidationPolicy(type, forPreload, resource)) { case Load: resource = loadResource(type, url, charset, priority); break; case Reload: - cache()->remove(resource); + memoryCache()->remove(resource); resource = loadResource(type, url, charset, priority); break; case Revalidate: resource = revalidateResource(resource, priority); break; case Use: - cache()->resourceAccessed(resource); + memoryCache()->resourceAccessed(resource); notifyLoadedFromMemoryCache(resource); break; } @@ -331,7 +330,7 @@ CachedResource* CachedResourceLoader::revalidateResource(CachedResource* resourc { ASSERT(resource); ASSERT(resource->inCache()); - ASSERT(!cache()->disabled()); + ASSERT(!memoryCache()->disabled()); ASSERT(resource->canUseCacheValidator()); ASSERT(!resource->resourceToRevalidate()); @@ -341,8 +340,8 @@ CachedResource* CachedResourceLoader::revalidateResource(CachedResource* resourc LOG(ResourceLoading, "Resource %p created to revalidate %p", newResource, resource); newResource->setResourceToRevalidate(resource); - cache()->remove(resource); - cache()->add(newResource); + memoryCache()->remove(resource); + memoryCache()->add(newResource); newResource->setLoadPriority(priority); newResource->load(this); @@ -353,13 +352,13 @@ CachedResource* CachedResourceLoader::revalidateResource(CachedResource* resourc CachedResource* CachedResourceLoader::loadResource(CachedResource::Type type, const KURL& url, const String& charset, ResourceLoadPriority priority) { - ASSERT(!cache()->resourceForURL(url)); + ASSERT(!memoryCache()->resourceForURL(url)); LOG(ResourceLoading, "Loading CachedResource for '%s'.", url.string().latin1().data()); CachedResource* resource = createResource(type, url, charset); - bool inCache = cache()->add(resource); + bool inCache = memoryCache()->add(resource); // Pretend the resource is in the cache, to prevent it from being deleted during the load() call. // FIXME: CachedResource should just use normal refcounting instead. @@ -377,7 +376,7 @@ CachedResource* CachedResourceLoader::loadResource(CachedResource::Type type, co // We don't support immediate loads, but we do support immediate failure. if (resource->errorOccurred()) { if (inCache) - cache()->remove(resource); + memoryCache()->remove(resource); else delete resource; return 0; @@ -410,6 +409,16 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida if (existingResource->isPreloaded()) return Use; + // CachePolicyHistoryBuffer uses the cache no matter what. + if (cachePolicy() == CachePolicyHistoryBuffer) + return Use; + + // Don't reuse resources with Cache-control: no-store. + if (existingResource->response().cacheControlContainsNoStore()) { + LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to Cache-control: no-store."); + return Reload; + } + // Avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to. if (m_validatedURLs.contains(existingResource->url())) return Use; @@ -420,10 +429,6 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida return Reload; } - // CachePolicyHistoryBuffer uses the cache no matter what. - if (cachePolicy() == CachePolicyHistoryBuffer) - return Use; - // We'll try to reload the resource if it failed last time. if (existingResource->errorOccurred()) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicye reloading due to resource being in the error state"); @@ -562,6 +567,7 @@ void CachedResourceLoader::loadDone(CachedResourceRequest* request) if (frame()) frame()->loader()->loadDone(); checkForPendingPreloads(); + resourceLoadScheduler()->servePendingRequests(); } void CachedResourceLoader::cancelRequests() @@ -671,7 +677,7 @@ void CachedResourceLoader::clearPreloads() if (res->canDelete() && !res->inCache()) delete res; else if (res->preloadResult() == CachedResource::PreloadNotReferenced) - cache()->remove(res); + memoryCache()->remove(res); } m_preloads.clear(); } @@ -715,7 +721,7 @@ void CachedResourceLoader::printPreloadStats() } if (res->errorOccurred()) - cache()->remove(res); + memoryCache()->remove(res); res->decreasePreloadCount(); } diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h index 1d53976..bc351ce 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.h +++ b/Source/WebCore/loader/cache/CachedResourceLoader.h @@ -50,7 +50,6 @@ class KURL; // The CachedResourceLoader manages the loading of scripts/images/stylesheets for a single document. class CachedResourceLoader : public Noncopyable { -friend class MemoryCache; friend class ImageLoader; public: @@ -124,7 +123,6 @@ private: void notifyLoadedFromMemoryCache(CachedResource*); bool canRequest(CachedResource::Type, const KURL&); - MemoryCache* m_cache; HashSet<String> m_validatedURLs; mutable DocumentResourceMap m_documentResources; Document* m_document; diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.cpp b/Source/WebCore/loader/cache/CachedResourceRequest.cpp index 827bb8e..d5e1adf 100644 --- a/Source/WebCore/loader/cache/CachedResourceRequest.cpp +++ b/Source/WebCore/loader/cache/CachedResourceRequest.cpp @@ -122,7 +122,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad cachedResourceLoader->decrementRequestCount(resource); cachedResourceLoader->loadFinishing(); if (resource->resourceToRevalidate()) - cache()->revalidationFailed(resource); + memoryCache()->revalidationFailed(resource); resource->error(CachedResource::LoadError); cachedResourceLoader->loadDone(0); return 0; @@ -186,7 +186,7 @@ void CachedResourceRequest::didFail(bool cancelled) m_loader->clearClient(); if (m_resource->resourceToRevalidate()) - cache()->revalidationFailed(m_resource); + memoryCache()->revalidationFailed(m_resource); if (!cancelled) { m_cachedResourceLoader->loadFinishing(); @@ -194,7 +194,7 @@ void CachedResourceRequest::didFail(bool cancelled) } if (cancelled || !m_resource->isPreloaded()) - cache()->remove(m_resource); + memoryCache()->remove(m_resource); m_cachedResourceLoader->loadDone(this); } @@ -211,7 +211,7 @@ void CachedResourceRequest::didReceiveResponse(SubresourceLoader* loader, const m_finishing = true; // Existing resource is ok, just use it updating the expiration time. - cache()->revalidationSucceeded(m_resource, response); + memoryCache()->revalidationSucceeded(m_resource, response); if (m_cachedResourceLoader->frame()) m_cachedResourceLoader->frame()->loader()->checkCompleted(); @@ -220,7 +220,7 @@ void CachedResourceRequest::didReceiveResponse(SubresourceLoader* loader, const return; } // Did not get 304 response, continue as a regular resource load. - cache()->revalidationFailed(m_resource); + memoryCache()->revalidationFailed(m_resource); } m_resource->setResponse(response); diff --git a/Source/WebCore/loader/cache/MemoryCache.cpp b/Source/WebCore/loader/cache/MemoryCache.cpp index 930033a..c0927f8 100644 --- a/Source/WebCore/loader/cache/MemoryCache.cpp +++ b/Source/WebCore/loader/cache/MemoryCache.cpp @@ -50,7 +50,7 @@ static const double cMinDelayBeforeLiveDecodedPrune = 1; // Seconds. static const float cTargetPrunePercentage = .95f; // Percentage of capacity toward which we prune, to avoid immediately pruning again. static const double cDefaultDecodedDataDeletionInterval = 0; -MemoryCache* cache() +MemoryCache* memoryCache() { static MemoryCache* staticCache = new MemoryCache; return staticCache; @@ -346,16 +346,6 @@ void MemoryCache::evict(CachedResource* resource) delete resource; } -void MemoryCache::addCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) -{ - m_cachedResourceLoaders.add(cachedResourceLoader); -} - -void MemoryCache::removeCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) -{ - m_cachedResourceLoaders.remove(cachedResourceLoader); -} - static inline unsigned fastLog2(unsigned i) { unsigned log2 = 0; diff --git a/Source/WebCore/loader/cache/MemoryCache.h b/Source/WebCore/loader/cache/MemoryCache.h index dc47733..7a567ea 100644 --- a/Source/WebCore/loader/cache/MemoryCache.h +++ b/Source/WebCore/loader/cache/MemoryCache.h @@ -72,7 +72,7 @@ class KURL; class MemoryCache : public Noncopyable { public: - friend MemoryCache* cache(); + friend MemoryCache* memoryCache(); typedef HashMap<String, CachedResource*> CachedResourceMap; @@ -186,9 +186,6 @@ private: bool makeResourcePurgeable(CachedResource*); void evict(CachedResource*); - // Member variables. - HashSet<CachedResourceLoader*> m_cachedResourceLoaders; - bool m_disabled; // Whether or not the cache is enabled. bool m_pruneEnabled; bool m_inPruneDeadResources; @@ -224,7 +221,7 @@ inline bool MemoryCache::shouldMakeResourcePurgeableOnEviction() } // Function to obtain the global cache. -MemoryCache* cache(); +MemoryCache* memoryCache(); } |