[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
abarth at webkit.org
abarth at webkit.org
Wed Dec 22 15:33:13 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 94d2d9fd6434fe521c5206c3aa208b787e8ec670
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Nov 8 06:46:03 2010 +0000
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* public/WebCache.h:
* src/WebCache.cpp:
(WebKit::ToResourceTypeStat):
(WebKit::WebCache::setCapacities):
(WebKit::WebCache::clear):
(WebKit::WebCache::getUsageStats):
(WebKit::WebCache::getResourceTypeStats):
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* Api/qwebpage.cpp:
* Api/qwebsettings.cpp:
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* webkit/webkitwebview.cpp:
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* WebCache.cpp:
(WebCache::statistics):
* WebFrame.cpp:
* WebView.cpp:
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* WebView.cpp:
(wxWebView::SetCachePolicy):
* WebView.h:
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* Misc/WebCache.mm:
(+[WebCache statistics]):
* WebCoreSupport/WebDeviceOrientationClient.mm:
(WebDeviceOrientationClient::setController):
* WebView/WebView.mm:
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
So sayeth the diagram.
* Android.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSImageValue.cpp:
* dom/ContainerNode.cpp:
* history/PageCache.cpp:
* inspector/InspectorCSSStore.h:
* inspector/InspectorResourceAgent.cpp:
* loader/FrameLoader.cpp:
* loader/archive/cf/LegacyWebArchive.cpp:
* loader/cache/Cache.cpp: Removed.
* loader/cache/Cache.h: Removed.
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::allClientsRemoved):
* loader/cache/CachedFont.cpp:
* loader/cache/CachedFont.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::destroyDecodedData):
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceLoader.cpp:
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::destroyDecodedData):
* loader/cache/MemoryCache.cpp: Copied from WebCore/loader/cache/Cache.cpp.
(WebCore::cache):
(WebCore::MemoryCache::MemoryCache):
(WebCore::MemoryCache::requestResource):
(WebCore::MemoryCache::requestUserCSSStyleSheet):
(WebCore::MemoryCache::revalidateResource):
(WebCore::MemoryCache::revalidationSucceeded):
(WebCore::MemoryCache::revalidationFailed):
(WebCore::MemoryCache::resourceForURL):
(WebCore::MemoryCache::deadCapacity):
(WebCore::MemoryCache::liveCapacity):
(WebCore::MemoryCache::pruneLiveResources):
(WebCore::MemoryCache::pruneDeadResources):
(WebCore::MemoryCache::setCapacities):
(WebCore::MemoryCache::makeResourcePurgeable):
(WebCore::MemoryCache::evict):
(WebCore::MemoryCache::addCachedResourceLoader):
(WebCore::MemoryCache::removeCachedResourceLoader):
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
(WebCore::MemoryCache::insertInLRUList):
(WebCore::MemoryCache::resourceAccessed):
(WebCore::MemoryCache::removeFromLiveDecodedResourcesList):
(WebCore::MemoryCache::insertInLiveDecodedResourcesList):
(WebCore::MemoryCache::addToLiveResourcesSize):
(WebCore::MemoryCache::removeFromLiveResourcesSize):
(WebCore::MemoryCache::adjustSize):
(WebCore::MemoryCache::TypeStatistic::addResource):
(WebCore::MemoryCache::getStatistics):
(WebCore::MemoryCache::setDisabled):
(WebCore::MemoryCache::dumpStats):
(WebCore::MemoryCache::dumpLRULists):
* loader/cache/MemoryCache.h: Copied from WebCore/loader/cache/Cache.h.
(WebCore::MemoryCache::shouldMakeResourcePurgeableOnEviction):
* loader/loader.cpp:
* page/EventSource.cpp:
* page/Settings.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):
2010-11-07 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
Rename Cache to MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=49159
* WebProcess/WebProcess.cpp:
* WebProcess/mac/WebProcessMac.mm:
* WebProcess/win/WebProcessWin.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71499 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 12f36d7..1764e61 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -387,7 +387,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
loader/appcache/DOMApplicationCache.cpp \
loader/appcache/ManifestParser.cpp \
\
- loader/cache/Cache.cpp \
+ loader/cache/MemoryCache.cpp \
\
loader/icon/IconDatabase.cpp \
loader/icon/IconFetcher.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 4ac40f2..10246cd 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1191,7 +1191,7 @@ SET(WebCore_SOURCES
loader/archive/ArchiveResource.cpp
loader/archive/ArchiveResourceCollection.cpp
- loader/cache/Cache.cpp
+ loader/cache/MemoryCache.cpp
loader/icon/IconDatabase.cpp
loader/icon/IconLoader.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 77f2cd7..f321685 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,81 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ So sayeth the diagram.
+
+ * Android.mk:
+ * CMakeLists.txt:
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSImageValue.cpp:
+ * dom/ContainerNode.cpp:
+ * history/PageCache.cpp:
+ * inspector/InspectorCSSStore.h:
+ * inspector/InspectorResourceAgent.cpp:
+ * loader/FrameLoader.cpp:
+ * loader/archive/cf/LegacyWebArchive.cpp:
+ * loader/cache/Cache.cpp: Removed.
+ * loader/cache/Cache.h: Removed.
+ * loader/cache/CachedCSSStyleSheet.cpp:
+ (WebCore::CachedCSSStyleSheet::allClientsRemoved):
+ * loader/cache/CachedFont.cpp:
+ * loader/cache/CachedFont.h:
+ * loader/cache/CachedImage.cpp:
+ (WebCore::CachedImage::destroyDecodedData):
+ * loader/cache/CachedImage.h:
+ * loader/cache/CachedResource.cpp:
+ * loader/cache/CachedResource.h:
+ * loader/cache/CachedResourceLoader.cpp:
+ * loader/cache/CachedResourceLoader.h:
+ * loader/cache/CachedScript.cpp:
+ (WebCore::CachedScript::destroyDecodedData):
+ * loader/cache/MemoryCache.cpp: Copied from WebCore/loader/cache/Cache.cpp.
+ (WebCore::cache):
+ (WebCore::MemoryCache::MemoryCache):
+ (WebCore::MemoryCache::requestResource):
+ (WebCore::MemoryCache::requestUserCSSStyleSheet):
+ (WebCore::MemoryCache::revalidateResource):
+ (WebCore::MemoryCache::revalidationSucceeded):
+ (WebCore::MemoryCache::revalidationFailed):
+ (WebCore::MemoryCache::resourceForURL):
+ (WebCore::MemoryCache::deadCapacity):
+ (WebCore::MemoryCache::liveCapacity):
+ (WebCore::MemoryCache::pruneLiveResources):
+ (WebCore::MemoryCache::pruneDeadResources):
+ (WebCore::MemoryCache::setCapacities):
+ (WebCore::MemoryCache::makeResourcePurgeable):
+ (WebCore::MemoryCache::evict):
+ (WebCore::MemoryCache::addCachedResourceLoader):
+ (WebCore::MemoryCache::removeCachedResourceLoader):
+ (WebCore::MemoryCache::lruListFor):
+ (WebCore::MemoryCache::removeFromLRUList):
+ (WebCore::MemoryCache::insertInLRUList):
+ (WebCore::MemoryCache::resourceAccessed):
+ (WebCore::MemoryCache::removeFromLiveDecodedResourcesList):
+ (WebCore::MemoryCache::insertInLiveDecodedResourcesList):
+ (WebCore::MemoryCache::addToLiveResourcesSize):
+ (WebCore::MemoryCache::removeFromLiveResourcesSize):
+ (WebCore::MemoryCache::adjustSize):
+ (WebCore::MemoryCache::TypeStatistic::addResource):
+ (WebCore::MemoryCache::getStatistics):
+ (WebCore::MemoryCache::setDisabled):
+ (WebCore::MemoryCache::dumpStats):
+ (WebCore::MemoryCache::dumpLRULists):
+ * loader/cache/MemoryCache.h: Copied from WebCore/loader/cache/Cache.h.
+ (WebCore::MemoryCache::shouldMakeResourcePurgeableOnEviction):
+ * loader/loader.cpp:
+ * page/EventSource.cpp:
+ * page/Settings.h:
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::createRequest):
+
2010-11-07 Eric Seidel <eric at webkit.org>
Unreviewed. Attempt to fix the windows build.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index bb3d3d6..ba76c6b 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1906,7 +1906,7 @@ webcore_sources += \
WebCore/loader/archive/ArchiveResourceCollection.h \
WebCore/loader/archive/ArchiveResource.cpp \
WebCore/loader/archive/ArchiveResource.h \
- WebCore/loader/cache/Cache.cpp \
+ WebCore/loader/cache/MemoryCache.cpp \
WebCore/loader/cache/CachedCSSStyleSheet.cpp \
WebCore/loader/cache/CachedCSSStyleSheet.h \
WebCore/loader/cache/CachedFont.cpp \
@@ -1926,7 +1926,7 @@ webcore_sources += \
WebCore/loader/cache/CachedScript.h \
WebCore/loader/cache/CachedXSLStyleSheet.cpp \
WebCore/loader/cache/CachedXSLStyleSheet.h \
- WebCore/loader/cache/Cache.h \
+ WebCore/loader/cache/MemoryCache.h \
WebCore/loader/cache/CachePolicy.h \
WebCore/loader/CachedMetadata.h \
WebCore/loader/CrossOriginAccessControl.cpp \
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 28af5f0..217f328 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -200,6 +200,9 @@ __ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_d
__ZN7WebCore11HistoryItemC1ERKNS_4KURLERKN3WTF6StringES7_S7_
__ZN7WebCore11HistoryItemC1Ev
__ZN7WebCore11HistoryItemD1Ev
+__ZN7WebCore11MemoryCache13getStatisticsEv
+__ZN7WebCore11MemoryCache11setDisabledEb
+__ZN7WebCore11MemoryCache13setCapacitiesEjjj
__ZN7WebCore11RenderLayer19scrollRectToVisibleERKNS_7IntRectEbRKNS_15ScrollAlignmentES6_
__ZN7WebCore11globalPointERK8_NSPointP8NSWindow
__ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow
@@ -629,9 +632,6 @@ __ZN7WebCore4coreEP20NSURLProtectionSpace
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_19CSSStyleDeclarationE
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_5RangeE
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_8NodeListE
-__ZN7WebCore5Cache11setDisabledEb
-__ZN7WebCore5Cache13getStatisticsEv
-__ZN7WebCore5Cache13setCapacitiesEjjj
__ZN7WebCore5Frame10createViewERKNS_7IntSizeERKNS_5ColorEbS3_bNS_13ScrollbarModeEbS7_b
__ZN7WebCore5Frame14frameForWidgetEPKNS_6WidgetE
__ZN7WebCore5Frame17setPageZoomFactorEf
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 7c96378..a8efde6 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2011,8 +2011,8 @@
'loader/archive/ArchiveResource.h',
'loader/archive/ArchiveResourceCollection.cpp',
'loader/archive/ArchiveResourceCollection.h',
- 'loader/cache/Cache.cpp',
- 'loader/cache/Cache.h',
+ 'loader/cache/MemoryCache.cpp',
+ 'loader/cache/MemoryCache.h',
'loader/cache/CachedCSSStyleSheet.cpp',
'loader/cache/CachedCSSStyleSheet.h',
'loader/cache/CachedFont.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index c1dbd19..758bfae 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1032,7 +1032,7 @@ SOURCES += \
loader/archive/ArchiveFactory.cpp \
loader/archive/ArchiveResource.cpp \
loader/archive/ArchiveResourceCollection.cpp \
- loader/cache/Cache.cpp \
+ loader/cache/MemoryCache.cpp \
loader/cache/CachedCSSStyleSheet.cpp \
loader/cache/CachedFont.cpp \
loader/cache/CachedImage.cpp \
@@ -1931,7 +1931,7 @@ HEADERS += \
loader/cache/CachedResourceHandle.h \
loader/cache/CachedScript.h \
loader/cache/CachedXSLStyleSheet.h \
- loader/cache/Cache.h \
+ loader/cache/MemoryCache.h \
loader/CrossOriginAccessControl.h \
loader/CrossOriginPreflightResultCache.h \
loader/cache/CachedResourceLoader.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index e15729f..91d485e 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -24163,11 +24163,11 @@
Name="cache"
>
<File
- RelativePath="..\loader\cache\Cache.cpp"
+ RelativePath="..\loader\cache\MemoryCache.cpp"
>
</File>
<File
- RelativePath="..\loader\cache\Cache.h"
+ RelativePath="..\loader\cache\MemoryCache.h"
>
</File>
<File
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 32fbd12..9e76a64 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5034,8 +5034,8 @@
BCACF3BC1072921A00C0C8A3 /* UserContentURLPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */; };
BCACF3BD1072921A00C0C8A3 /* UserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCAEFCAE1016CE4A0040D34E /* DOMRGBColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCAEFCAD1016CE4A0040D34E /* DOMRGBColor.mm */; };
- BCB16C170979C3BD00467741 /* Cache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16BFE0979C3BD00467741 /* Cache.cpp */; };
- BCB16C180979C3BD00467741 /* Cache.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16BFF0979C3BD00467741 /* Cache.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */; };
+ BCB16C180979C3BD00467741 /* MemoryCache.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16BFF0979C3BD00467741 /* MemoryCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCB16C190979C3BD00467741 /* CachedCSSStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16C000979C3BD00467741 /* CachedCSSStyleSheet.cpp */; };
BCB16C1A0979C3BD00467741 /* CachedCSSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16C010979C3BD00467741 /* CachedCSSStyleSheet.h */; };
BCB16C1B0979C3BD00467741 /* CachedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16C020979C3BD00467741 /* CachedImage.cpp */; };
@@ -11069,8 +11069,8 @@
BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentURLPattern.cpp; sourceTree = "<group>"; };
BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentURLPattern.h; sourceTree = "<group>"; };
BCAEFCAD1016CE4A0040D34E /* DOMRGBColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMRGBColor.mm; sourceTree = "<group>"; };
- BCB16BFE0979C3BD00467741 /* Cache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cache.cpp; sourceTree = "<group>"; };
- BCB16BFF0979C3BD00467741 /* Cache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Cache.h; sourceTree = "<group>"; };
+ BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryCache.cpp; sourceTree = "<group>"; };
+ BCB16BFF0979C3BD00467741 /* MemoryCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MemoryCache.h; sourceTree = "<group>"; };
BCB16C000979C3BD00467741 /* CachedCSSStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedCSSStyleSheet.cpp; sourceTree = "<group>"; };
BCB16C010979C3BD00467741 /* CachedCSSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedCSSStyleSheet.h; sourceTree = "<group>"; };
BCB16C020979C3BD00467741 /* CachedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedImage.cpp; sourceTree = "<group>"; };
@@ -16043,8 +16043,8 @@
BCB16C0E0979C3BD00467741 /* CachedXSLStyleSheet.cpp */,
BCB16C0F0979C3BD00467741 /* CachedXSLStyleSheet.h */,
F587864902DE3A9A01EA4122 /* CachePolicy.h */,
- BCB16BFE0979C3BD00467741 /* Cache.cpp */,
- BCB16BFF0979C3BD00467741 /* Cache.h */,
+ BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */,
+ BCB16BFF0979C3BD00467741 /* MemoryCache.h */,
);
path = cache;
sourceTree = "<group>";
@@ -18564,7 +18564,7 @@
1A569CFA0D7E2B82007C3983 /* c_instance.h in Headers */,
1A569CFC0D7E2B82007C3983 /* c_runtime.h in Headers */,
1A569CFE0D7E2B82007C3983 /* c_utility.h in Headers */,
- BCB16C180979C3BD00467741 /* Cache.h in Headers */,
+ BCB16C180979C3BD00467741 /* MemoryCache.h in Headers */,
BCB16C1A0979C3BD00467741 /* CachedCSSStyleSheet.h in Headers */,
BC64B4CC0CB4295D005F2B62 /* CachedFont.h in Headers */,
51C0AA390F2AA10A001648C2 /* CachedFrame.h in Headers */,
@@ -21714,7 +21714,7 @@
1A569CF90D7E2B82007C3983 /* c_instance.cpp in Sources */,
1A569CFB0D7E2B82007C3983 /* c_runtime.cpp in Sources */,
1A569CFD0D7E2B82007C3983 /* c_utility.cpp in Sources */,
- BCB16C170979C3BD00467741 /* Cache.cpp in Sources */,
+ BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */,
BCB16C190979C3BD00467741 /* CachedCSSStyleSheet.cpp in Sources */,
BC64B4CB0CB4295D005F2B62 /* CachedFont.cpp in Sources */,
51C0AA410F2AA15E001648C2 /* CachedFrame.cpp in Sources */,
diff --git a/WebCore/css/CSSImageValue.cpp b/WebCore/css/CSSImageValue.cpp
index e657fcc..f09a35f 100644
--- a/WebCore/css/CSSImageValue.cpp
+++ b/WebCore/css/CSSImageValue.cpp
@@ -22,7 +22,7 @@
#include "CSSImageValue.h"
#include "CSSValueKeywords.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedImage.h"
#include "CachedResourceLoader.h"
#include "StyleCachedImage.h"
diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp
index fc33519..79d233a 100644
--- a/WebCore/dom/ContainerNode.cpp
+++ b/WebCore/dom/ContainerNode.cpp
@@ -24,7 +24,7 @@
#include "ContainerNode.h"
#include "BeforeLoadEvent.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "ContainerNodeAlgorithms.h"
#include "DeleteButtonController.h"
#include "EventNames.h"
diff --git a/WebCore/history/PageCache.cpp b/WebCore/history/PageCache.cpp
index 41ddb42..7375a9c 100644
--- a/WebCore/history/PageCache.cpp
+++ b/WebCore/history/PageCache.cpp
@@ -28,7 +28,7 @@
#include "ApplicationCacheHost.h"
#include "BackForwardController.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedPage.h"
#include "DOMWindow.h"
#include "DeviceMotionController.h"
diff --git a/WebCore/inspector/InspectorCSSStore.h b/WebCore/inspector/InspectorCSSStore.h
index 25a9d15..0414b58 100644
--- a/WebCore/inspector/InspectorCSSStore.h
+++ b/WebCore/inspector/InspectorCSSStore.h
@@ -30,7 +30,7 @@
#define InspectorCSSStore_h
#include "CSSPropertySourceData.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
diff --git a/WebCore/inspector/InspectorResourceAgent.cpp b/WebCore/inspector/InspectorResourceAgent.cpp
index e121c60..0ed6cba 100644
--- a/WebCore/inspector/InspectorResourceAgent.cpp
+++ b/WebCore/inspector/InspectorResourceAgent.cpp
@@ -32,7 +32,7 @@
#include "InspectorResourceAgent.h"
#include "Base64.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedResource.h"
#include "CachedResourceLoader.h"
#include "Document.h"
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 052a85b..37db9ca 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -38,7 +38,7 @@
#include "ArchiveFactory.h"
#include "BackForwardController.h"
#include "BeforeUnloadEvent.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedPage.h"
#include "CachedResourceLoader.h"
#include "Chrome.h"
diff --git a/WebCore/loader/archive/cf/LegacyWebArchive.cpp b/WebCore/loader/archive/cf/LegacyWebArchive.cpp
index 3efea91..ddd564e 100644
--- a/WebCore/loader/archive/cf/LegacyWebArchive.cpp
+++ b/WebCore/loader/archive/cf/LegacyWebArchive.cpp
@@ -29,7 +29,7 @@
#include "config.h"
#include "LegacyWebArchive.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "Frame.h"
diff --git a/WebCore/loader/cache/Cache.cpp b/WebCore/loader/cache/Cache.cpp
deleted file mode 100644
index 7dc8a32..0000000
--- a/WebCore/loader/cache/Cache.cpp
+++ /dev/null
@@ -1,788 +0,0 @@
-/*
- Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
- Copyright (C) 2001 Dirk Mueller (mueller at kde.org)
- Copyright (C) 2002 Waldo Bastian (bastian at kde.org)
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "Cache.h"
-
-#include "CachedCSSStyleSheet.h"
-#include "CachedFont.h"
-#include "CachedImage.h"
-#include "CachedScript.h"
-#include "CachedXSLStyleSheet.h"
-#include "CachedResourceLoader.h"
-#include "Document.h"
-#include "FrameLoader.h"
-#include "FrameLoaderTypes.h"
-#include "FrameView.h"
-#include "Image.h"
-#include "Logging.h"
-#include "ResourceHandle.h"
-#include "SecurityOrigin.h"
-#include <stdio.h>
-#include <wtf/CurrentTime.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static const int cDefaultCacheCapacity = 8192 * 1024;
-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;
-
-Cache* cache()
-{
- static Cache* staticCache = new Cache;
- return staticCache;
-}
-
-Cache::Cache()
- : m_disabled(false)
- , m_pruneEnabled(true)
- , m_inPruneDeadResources(false)
- , m_capacity(cDefaultCacheCapacity)
- , m_minDeadCapacity(0)
- , m_maxDeadCapacity(cDefaultCacheCapacity)
- , m_deadDecodedDataDeletionInterval(cDefaultDecodedDataDeletionInterval)
- , m_liveSize(0)
- , m_deadSize(0)
-{
-}
-
-static CachedResource* createResource(CachedResource::Type type, const KURL& url, const String& charset)
-{
- switch (type) {
- case CachedResource::ImageResource:
- return new CachedImage(url.string());
- case CachedResource::CSSStyleSheet:
- return new CachedCSSStyleSheet(url.string(), charset);
- case CachedResource::Script:
- return new CachedScript(url.string(), charset);
- case CachedResource::FontResource:
- return new CachedFont(url.string());
-#if ENABLE(XSLT)
- case CachedResource::XSLStyleSheet:
- return new CachedXSLStyleSheet(url.string());
-#endif
-#if ENABLE(LINK_PREFETCH)
- case CachedResource::LinkPrefetch:
- return new CachedResource(url.string(), CachedResource::LinkPrefetch);
-#endif
- default:
- break;
- }
-
- return 0;
-}
-
-CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
-{
- LOG(ResourceLoading, "Cache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload);
-
- // FIXME: Do we really need to special-case an empty URL?
- // Would it be better to just go on with the cache code and let it fail later?
- if (url.isEmpty())
- return 0;
-
- // Look up the resource in our map.
- CachedResource* resource = resourceForURL(url.string());
-
- if (resource && requestIsPreload && !resource->isPreloaded()) {
- LOG(ResourceLoading, "Cache::requestResource already has a preload request for this request, and it hasn't been preloaded yet");
- return 0;
- }
-
- if (!cachedResourceLoader->doc()->securityOrigin()->canDisplay(url)) {
- LOG(ResourceLoading, "...URL was not allowed by SecurityOrigin");
- if (!requestIsPreload)
- FrameLoader::reportLocalLoadFailed(cachedResourceLoader->doc()->frame(), url.string());
- return 0;
- }
-
- if (!resource) {
- LOG(ResourceLoading, "CachedResource for '%s' wasn't found in cache. Creating it", url.string().latin1().data());
- // The resource does not exist. Create it.
- resource = createResource(type, url, charset);
- ASSERT(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.
- resource->setInCache(true);
-
- resource->load(cachedResourceLoader);
-
- if (resource->errorOccurred()) {
- // We don't support immediate loads, but we do support immediate failure.
- // In that case we should to delete the resource now and return 0 because otherwise
- // it would leak if no ref/deref was ever done on it.
- resource->setInCache(false);
- delete resource;
- return 0;
- }
-
- if (!disabled())
- m_resources.set(url.string(), resource); // The size will be added in later once the resource is loaded and calls back to us with the new size.
- else {
- // Kick the resource out of the cache, because the cache is disabled.
- resource->setInCache(false);
- resource->setCachedResourceLoader(cachedResourceLoader);
- }
- }
-
- if (resource->type() != type) {
- LOG(ResourceLoading, "Cache::requestResource cannot use cached resource for '%s' due to type mismatch", url.string().latin1().data());
- return 0;
- }
-
- if (!disabled()) {
- // This will move the resource to the front of its LRU list and increase its access count.
- resourceAccessed(resource);
- }
-
- LOG(ResourceLoading, "Cache::requestResource for '%s' returning resource %p\n", url.string().latin1().data(), resource);
-
- return resource;
-}
-
-CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(CachedResourceLoader* cachedResourceLoader, const String& url, const String& charset)
-{
- CachedCSSStyleSheet* userSheet;
- if (CachedResource* existing = resourceForURL(url)) {
- if (existing->type() != CachedResource::CSSStyleSheet)
- return 0;
- userSheet = static_cast<CachedCSSStyleSheet*>(existing);
- } else {
- userSheet = new CachedCSSStyleSheet(url, charset);
-
- // 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.
- userSheet->setInCache(true);
- // Don't load incrementally, skip load checks, don't send resource load callbacks.
- userSheet->load(cachedResourceLoader, false, SkipSecurityCheck, false);
- if (!disabled())
- m_resources.set(url, userSheet);
- else
- userSheet->setInCache(false);
- }
-
- if (!disabled()) {
- // This will move the resource to the front of its LRU list and increase its access count.
- resourceAccessed(userSheet);
- }
-
- return userSheet;
-}
-
-void Cache::revalidateResource(CachedResource* resource, CachedResourceLoader* cachedResourceLoader)
-{
- ASSERT(resource);
- ASSERT(resource->inCache());
- ASSERT(resource == m_resources.get(resource->url()));
- ASSERT(!disabled());
- if (resource->resourceToRevalidate())
- return;
- if (!resource->canUseCacheValidator()) {
- evict(resource);
- return;
- }
- const String& url = resource->url();
- CachedResource* newResource = createResource(resource->type(), KURL(ParsedURLString, url), resource->encoding());
- LOG(ResourceLoading, "Resource %p created to revalidate %p", newResource, resource);
- newResource->setResourceToRevalidate(resource);
- evict(resource);
- m_resources.set(url, newResource);
- newResource->setInCache(true);
- resourceAccessed(newResource);
- newResource->load(cachedResourceLoader);
-}
-
-void Cache::revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse& response)
-{
- CachedResource* resource = revalidatingResource->resourceToRevalidate();
- ASSERT(resource);
- ASSERT(!resource->inCache());
- ASSERT(resource->isLoaded());
- ASSERT(revalidatingResource->inCache());
-
- evict(revalidatingResource);
-
- ASSERT(!m_resources.get(resource->url()));
- m_resources.set(resource->url(), resource);
- resource->setInCache(true);
- resource->updateResponseAfterRevalidation(response);
- insertInLRUList(resource);
- int delta = resource->size();
- if (resource->decodedSize() && resource->hasClients())
- insertInLiveDecodedResourcesList(resource);
- if (delta)
- adjustSize(resource->hasClients(), delta);
-
- revalidatingResource->switchClientsToRevalidatedResource();
- // this deletes the revalidating resource
- revalidatingResource->clearResourceToRevalidate();
-}
-
-void Cache::revalidationFailed(CachedResource* revalidatingResource)
-{
- LOG(ResourceLoading, "Revalidation failed for %p", revalidatingResource);
- ASSERT(revalidatingResource->resourceToRevalidate());
- revalidatingResource->clearResourceToRevalidate();
-}
-
-CachedResource* Cache::resourceForURL(const String& url)
-{
- CachedResource* resource = m_resources.get(url);
- bool wasPurgeable = Cache::shouldMakeResourcePurgeableOnEviction() && resource && resource->isPurgeable();
- if (resource && !resource->makePurgeable(false)) {
- ASSERT(!resource->hasClients());
- evict(resource);
- return 0;
- }
- // Add the size back since we had subtracted it when we marked the memory as purgeable.
- if (wasPurgeable)
- adjustSize(resource->hasClients(), resource->size());
- return resource;
-}
-
-unsigned Cache::deadCapacity() const
-{
- // Dead resource capacity is whatever space is not occupied by live resources, bounded by an independent minimum and maximum.
- unsigned capacity = m_capacity - min(m_liveSize, m_capacity); // Start with available capacity.
- capacity = max(capacity, m_minDeadCapacity); // Make sure it's above the minimum.
- capacity = min(capacity, m_maxDeadCapacity); // Make sure it's below the maximum.
- return capacity;
-}
-
-unsigned Cache::liveCapacity() const
-{
- // Live resource capacity is whatever is left over after calculating dead resource capacity.
- return m_capacity - deadCapacity();
-}
-
-void Cache::pruneLiveResources()
-{
- if (!m_pruneEnabled)
- return;
-
- unsigned capacity = liveCapacity();
- if (capacity && m_liveSize <= capacity)
- return;
-
- unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again.
- double currentTime = FrameView::currentPaintTimeStamp();
- if (!currentTime) // In case prune is called directly, outside of a Frame paint.
- currentTime = WTF::currentTime();
-
- // Destroy any decoded data in live objects that we can.
- // Start from the tail, since this is the least recently accessed of the objects.
-
- // The list might not be sorted by the m_lastDecodedAccessTime. The impact
- // of this weaker invariant is minor as the below if statement to check the
- // elapsedTime will evaluate to false as the currentTime will be a lot
- // greater than the current->m_lastDecodedAccessTime.
- // For more details see: https://bugs.webkit.org/show_bug.cgi?id=30209
- CachedResource* current = m_liveDecodedResources.m_tail;
- while (current) {
- CachedResource* prev = current->m_prevInLiveResourcesList;
- ASSERT(current->hasClients());
- if (current->isLoaded() && current->decodedSize()) {
- // Check to see if the remaining resources are too new to prune.
- double elapsedTime = currentTime - current->m_lastDecodedAccessTime;
- if (elapsedTime < cMinDelayBeforeLiveDecodedPrune)
- return;
-
- // Destroy our decoded data. This will remove us from
- // m_liveDecodedResources, and possibly move us to a different LRU
- // list in m_allResources.
- current->destroyDecodedData();
-
- if (targetSize && m_liveSize <= targetSize)
- return;
- }
- current = prev;
- }
-}
-
-void Cache::pruneDeadResources()
-{
- if (!m_pruneEnabled)
- return;
-
- unsigned capacity = deadCapacity();
- if (capacity && m_deadSize <= capacity)
- return;
-
- unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again.
- int size = m_allResources.size();
-
- if (!m_inPruneDeadResources) {
- // See if we have any purged resources we can evict.
- for (int i = 0; i < size; i++) {
- CachedResource* current = m_allResources[i].m_tail;
- while (current) {
- CachedResource* prev = current->m_prevInAllResourcesList;
- if (current->wasPurged()) {
- ASSERT(!current->hasClients());
- ASSERT(!current->isPreloaded());
- evict(current);
- }
- current = prev;
- }
- }
- if (targetSize && m_deadSize <= targetSize)
- return;
- }
-
- bool canShrinkLRULists = true;
- m_inPruneDeadResources = true;
- for (int i = size - 1; i >= 0; i--) {
- // Remove from the tail, since this is the least frequently accessed of the objects.
- CachedResource* current = m_allResources[i].m_tail;
-
- // First flush all the decoded data in this queue.
- while (current) {
- CachedResource* prev = current->m_prevInAllResourcesList;
- if (!current->hasClients() && !current->isPreloaded() && current->isLoaded()) {
- // Destroy our decoded data. This will remove us from
- // m_liveDecodedResources, and possibly move us to a different
- // LRU list in m_allResources.
- current->destroyDecodedData();
-
- if (targetSize && m_deadSize <= targetSize) {
- m_inPruneDeadResources = false;
- return;
- }
- }
- current = prev;
- }
-
- // Now evict objects from this queue.
- current = m_allResources[i].m_tail;
- while (current) {
- CachedResource* prev = current->m_prevInAllResourcesList;
- if (!current->hasClients() && !current->isPreloaded() && !current->isCacheValidator()) {
- if (!makeResourcePurgeable(current))
- evict(current);
-
- // If evict() caused pruneDeadResources() to be re-entered, bail out. This can happen when removing an
- // SVG CachedImage that has subresources.
- if (!m_inPruneDeadResources)
- return;
-
- if (targetSize && m_deadSize <= targetSize) {
- m_inPruneDeadResources = false;
- return;
- }
- }
- current = prev;
- }
-
- // Shrink the vector back down so we don't waste time inspecting
- // empty LRU lists on future prunes.
- if (m_allResources[i].m_head)
- canShrinkLRULists = false;
- else if (canShrinkLRULists)
- m_allResources.resize(i);
- }
- m_inPruneDeadResources = false;
-}
-
-void Cache::setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned totalBytes)
-{
- ASSERT(minDeadBytes <= maxDeadBytes);
- ASSERT(maxDeadBytes <= totalBytes);
- m_minDeadCapacity = minDeadBytes;
- m_maxDeadCapacity = maxDeadBytes;
- m_capacity = totalBytes;
- prune();
-}
-
-bool Cache::makeResourcePurgeable(CachedResource* resource)
-{
- if (!Cache::shouldMakeResourcePurgeableOnEviction())
- return false;
-
- if (!resource->inCache())
- return false;
-
- if (resource->isPurgeable())
- return true;
-
- if (!resource->isSafeToMakePurgeable())
- return false;
-
- if (!resource->makePurgeable(true))
- return false;
-
- adjustSize(resource->hasClients(), -static_cast<int>(resource->size()));
-
- return true;
-}
-
-void Cache::evict(CachedResource* resource)
-{
- LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().latin1().data());
- // The resource may have already been removed by someone other than our caller,
- // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
- if (resource->inCache()) {
- // Remove from the resource map.
- m_resources.remove(resource->url());
- resource->setInCache(false);
-
- // Remove from the appropriate LRU list.
- removeFromLRUList(resource);
- removeFromLiveDecodedResourcesList(resource);
-
- // If the resource was purged, it means we had already decremented the size when we made the
- // resource purgeable in makeResourcePurgeable(). So adjust the size if we are evicting a
- // resource that was not marked as purgeable.
- if (!Cache::shouldMakeResourcePurgeableOnEviction() || !resource->isPurgeable())
- adjustSize(resource->hasClients(), -static_cast<int>(resource->size()));
- } else
- ASSERT(m_resources.get(resource->url()) != resource);
-
- if (resource->canDelete())
- delete resource;
-}
-
-void Cache::addCachedResourceLoader(CachedResourceLoader* cachedResourceLoader)
-{
- m_cachedResourceLoaders.add(cachedResourceLoader);
-}
-
-void Cache::removeCachedResourceLoader(CachedResourceLoader* cachedResourceLoader)
-{
- m_cachedResourceLoaders.remove(cachedResourceLoader);
-}
-
-static inline unsigned fastLog2(unsigned i)
-{
- unsigned log2 = 0;
- if (i & (i - 1))
- log2 += 1;
- if (i >> 16)
- log2 += 16, i >>= 16;
- if (i >> 8)
- log2 += 8, i >>= 8;
- if (i >> 4)
- log2 += 4, i >>= 4;
- if (i >> 2)
- log2 += 2, i >>= 2;
- if (i >> 1)
- log2 += 1;
- return log2;
-}
-
-Cache::LRUList* Cache::lruListFor(CachedResource* resource)
-{
- unsigned accessCount = max(resource->accessCount(), 1U);
- unsigned queueIndex = fastLog2(resource->size() / accessCount);
-#ifndef NDEBUG
- resource->m_lruIndex = queueIndex;
-#endif
- if (m_allResources.size() <= queueIndex)
- m_allResources.grow(queueIndex + 1);
- return &m_allResources[queueIndex];
-}
-
-void Cache::removeFromLRUList(CachedResource* resource)
-{
- // If we've never been accessed, then we're brand new and not in any list.
- if (resource->accessCount() == 0)
- return;
-
-#if !ASSERT_DISABLED
- unsigned oldListIndex = resource->m_lruIndex;
-#endif
-
- LRUList* list = lruListFor(resource);
-
-#if !ASSERT_DISABLED
- // Verify that the list we got is the list we want.
- ASSERT(resource->m_lruIndex == oldListIndex);
-
- // Verify that we are in fact in this list.
- bool found = false;
- for (CachedResource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
- if (current == resource) {
- found = true;
- break;
- }
- }
- ASSERT(found);
-#endif
-
- CachedResource* next = resource->m_nextInAllResourcesList;
- CachedResource* prev = resource->m_prevInAllResourcesList;
-
- if (next == 0 && prev == 0 && list->m_head != resource)
- return;
-
- resource->m_nextInAllResourcesList = 0;
- resource->m_prevInAllResourcesList = 0;
-
- if (next)
- next->m_prevInAllResourcesList = prev;
- else if (list->m_tail == resource)
- list->m_tail = prev;
-
- if (prev)
- prev->m_nextInAllResourcesList = next;
- else if (list->m_head == resource)
- list->m_head = next;
-}
-
-void Cache::insertInLRUList(CachedResource* resource)
-{
- // Make sure we aren't in some list already.
- ASSERT(!resource->m_nextInAllResourcesList && !resource->m_prevInAllResourcesList);
- ASSERT(resource->inCache());
- ASSERT(resource->accessCount() > 0);
-
- LRUList* list = lruListFor(resource);
-
- resource->m_nextInAllResourcesList = list->m_head;
- if (list->m_head)
- list->m_head->m_prevInAllResourcesList = resource;
- list->m_head = resource;
-
- if (!resource->m_nextInAllResourcesList)
- list->m_tail = resource;
-
-#ifndef NDEBUG
- // Verify that we are in now in the list like we should be.
- list = lruListFor(resource);
- bool found = false;
- for (CachedResource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
- if (current == resource) {
- found = true;
- break;
- }
- }
- ASSERT(found);
-#endif
-
-}
-
-void Cache::resourceAccessed(CachedResource* resource)
-{
- ASSERT(resource->inCache());
-
- // Need to make sure to remove before we increase the access count, since
- // the queue will possibly change.
- removeFromLRUList(resource);
-
- // If this is the first time the resource has been accessed, adjust the size of the cache to account for its initial size.
- if (!resource->accessCount())
- adjustSize(resource->hasClients(), resource->size());
-
- // Add to our access count.
- resource->increaseAccessCount();
-
- // Now insert into the new queue.
- insertInLRUList(resource);
-}
-
-void Cache::removeFromLiveDecodedResourcesList(CachedResource* resource)
-{
- // If we've never been accessed, then we're brand new and not in any list.
- if (!resource->m_inLiveDecodedResourcesList)
- return;
- resource->m_inLiveDecodedResourcesList = false;
-
-#ifndef NDEBUG
- // Verify that we are in fact in this list.
- bool found = false;
- for (CachedResource* current = m_liveDecodedResources.m_head; current; current = current->m_nextInLiveResourcesList) {
- if (current == resource) {
- found = true;
- break;
- }
- }
- ASSERT(found);
-#endif
-
- CachedResource* next = resource->m_nextInLiveResourcesList;
- CachedResource* prev = resource->m_prevInLiveResourcesList;
-
- if (next == 0 && prev == 0 && m_liveDecodedResources.m_head != resource)
- return;
-
- resource->m_nextInLiveResourcesList = 0;
- resource->m_prevInLiveResourcesList = 0;
-
- if (next)
- next->m_prevInLiveResourcesList = prev;
- else if (m_liveDecodedResources.m_tail == resource)
- m_liveDecodedResources.m_tail = prev;
-
- if (prev)
- prev->m_nextInLiveResourcesList = next;
- else if (m_liveDecodedResources.m_head == resource)
- m_liveDecodedResources.m_head = next;
-}
-
-void Cache::insertInLiveDecodedResourcesList(CachedResource* resource)
-{
- // Make sure we aren't in the list already.
- ASSERT(!resource->m_nextInLiveResourcesList && !resource->m_prevInLiveResourcesList && !resource->m_inLiveDecodedResourcesList);
- resource->m_inLiveDecodedResourcesList = true;
-
- resource->m_nextInLiveResourcesList = m_liveDecodedResources.m_head;
- if (m_liveDecodedResources.m_head)
- m_liveDecodedResources.m_head->m_prevInLiveResourcesList = resource;
- m_liveDecodedResources.m_head = resource;
-
- if (!resource->m_nextInLiveResourcesList)
- m_liveDecodedResources.m_tail = resource;
-
-#ifndef NDEBUG
- // Verify that we are in now in the list like we should be.
- bool found = false;
- for (CachedResource* current = m_liveDecodedResources.m_head; current; current = current->m_nextInLiveResourcesList) {
- if (current == resource) {
- found = true;
- break;
- }
- }
- ASSERT(found);
-#endif
-
-}
-
-void Cache::addToLiveResourcesSize(CachedResource* resource)
-{
- m_liveSize += resource->size();
- m_deadSize -= resource->size();
-}
-
-void Cache::removeFromLiveResourcesSize(CachedResource* resource)
-{
- m_liveSize -= resource->size();
- m_deadSize += resource->size();
-}
-
-void Cache::adjustSize(bool live, int delta)
-{
- if (live) {
- ASSERT(delta >= 0 || ((int)m_liveSize + delta >= 0));
- m_liveSize += delta;
- } else {
- ASSERT(delta >= 0 || ((int)m_deadSize + delta >= 0));
- m_deadSize += delta;
- }
-}
-
-void Cache::TypeStatistic::addResource(CachedResource* o)
-{
- bool purged = o->wasPurged();
- bool purgeable = o->isPurgeable() && !purged;
- int pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095;
- count++;
- size += purged ? 0 : o->size();
- liveSize += o->hasClients() ? o->size() : 0;
- decodedSize += o->decodedSize();
- purgeableSize += purgeable ? pageSize : 0;
- purgedSize += purged ? pageSize : 0;
-}
-
-Cache::Statistics Cache::getStatistics()
-{
- Statistics stats;
- CachedResourceMap::iterator e = m_resources.end();
- for (CachedResourceMap::iterator i = m_resources.begin(); i != e; ++i) {
- CachedResource* resource = i->second;
- switch (resource->type()) {
- case CachedResource::ImageResource:
- stats.images.addResource(resource);
- break;
- case CachedResource::CSSStyleSheet:
- stats.cssStyleSheets.addResource(resource);
- break;
- case CachedResource::Script:
- stats.scripts.addResource(resource);
- break;
-#if ENABLE(XSLT)
- case CachedResource::XSLStyleSheet:
- stats.xslStyleSheets.addResource(resource);
- break;
-#endif
- case CachedResource::FontResource:
- stats.fonts.addResource(resource);
- break;
- default:
- break;
- }
- }
- return stats;
-}
-
-void Cache::setDisabled(bool disabled)
-{
- m_disabled = disabled;
- if (!m_disabled)
- return;
-
- for (;;) {
- CachedResourceMap::iterator i = m_resources.begin();
- if (i == m_resources.end())
- break;
- evict(i->second);
- }
-}
-
-#ifndef NDEBUG
-void Cache::dumpStats()
-{
- Statistics s = getStatistics();
- printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize", "PurgeableSize", "PurgedSize");
- printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------");
- printf("%-13s %13d %13d %13d %13d %13d %13d\n", "Images", s.images.count, s.images.size, s.images.liveSize, s.images.decodedSize, s.images.purgeableSize, s.images.purgedSize);
- printf("%-13s %13d %13d %13d %13d %13d %13d\n", "CSS", s.cssStyleSheets.count, s.cssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize, s.cssStyleSheets.purgeableSize, s.cssStyleSheets.purgedSize);
-#if ENABLE(XSLT)
- printf("%-13s %13d %13d %13d %13d %13d %13d\n", "XSL", s.xslStyleSheets.count, s.xslStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize, s.xslStyleSheets.purgeableSize, s.xslStyleSheets.purgedSize);
-#endif
- printf("%-13s %13d %13d %13d %13d %13d %13d\n", "JavaScript", s.scripts.count, s.scripts.size, s.scripts.liveSize, s.scripts.decodedSize, s.scripts.purgeableSize, s.scripts.purgedSize);
- printf("%-13s %13d %13d %13d %13d %13d %13d\n", "Fonts", s.fonts.count, s.fonts.size, s.fonts.liveSize, s.fonts.decodedSize, s.fonts.purgeableSize, s.fonts.purgedSize);
- printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------");
-}
-
-void Cache::dumpLRULists(bool includeLive) const
-{
- printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced, isPurgeable, wasPurged):\n");
-
- int size = m_allResources.size();
- for (int i = size - 1; i >= 0; i--) {
- printf("\n\nList %d: ", i);
- CachedResource* current = m_allResources[i].m_tail;
- while (current) {
- CachedResource* prev = current->m_prevInAllResourcesList;
- if (includeLive || !current->hasClients())
- printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", current->decodedSize() / 1024.0f, (current->encodedSize() + current->overheadSize()) / 1024.0f, current->accessCount(), current->hasClients(), current->isPurgeable(), current->wasPurged());
-
- current = prev;
- }
- }
-}
-#endif
-
-} // namespace WebCore
diff --git a/WebCore/loader/cache/Cache.h b/WebCore/loader/cache/Cache.h
deleted file mode 100644
index 14ddc21..0000000
--- a/WebCore/loader/cache/Cache.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
- Copyright (C) 2001 Dirk Mueller <mueller at kde.org>
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-
-#ifndef Cache_h
-#define Cache_h
-
-#include "CachePolicy.h"
-#include "CachedResource.h"
-#include "PlatformString.h"
-#include "loader.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-
-namespace WebCore {
-
-class CachedCSSStyleSheet;
-class CachedResource;
-class CachedResourceLoader;
-class KURL;
-
-// This cache holds subresources used by Web pages: images, scripts, stylesheets, etc.
-
-// The cache keeps a flexible but bounded window of dead resources that grows/shrinks
-// depending on the live resource load. Here's an example of cache growth over time,
-// with a min dead resource capacity of 25% and a max dead resource capacity of 50%:
-
-// |-----| Dead: -
-// |----------| Live: +
-// --|----------| Cache boundary: | (objects outside this mark have been evicted)
-// --|----------++++++++++|
-// -------|-----+++++++++++++++|
-// -------|-----+++++++++++++++|+++++
-
-// The behavior of the cache changes in the following way if shouldMakeResourcePurgeableOnEviction
-// returns true.
-//
-// 1. Dead resources in the cache are kept in non-purgeable memory.
-// 2. When we prune dead resources, instead of freeing them, we mark their memory as purgeable and
-// keep the resources until the kernel reclaims the purgeable memory.
-//
-// By leaving the in-cache dead resources in dirty resident memory, we decrease the likelihood of
-// the kernel claiming that memory and forcing us to refetch the resource (for example when a user
-// presses back).
-//
-// And by having an unbounded number of resource objects using purgeable memory, we can use as much
-// memory as is available on the machine. The trade-off here is that the CachedResource object (and
-// its member variables) are allocated in non-purgeable TC-malloc'd memory so we would see slightly
-// more memory use due to this.
-
-class Cache : public Noncopyable {
-public:
- friend Cache* cache();
-
- typedef HashMap<String, CachedResource*> CachedResourceMap;
-
- struct LRUList {
- CachedResource* m_head;
- CachedResource* m_tail;
- LRUList() : m_head(0), m_tail(0) { }
- };
-
- struct TypeStatistic {
- int count;
- int size;
- int liveSize;
- int decodedSize;
- int purgeableSize;
- int purgedSize;
- TypeStatistic() : count(0), size(0), liveSize(0), decodedSize(0), purgeableSize(0), purgedSize(0) { }
- void addResource(CachedResource*);
- };
-
- struct Statistics {
- TypeStatistic images;
- TypeStatistic cssStyleSheets;
- TypeStatistic scripts;
-#if ENABLE(XSLT)
- TypeStatistic xslStyleSheets;
-#endif
- TypeStatistic fonts;
- };
-
- // The loader that fetches resources.
- Loader* loader() { return &m_loader; }
-
- // Request resources from the cache. A load will be initiated and a cache object created if the object is not
- // found in the cache.
- CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
-
- CachedCSSStyleSheet* requestUserCSSStyleSheet(CachedResourceLoader*, const String& url, const String& charset);
-
- void revalidateResource(CachedResource*, CachedResourceLoader*);
- void revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse&);
- void revalidationFailed(CachedResource* revalidatingResource);
-
- // Sets the cache's memory capacities, in bytes. These will hold only approximately,
- // since the decoded cost of resources like scripts and stylesheets is not known.
- // - minDeadBytes: The maximum number of bytes that dead resources should consume when the cache is under pressure.
- // - maxDeadBytes: The maximum number of bytes that dead resources should consume when the cache is not under pressure.
- // - totalBytes: The maximum number of bytes that the cache should consume overall.
- void setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned totalBytes);
-
- // Turn the cache on and off. Disabling the cache will remove all resources from the cache. They may
- // still live on if they are referenced by some Web page though.
- void setDisabled(bool);
- bool disabled() const { return m_disabled; }
-
- void setPruneEnabled(bool enabled) { m_pruneEnabled = enabled; }
- void prune()
- {
- if (m_liveSize + m_deadSize <= m_capacity && m_maxDeadCapacity && m_deadSize <= m_maxDeadCapacity) // Fast path.
- return;
-
- pruneDeadResources(); // Prune dead first, in case it was "borrowing" capacity from live.
- pruneLiveResources();
- }
-
- void setDeadDecodedDataDeletionInterval(double interval) { m_deadDecodedDataDeletionInterval = interval; }
- double deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
-
- // Remove an existing cache entry from both the resource map and from the LRU list.
- void remove(CachedResource* resource) { evict(resource); }
-
- void addCachedResourceLoader(CachedResourceLoader*);
- void removeCachedResourceLoader(CachedResourceLoader*);
-
- CachedResource* resourceForURL(const String&);
-
- // Calls to put the cached resource into and out of LRU lists.
- void insertInLRUList(CachedResource*);
- void removeFromLRUList(CachedResource*);
-
- // Called to adjust the cache totals when a resource changes size.
- void adjustSize(bool live, int delta);
-
- // Track decoded resources that are in the cache and referenced by a Web page.
- void insertInLiveDecodedResourcesList(CachedResource*);
- void removeFromLiveDecodedResourcesList(CachedResource*);
-
- void addToLiveResourcesSize(CachedResource*);
- void removeFromLiveResourcesSize(CachedResource*);
-
- static bool shouldMakeResourcePurgeableOnEviction();
-
- // Function to collect cache statistics for the caches window in the Safari Debug menu.
- Statistics getStatistics();
-
-private:
- Cache();
- ~Cache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
-
- LRUList* lruListFor(CachedResource*);
- void resourceAccessed(CachedResource*);
-#ifndef NDEBUG
- void dumpStats();
- void dumpLRULists(bool includeLive) const;
-#endif
-
- unsigned liveCapacity() const;
- unsigned deadCapacity() const;
-
- void pruneDeadResources(); // Flush decoded and encoded data from resources not referenced by Web pages.
- void pruneLiveResources(); // Flush decoded data from resources still referenced by Web pages.
-
- bool makeResourcePurgeable(CachedResource*);
- void evict(CachedResource*);
-
- // Member variables.
- HashSet<CachedResourceLoader*> m_cachedResourceLoaders;
- Loader m_loader;
-
- bool m_disabled; // Whether or not the cache is enabled.
- bool m_pruneEnabled;
- bool m_inPruneDeadResources;
-
- unsigned m_capacity;
- unsigned m_minDeadCapacity;
- unsigned m_maxDeadCapacity;
- double m_deadDecodedDataDeletionInterval;
-
- unsigned m_liveSize; // The number of bytes currently consumed by "live" resources in the cache.
- unsigned m_deadSize; // The number of bytes currently consumed by "dead" resources in the cache.
-
- // Size-adjusted and popularity-aware LRU list collection for cache objects. This collection can hold
- // more resources than the cached resource map, since it can also hold "stale" multiple versions of objects that are
- // waiting to die when the clients referencing them go away.
- Vector<LRUList, 32> m_allResources;
-
- // List just for live resources with decoded data. Access to this list is based off of painting the resource.
- LRUList m_liveDecodedResources;
-
- // A URL-based map of all resources that are in the cache (including the freshest version of objects that are currently being
- // referenced by a Web page).
- HashMap<String, CachedResource*> m_resources;
-};
-
-inline bool Cache::shouldMakeResourcePurgeableOnEviction()
-{
-#if PLATFORM(IOS)
- return true;
-#else
- return false;
-#endif
-}
-
-// Function to obtain the global cache.
-Cache* cache();
-
-}
-
-#endif
diff --git a/WebCore/loader/cache/CachedCSSStyleSheet.cpp b/WebCore/loader/cache/CachedCSSStyleSheet.cpp
index 877cd1d..f0016d1 100644
--- a/WebCore/loader/cache/CachedCSSStyleSheet.cpp
+++ b/WebCore/loader/cache/CachedCSSStyleSheet.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "CachedCSSStyleSheet.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "HTTPParsers.h"
@@ -59,7 +59,7 @@ void CachedCSSStyleSheet::didAddClient(CachedResourceClient *c)
void CachedCSSStyleSheet::allClientsRemoved()
{
- if (!Cache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
+ if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
makePurgeable(true);
}
diff --git a/WebCore/loader/cache/CachedFont.cpp b/WebCore/loader/cache/CachedFont.cpp
index e8db6c6..6297ad1 100644
--- a/WebCore/loader/cache/CachedFont.cpp
+++ b/WebCore/loader/cache/CachedFont.cpp
@@ -31,7 +31,7 @@
#define STORE_FONT_CUSTOM_PLATFORM_DATA
#endif
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "FontPlatformData.h"
diff --git a/WebCore/loader/cache/CachedFont.h b/WebCore/loader/cache/CachedFont.h
index 8dc8874..e1a34e8 100644
--- a/WebCore/loader/cache/CachedFont.h
+++ b/WebCore/loader/cache/CachedFont.h
@@ -39,7 +39,7 @@
namespace WebCore {
class CachedResourceLoader;
-class Cache;
+class MemoryCache;
class FontPlatformData;
class SVGFontElement;
@@ -81,7 +81,7 @@ private:
RefPtr<SVGDocument> m_externalSVGDocument;
#endif
- friend class Cache;
+ friend class MemoryCache;
};
}
diff --git a/WebCore/loader/cache/CachedImage.cpp b/WebCore/loader/cache/CachedImage.cpp
index 9f6abef..8d1a737 100644
--- a/WebCore/loader/cache/CachedImage.cpp
+++ b/WebCore/loader/cache/CachedImage.cpp
@@ -25,7 +25,7 @@
#include "CachedImage.h"
#include "BitmapImage.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "CachedResourceLoader.h"
@@ -331,7 +331,7 @@ void CachedImage::destroyDecodedData()
// Invoking addClient() will reconstruct the image object.
m_image = 0;
setDecodedSize(0);
- if (!Cache::shouldMakeResourcePurgeableOnEviction())
+ if (!MemoryCache::shouldMakeResourcePurgeableOnEviction())
makePurgeable(true);
} else if (m_image && !errorOccurred())
m_image->destroyDecodedData();
diff --git a/WebCore/loader/cache/CachedImage.h b/WebCore/loader/cache/CachedImage.h
index da8754a..313f3f3 100644
--- a/WebCore/loader/cache/CachedImage.h
+++ b/WebCore/loader/cache/CachedImage.h
@@ -32,10 +32,10 @@
namespace WebCore {
class CachedResourceLoader;
-class Cache;
+class MemoryCache;
class CachedImage : public CachedResource, public ImageObserver {
- friend class Cache;
+ friend class MemoryCache;
public:
CachedImage(const String& url);
diff --git a/WebCore/loader/cache/CachedResource.cpp b/WebCore/loader/cache/CachedResource.cpp
index 009b50a..c440ec9 100644
--- a/WebCore/loader/cache/CachedResource.cpp
+++ b/WebCore/loader/cache/CachedResource.cpp
@@ -24,7 +24,7 @@
#include "config.h"
#include "CachedResource.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedMetadata.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
diff --git a/WebCore/loader/cache/CachedResource.h b/WebCore/loader/cache/CachedResource.h
index f747fc4..ba02459 100644
--- a/WebCore/loader/cache/CachedResource.h
+++ b/WebCore/loader/cache/CachedResource.h
@@ -36,7 +36,7 @@
namespace WebCore {
-class Cache;
+class MemoryCache;
class CachedMetadata;
class CachedResourceClient;
class CachedResourceHandleBase;
@@ -50,7 +50,7 @@ class Request;
// from CachedResourceClient, to get the function calls in case the requested data has arrived.
// This class also does the actual communication with the loader to obtain the resource from the network.
class CachedResource : public Noncopyable {
- friend class Cache;
+ friend class MemoryCache;
friend class InspectorResource;
public:
@@ -225,7 +225,7 @@ protected:
private:
void addClientToSet(CachedResourceClient*);
- // These are called by the friendly Cache only
+ // These are called by the friendly MemoryCache only
void setResourceToRevalidate(CachedResource*);
void switchClientsToRevalidatedResource();
void clearResourceToRevalidate();
diff --git a/WebCore/loader/cache/CachedResourceLoader.cpp b/WebCore/loader/cache/CachedResourceLoader.cpp
index ce9dc2b..c129c3f 100644
--- a/WebCore/loader/cache/CachedResourceLoader.cpp
+++ b/WebCore/loader/cache/CachedResourceLoader.cpp
@@ -27,23 +27,23 @@
#include "config.h"
#include "CachedResourceLoader.h"
-#include "loader.h"
-#include "Cache.h"
#include "CachedCSSStyleSheet.h"
#include "CachedFont.h"
#include "CachedImage.h"
#include "CachedScript.h"
#include "CachedXSLStyleSheet.h"
#include "Console.h"
-#include "Document.h"
#include "DOMWindow.h"
-#include "HTMLElement.h"
+#include "Document.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
+#include "HTMLElement.h"
+#include "MemoryCache.h"
#include "PingLoader.h"
#include "SecurityOrigin.h"
#include "Settings.h"
+#include "loader.h"
#include <wtf/text/StringConcatenate.h>
#define PRELOAD_DEBUG 0
diff --git a/WebCore/loader/cache/CachedResourceLoader.h b/WebCore/loader/cache/CachedResourceLoader.h
index 02e983b..be2f3ae 100644
--- a/WebCore/loader/cache/CachedResourceLoader.h
+++ b/WebCore/loader/cache/CachedResourceLoader.h
@@ -48,7 +48,7 @@ class KURL;
// The CachedResourceLoader manages the loading of scripts/images/stylesheets for a single document.
class CachedResourceLoader : public Noncopyable {
-friend class Cache;
+friend class MemoryCache;
friend class ImageLoader;
public:
@@ -109,7 +109,7 @@ private:
void checkCacheObjectStatus(CachedResource*);
bool canRequest(CachedResource::Type, const KURL&);
- Cache* m_cache;
+ MemoryCache* m_cache;
HashSet<String> m_reloadedURLs;
mutable DocumentResourceMap m_documentResources;
Document* m_doc;
diff --git a/WebCore/loader/cache/CachedScript.cpp b/WebCore/loader/cache/CachedScript.cpp
index 1898438..50a8c17 100644
--- a/WebCore/loader/cache/CachedScript.cpp
+++ b/WebCore/loader/cache/CachedScript.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "CachedScript.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "SharedBuffer.h"
@@ -111,7 +111,7 @@ void CachedScript::destroyDecodedData()
{
m_script = String();
setDecodedSize(0);
- if (!Cache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
+ if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
makePurgeable(true);
}
diff --git a/WebCore/loader/cache/MemoryCache.cpp b/WebCore/loader/cache/MemoryCache.cpp
new file mode 100644
index 0000000..4679f06
--- /dev/null
+++ b/WebCore/loader/cache/MemoryCache.cpp
@@ -0,0 +1,788 @@
+/*
+ Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
+ Copyright (C) 2001 Dirk Mueller (mueller at kde.org)
+ Copyright (C) 2002 Waldo Bastian (bastian at kde.org)
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "MemoryCache.h"
+
+#include "CachedCSSStyleSheet.h"
+#include "CachedFont.h"
+#include "CachedImage.h"
+#include "CachedScript.h"
+#include "CachedXSLStyleSheet.h"
+#include "CachedResourceLoader.h"
+#include "Document.h"
+#include "FrameLoader.h"
+#include "FrameLoaderTypes.h"
+#include "FrameView.h"
+#include "Image.h"
+#include "Logging.h"
+#include "ResourceHandle.h"
+#include "SecurityOrigin.h"
+#include <stdio.h>
+#include <wtf/CurrentTime.h>
+
+using namespace std;
+
+namespace WebCore {
+
+static const int cDefaultCacheCapacity = 8192 * 1024;
+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()
+{
+ static MemoryCache* staticCache = new MemoryCache;
+ return staticCache;
+}
+
+MemoryCache::MemoryCache()
+ : m_disabled(false)
+ , m_pruneEnabled(true)
+ , m_inPruneDeadResources(false)
+ , m_capacity(cDefaultCacheCapacity)
+ , m_minDeadCapacity(0)
+ , m_maxDeadCapacity(cDefaultCacheCapacity)
+ , m_deadDecodedDataDeletionInterval(cDefaultDecodedDataDeletionInterval)
+ , m_liveSize(0)
+ , m_deadSize(0)
+{
+}
+
+static CachedResource* createResource(CachedResource::Type type, const KURL& url, const String& charset)
+{
+ switch (type) {
+ case CachedResource::ImageResource:
+ return new CachedImage(url.string());
+ case CachedResource::CSSStyleSheet:
+ return new CachedCSSStyleSheet(url.string(), charset);
+ case CachedResource::Script:
+ return new CachedScript(url.string(), charset);
+ case CachedResource::FontResource:
+ return new CachedFont(url.string());
+#if ENABLE(XSLT)
+ case CachedResource::XSLStyleSheet:
+ return new CachedXSLStyleSheet(url.string());
+#endif
+#if ENABLE(LINK_PREFETCH)
+ case CachedResource::LinkPrefetch:
+ return new CachedResource(url.string(), CachedResource::LinkPrefetch);
+#endif
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
+{
+ LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload);
+
+ // FIXME: Do we really need to special-case an empty URL?
+ // Would it be better to just go on with the cache code and let it fail later?
+ if (url.isEmpty())
+ return 0;
+
+ // Look up the resource in our map.
+ CachedResource* resource = resourceForURL(url.string());
+
+ if (resource && requestIsPreload && !resource->isPreloaded()) {
+ LOG(ResourceLoading, "MemoryCache::requestResource already has a preload request for this request, and it hasn't been preloaded yet");
+ return 0;
+ }
+
+ if (!cachedResourceLoader->doc()->securityOrigin()->canDisplay(url)) {
+ LOG(ResourceLoading, "...URL was not allowed by SecurityOrigin");
+ if (!requestIsPreload)
+ FrameLoader::reportLocalLoadFailed(cachedResourceLoader->doc()->frame(), url.string());
+ return 0;
+ }
+
+ if (!resource) {
+ LOG(ResourceLoading, "CachedResource for '%s' wasn't found in cache. Creating it", url.string().latin1().data());
+ // The resource does not exist. Create it.
+ resource = createResource(type, url, charset);
+ ASSERT(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.
+ resource->setInCache(true);
+
+ resource->load(cachedResourceLoader);
+
+ if (resource->errorOccurred()) {
+ // We don't support immediate loads, but we do support immediate failure.
+ // In that case we should to delete the resource now and return 0 because otherwise
+ // it would leak if no ref/deref was ever done on it.
+ resource->setInCache(false);
+ delete resource;
+ return 0;
+ }
+
+ if (!disabled())
+ m_resources.set(url.string(), resource); // The size will be added in later once the resource is loaded and calls back to us with the new size.
+ else {
+ // Kick the resource out of the cache, because the cache is disabled.
+ resource->setInCache(false);
+ resource->setCachedResourceLoader(cachedResourceLoader);
+ }
+ }
+
+ if (resource->type() != type) {
+ LOG(ResourceLoading, "MemoryCache::requestResource cannot use cached resource for '%s' due to type mismatch", url.string().latin1().data());
+ return 0;
+ }
+
+ if (!disabled()) {
+ // This will move the resource to the front of its LRU list and increase its access count.
+ resourceAccessed(resource);
+ }
+
+ LOG(ResourceLoading, "MemoryCache::requestResource for '%s' returning resource %p\n", url.string().latin1().data(), resource);
+
+ return resource;
+}
+
+CachedCSSStyleSheet* MemoryCache::requestUserCSSStyleSheet(CachedResourceLoader* cachedResourceLoader, const String& url, const String& charset)
+{
+ CachedCSSStyleSheet* userSheet;
+ if (CachedResource* existing = resourceForURL(url)) {
+ if (existing->type() != CachedResource::CSSStyleSheet)
+ return 0;
+ userSheet = static_cast<CachedCSSStyleSheet*>(existing);
+ } else {
+ userSheet = new CachedCSSStyleSheet(url, charset);
+
+ // 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.
+ userSheet->setInCache(true);
+ // Don't load incrementally, skip load checks, don't send resource load callbacks.
+ userSheet->load(cachedResourceLoader, false, SkipSecurityCheck, false);
+ if (!disabled())
+ m_resources.set(url, userSheet);
+ else
+ userSheet->setInCache(false);
+ }
+
+ if (!disabled()) {
+ // This will move the resource to the front of its LRU list and increase its access count.
+ resourceAccessed(userSheet);
+ }
+
+ return userSheet;
+}
+
+void MemoryCache::revalidateResource(CachedResource* resource, CachedResourceLoader* cachedResourceLoader)
+{
+ ASSERT(resource);
+ ASSERT(resource->inCache());
+ ASSERT(resource == m_resources.get(resource->url()));
+ ASSERT(!disabled());
+ if (resource->resourceToRevalidate())
+ return;
+ if (!resource->canUseCacheValidator()) {
+ evict(resource);
+ return;
+ }
+ const String& url = resource->url();
+ CachedResource* newResource = createResource(resource->type(), KURL(ParsedURLString, url), resource->encoding());
+ LOG(ResourceLoading, "Resource %p created to revalidate %p", newResource, resource);
+ newResource->setResourceToRevalidate(resource);
+ evict(resource);
+ m_resources.set(url, newResource);
+ newResource->setInCache(true);
+ resourceAccessed(newResource);
+ newResource->load(cachedResourceLoader);
+}
+
+void MemoryCache::revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse& response)
+{
+ CachedResource* resource = revalidatingResource->resourceToRevalidate();
+ ASSERT(resource);
+ ASSERT(!resource->inCache());
+ ASSERT(resource->isLoaded());
+ ASSERT(revalidatingResource->inCache());
+
+ evict(revalidatingResource);
+
+ ASSERT(!m_resources.get(resource->url()));
+ m_resources.set(resource->url(), resource);
+ resource->setInCache(true);
+ resource->updateResponseAfterRevalidation(response);
+ insertInLRUList(resource);
+ int delta = resource->size();
+ if (resource->decodedSize() && resource->hasClients())
+ insertInLiveDecodedResourcesList(resource);
+ if (delta)
+ adjustSize(resource->hasClients(), delta);
+
+ revalidatingResource->switchClientsToRevalidatedResource();
+ // this deletes the revalidating resource
+ revalidatingResource->clearResourceToRevalidate();
+}
+
+void MemoryCache::revalidationFailed(CachedResource* revalidatingResource)
+{
+ LOG(ResourceLoading, "Revalidation failed for %p", revalidatingResource);
+ ASSERT(revalidatingResource->resourceToRevalidate());
+ revalidatingResource->clearResourceToRevalidate();
+}
+
+CachedResource* MemoryCache::resourceForURL(const String& url)
+{
+ CachedResource* resource = m_resources.get(url);
+ bool wasPurgeable = MemoryCache::shouldMakeResourcePurgeableOnEviction() && resource && resource->isPurgeable();
+ if (resource && !resource->makePurgeable(false)) {
+ ASSERT(!resource->hasClients());
+ evict(resource);
+ return 0;
+ }
+ // Add the size back since we had subtracted it when we marked the memory as purgeable.
+ if (wasPurgeable)
+ adjustSize(resource->hasClients(), resource->size());
+ return resource;
+}
+
+unsigned MemoryCache::deadCapacity() const
+{
+ // Dead resource capacity is whatever space is not occupied by live resources, bounded by an independent minimum and maximum.
+ unsigned capacity = m_capacity - min(m_liveSize, m_capacity); // Start with available capacity.
+ capacity = max(capacity, m_minDeadCapacity); // Make sure it's above the minimum.
+ capacity = min(capacity, m_maxDeadCapacity); // Make sure it's below the maximum.
+ return capacity;
+}
+
+unsigned MemoryCache::liveCapacity() const
+{
+ // Live resource capacity is whatever is left over after calculating dead resource capacity.
+ return m_capacity - deadCapacity();
+}
+
+void MemoryCache::pruneLiveResources()
+{
+ if (!m_pruneEnabled)
+ return;
+
+ unsigned capacity = liveCapacity();
+ if (capacity && m_liveSize <= capacity)
+ return;
+
+ unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again.
+ double currentTime = FrameView::currentPaintTimeStamp();
+ if (!currentTime) // In case prune is called directly, outside of a Frame paint.
+ currentTime = WTF::currentTime();
+
+ // Destroy any decoded data in live objects that we can.
+ // Start from the tail, since this is the least recently accessed of the objects.
+
+ // The list might not be sorted by the m_lastDecodedAccessTime. The impact
+ // of this weaker invariant is minor as the below if statement to check the
+ // elapsedTime will evaluate to false as the currentTime will be a lot
+ // greater than the current->m_lastDecodedAccessTime.
+ // For more details see: https://bugs.webkit.org/show_bug.cgi?id=30209
+ CachedResource* current = m_liveDecodedResources.m_tail;
+ while (current) {
+ CachedResource* prev = current->m_prevInLiveResourcesList;
+ ASSERT(current->hasClients());
+ if (current->isLoaded() && current->decodedSize()) {
+ // Check to see if the remaining resources are too new to prune.
+ double elapsedTime = currentTime - current->m_lastDecodedAccessTime;
+ if (elapsedTime < cMinDelayBeforeLiveDecodedPrune)
+ return;
+
+ // Destroy our decoded data. This will remove us from
+ // m_liveDecodedResources, and possibly move us to a different LRU
+ // list in m_allResources.
+ current->destroyDecodedData();
+
+ if (targetSize && m_liveSize <= targetSize)
+ return;
+ }
+ current = prev;
+ }
+}
+
+void MemoryCache::pruneDeadResources()
+{
+ if (!m_pruneEnabled)
+ return;
+
+ unsigned capacity = deadCapacity();
+ if (capacity && m_deadSize <= capacity)
+ return;
+
+ unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again.
+ int size = m_allResources.size();
+
+ if (!m_inPruneDeadResources) {
+ // See if we have any purged resources we can evict.
+ for (int i = 0; i < size; i++) {
+ CachedResource* current = m_allResources[i].m_tail;
+ while (current) {
+ CachedResource* prev = current->m_prevInAllResourcesList;
+ if (current->wasPurged()) {
+ ASSERT(!current->hasClients());
+ ASSERT(!current->isPreloaded());
+ evict(current);
+ }
+ current = prev;
+ }
+ }
+ if (targetSize && m_deadSize <= targetSize)
+ return;
+ }
+
+ bool canShrinkLRULists = true;
+ m_inPruneDeadResources = true;
+ for (int i = size - 1; i >= 0; i--) {
+ // Remove from the tail, since this is the least frequently accessed of the objects.
+ CachedResource* current = m_allResources[i].m_tail;
+
+ // First flush all the decoded data in this queue.
+ while (current) {
+ CachedResource* prev = current->m_prevInAllResourcesList;
+ if (!current->hasClients() && !current->isPreloaded() && current->isLoaded()) {
+ // Destroy our decoded data. This will remove us from
+ // m_liveDecodedResources, and possibly move us to a different
+ // LRU list in m_allResources.
+ current->destroyDecodedData();
+
+ if (targetSize && m_deadSize <= targetSize) {
+ m_inPruneDeadResources = false;
+ return;
+ }
+ }
+ current = prev;
+ }
+
+ // Now evict objects from this queue.
+ current = m_allResources[i].m_tail;
+ while (current) {
+ CachedResource* prev = current->m_prevInAllResourcesList;
+ if (!current->hasClients() && !current->isPreloaded() && !current->isCacheValidator()) {
+ if (!makeResourcePurgeable(current))
+ evict(current);
+
+ // If evict() caused pruneDeadResources() to be re-entered, bail out. This can happen when removing an
+ // SVG CachedImage that has subresources.
+ if (!m_inPruneDeadResources)
+ return;
+
+ if (targetSize && m_deadSize <= targetSize) {
+ m_inPruneDeadResources = false;
+ return;
+ }
+ }
+ current = prev;
+ }
+
+ // Shrink the vector back down so we don't waste time inspecting
+ // empty LRU lists on future prunes.
+ if (m_allResources[i].m_head)
+ canShrinkLRULists = false;
+ else if (canShrinkLRULists)
+ m_allResources.resize(i);
+ }
+ m_inPruneDeadResources = false;
+}
+
+void MemoryCache::setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned totalBytes)
+{
+ ASSERT(minDeadBytes <= maxDeadBytes);
+ ASSERT(maxDeadBytes <= totalBytes);
+ m_minDeadCapacity = minDeadBytes;
+ m_maxDeadCapacity = maxDeadBytes;
+ m_capacity = totalBytes;
+ prune();
+}
+
+bool MemoryCache::makeResourcePurgeable(CachedResource* resource)
+{
+ if (!MemoryCache::shouldMakeResourcePurgeableOnEviction())
+ return false;
+
+ if (!resource->inCache())
+ return false;
+
+ if (resource->isPurgeable())
+ return true;
+
+ if (!resource->isSafeToMakePurgeable())
+ return false;
+
+ if (!resource->makePurgeable(true))
+ return false;
+
+ adjustSize(resource->hasClients(), -static_cast<int>(resource->size()));
+
+ return true;
+}
+
+void MemoryCache::evict(CachedResource* resource)
+{
+ LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().latin1().data());
+ // The resource may have already been removed by someone other than our caller,
+ // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
+ if (resource->inCache()) {
+ // Remove from the resource map.
+ m_resources.remove(resource->url());
+ resource->setInCache(false);
+
+ // Remove from the appropriate LRU list.
+ removeFromLRUList(resource);
+ removeFromLiveDecodedResourcesList(resource);
+
+ // If the resource was purged, it means we had already decremented the size when we made the
+ // resource purgeable in makeResourcePurgeable(). So adjust the size if we are evicting a
+ // resource that was not marked as purgeable.
+ if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() || !resource->isPurgeable())
+ adjustSize(resource->hasClients(), -static_cast<int>(resource->size()));
+ } else
+ ASSERT(m_resources.get(resource->url()) != resource);
+
+ if (resource->canDelete())
+ 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;
+ if (i & (i - 1))
+ log2 += 1;
+ if (i >> 16)
+ log2 += 16, i >>= 16;
+ if (i >> 8)
+ log2 += 8, i >>= 8;
+ if (i >> 4)
+ log2 += 4, i >>= 4;
+ if (i >> 2)
+ log2 += 2, i >>= 2;
+ if (i >> 1)
+ log2 += 1;
+ return log2;
+}
+
+MemoryCache::LRUList* MemoryCache::lruListFor(CachedResource* resource)
+{
+ unsigned accessCount = max(resource->accessCount(), 1U);
+ unsigned queueIndex = fastLog2(resource->size() / accessCount);
+#ifndef NDEBUG
+ resource->m_lruIndex = queueIndex;
+#endif
+ if (m_allResources.size() <= queueIndex)
+ m_allResources.grow(queueIndex + 1);
+ return &m_allResources[queueIndex];
+}
+
+void MemoryCache::removeFromLRUList(CachedResource* resource)
+{
+ // If we've never been accessed, then we're brand new and not in any list.
+ if (resource->accessCount() == 0)
+ return;
+
+#if !ASSERT_DISABLED
+ unsigned oldListIndex = resource->m_lruIndex;
+#endif
+
+ LRUList* list = lruListFor(resource);
+
+#if !ASSERT_DISABLED
+ // Verify that the list we got is the list we want.
+ ASSERT(resource->m_lruIndex == oldListIndex);
+
+ // Verify that we are in fact in this list.
+ bool found = false;
+ for (CachedResource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
+ if (current == resource) {
+ found = true;
+ break;
+ }
+ }
+ ASSERT(found);
+#endif
+
+ CachedResource* next = resource->m_nextInAllResourcesList;
+ CachedResource* prev = resource->m_prevInAllResourcesList;
+
+ if (next == 0 && prev == 0 && list->m_head != resource)
+ return;
+
+ resource->m_nextInAllResourcesList = 0;
+ resource->m_prevInAllResourcesList = 0;
+
+ if (next)
+ next->m_prevInAllResourcesList = prev;
+ else if (list->m_tail == resource)
+ list->m_tail = prev;
+
+ if (prev)
+ prev->m_nextInAllResourcesList = next;
+ else if (list->m_head == resource)
+ list->m_head = next;
+}
+
+void MemoryCache::insertInLRUList(CachedResource* resource)
+{
+ // Make sure we aren't in some list already.
+ ASSERT(!resource->m_nextInAllResourcesList && !resource->m_prevInAllResourcesList);
+ ASSERT(resource->inCache());
+ ASSERT(resource->accessCount() > 0);
+
+ LRUList* list = lruListFor(resource);
+
+ resource->m_nextInAllResourcesList = list->m_head;
+ if (list->m_head)
+ list->m_head->m_prevInAllResourcesList = resource;
+ list->m_head = resource;
+
+ if (!resource->m_nextInAllResourcesList)
+ list->m_tail = resource;
+
+#ifndef NDEBUG
+ // Verify that we are in now in the list like we should be.
+ list = lruListFor(resource);
+ bool found = false;
+ for (CachedResource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
+ if (current == resource) {
+ found = true;
+ break;
+ }
+ }
+ ASSERT(found);
+#endif
+
+}
+
+void MemoryCache::resourceAccessed(CachedResource* resource)
+{
+ ASSERT(resource->inCache());
+
+ // Need to make sure to remove before we increase the access count, since
+ // the queue will possibly change.
+ removeFromLRUList(resource);
+
+ // If this is the first time the resource has been accessed, adjust the size of the cache to account for its initial size.
+ if (!resource->accessCount())
+ adjustSize(resource->hasClients(), resource->size());
+
+ // Add to our access count.
+ resource->increaseAccessCount();
+
+ // Now insert into the new queue.
+ insertInLRUList(resource);
+}
+
+void MemoryCache::removeFromLiveDecodedResourcesList(CachedResource* resource)
+{
+ // If we've never been accessed, then we're brand new and not in any list.
+ if (!resource->m_inLiveDecodedResourcesList)
+ return;
+ resource->m_inLiveDecodedResourcesList = false;
+
+#ifndef NDEBUG
+ // Verify that we are in fact in this list.
+ bool found = false;
+ for (CachedResource* current = m_liveDecodedResources.m_head; current; current = current->m_nextInLiveResourcesList) {
+ if (current == resource) {
+ found = true;
+ break;
+ }
+ }
+ ASSERT(found);
+#endif
+
+ CachedResource* next = resource->m_nextInLiveResourcesList;
+ CachedResource* prev = resource->m_prevInLiveResourcesList;
+
+ if (next == 0 && prev == 0 && m_liveDecodedResources.m_head != resource)
+ return;
+
+ resource->m_nextInLiveResourcesList = 0;
+ resource->m_prevInLiveResourcesList = 0;
+
+ if (next)
+ next->m_prevInLiveResourcesList = prev;
+ else if (m_liveDecodedResources.m_tail == resource)
+ m_liveDecodedResources.m_tail = prev;
+
+ if (prev)
+ prev->m_nextInLiveResourcesList = next;
+ else if (m_liveDecodedResources.m_head == resource)
+ m_liveDecodedResources.m_head = next;
+}
+
+void MemoryCache::insertInLiveDecodedResourcesList(CachedResource* resource)
+{
+ // Make sure we aren't in the list already.
+ ASSERT(!resource->m_nextInLiveResourcesList && !resource->m_prevInLiveResourcesList && !resource->m_inLiveDecodedResourcesList);
+ resource->m_inLiveDecodedResourcesList = true;
+
+ resource->m_nextInLiveResourcesList = m_liveDecodedResources.m_head;
+ if (m_liveDecodedResources.m_head)
+ m_liveDecodedResources.m_head->m_prevInLiveResourcesList = resource;
+ m_liveDecodedResources.m_head = resource;
+
+ if (!resource->m_nextInLiveResourcesList)
+ m_liveDecodedResources.m_tail = resource;
+
+#ifndef NDEBUG
+ // Verify that we are in now in the list like we should be.
+ bool found = false;
+ for (CachedResource* current = m_liveDecodedResources.m_head; current; current = current->m_nextInLiveResourcesList) {
+ if (current == resource) {
+ found = true;
+ break;
+ }
+ }
+ ASSERT(found);
+#endif
+
+}
+
+void MemoryCache::addToLiveResourcesSize(CachedResource* resource)
+{
+ m_liveSize += resource->size();
+ m_deadSize -= resource->size();
+}
+
+void MemoryCache::removeFromLiveResourcesSize(CachedResource* resource)
+{
+ m_liveSize -= resource->size();
+ m_deadSize += resource->size();
+}
+
+void MemoryCache::adjustSize(bool live, int delta)
+{
+ if (live) {
+ ASSERT(delta >= 0 || ((int)m_liveSize + delta >= 0));
+ m_liveSize += delta;
+ } else {
+ ASSERT(delta >= 0 || ((int)m_deadSize + delta >= 0));
+ m_deadSize += delta;
+ }
+}
+
+void MemoryCache::TypeStatistic::addResource(CachedResource* o)
+{
+ bool purged = o->wasPurged();
+ bool purgeable = o->isPurgeable() && !purged;
+ int pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095;
+ count++;
+ size += purged ? 0 : o->size();
+ liveSize += o->hasClients() ? o->size() : 0;
+ decodedSize += o->decodedSize();
+ purgeableSize += purgeable ? pageSize : 0;
+ purgedSize += purged ? pageSize : 0;
+}
+
+MemoryCache::Statistics MemoryCache::getStatistics()
+{
+ Statistics stats;
+ CachedResourceMap::iterator e = m_resources.end();
+ for (CachedResourceMap::iterator i = m_resources.begin(); i != e; ++i) {
+ CachedResource* resource = i->second;
+ switch (resource->type()) {
+ case CachedResource::ImageResource:
+ stats.images.addResource(resource);
+ break;
+ case CachedResource::CSSStyleSheet:
+ stats.cssStyleSheets.addResource(resource);
+ break;
+ case CachedResource::Script:
+ stats.scripts.addResource(resource);
+ break;
+#if ENABLE(XSLT)
+ case CachedResource::XSLStyleSheet:
+ stats.xslStyleSheets.addResource(resource);
+ break;
+#endif
+ case CachedResource::FontResource:
+ stats.fonts.addResource(resource);
+ break;
+ default:
+ break;
+ }
+ }
+ return stats;
+}
+
+void MemoryCache::setDisabled(bool disabled)
+{
+ m_disabled = disabled;
+ if (!m_disabled)
+ return;
+
+ for (;;) {
+ CachedResourceMap::iterator i = m_resources.begin();
+ if (i == m_resources.end())
+ break;
+ evict(i->second);
+ }
+}
+
+#ifndef NDEBUG
+void MemoryCache::dumpStats()
+{
+ Statistics s = getStatistics();
+ printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize", "PurgeableSize", "PurgedSize");
+ printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------");
+ printf("%-13s %13d %13d %13d %13d %13d %13d\n", "Images", s.images.count, s.images.size, s.images.liveSize, s.images.decodedSize, s.images.purgeableSize, s.images.purgedSize);
+ printf("%-13s %13d %13d %13d %13d %13d %13d\n", "CSS", s.cssStyleSheets.count, s.cssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize, s.cssStyleSheets.purgeableSize, s.cssStyleSheets.purgedSize);
+#if ENABLE(XSLT)
+ printf("%-13s %13d %13d %13d %13d %13d %13d\n", "XSL", s.xslStyleSheets.count, s.xslStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize, s.xslStyleSheets.purgeableSize, s.xslStyleSheets.purgedSize);
+#endif
+ printf("%-13s %13d %13d %13d %13d %13d %13d\n", "JavaScript", s.scripts.count, s.scripts.size, s.scripts.liveSize, s.scripts.decodedSize, s.scripts.purgeableSize, s.scripts.purgedSize);
+ printf("%-13s %13d %13d %13d %13d %13d %13d\n", "Fonts", s.fonts.count, s.fonts.size, s.fonts.liveSize, s.fonts.decodedSize, s.fonts.purgeableSize, s.fonts.purgedSize);
+ printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------");
+}
+
+void MemoryCache::dumpLRULists(bool includeLive) const
+{
+ printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced, isPurgeable, wasPurged):\n");
+
+ int size = m_allResources.size();
+ for (int i = size - 1; i >= 0; i--) {
+ printf("\n\nList %d: ", i);
+ CachedResource* current = m_allResources[i].m_tail;
+ while (current) {
+ CachedResource* prev = current->m_prevInAllResourcesList;
+ if (includeLive || !current->hasClients())
+ printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", current->decodedSize() / 1024.0f, (current->encodedSize() + current->overheadSize()) / 1024.0f, current->accessCount(), current->hasClients(), current->isPurgeable(), current->wasPurged());
+
+ current = prev;
+ }
+ }
+}
+#endif
+
+} // namespace WebCore
diff --git a/WebCore/loader/cache/MemoryCache.h b/WebCore/loader/cache/MemoryCache.h
new file mode 100644
index 0000000..bf0f32c
--- /dev/null
+++ b/WebCore/loader/cache/MemoryCache.h
@@ -0,0 +1,235 @@
+/*
+ Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
+ Copyright (C) 2001 Dirk Mueller <mueller at kde.org>
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ This class provides all functionality needed for loading images, style sheets and html
+ pages from the web. It has a memory cache for these objects.
+*/
+
+#ifndef Cache_h
+#define Cache_h
+
+#include "CachePolicy.h"
+#include "CachedResource.h"
+#include "PlatformString.h"
+#include "loader.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class CachedCSSStyleSheet;
+class CachedResource;
+class CachedResourceLoader;
+class KURL;
+
+// This cache holds subresources used by Web pages: images, scripts, stylesheets, etc.
+
+// The cache keeps a flexible but bounded window of dead resources that grows/shrinks
+// depending on the live resource load. Here's an example of cache growth over time,
+// with a min dead resource capacity of 25% and a max dead resource capacity of 50%:
+
+// |-----| Dead: -
+// |----------| Live: +
+// --|----------| Cache boundary: | (objects outside this mark have been evicted)
+// --|----------++++++++++|
+// -------|-----+++++++++++++++|
+// -------|-----+++++++++++++++|+++++
+
+// The behavior of the cache changes in the following way if shouldMakeResourcePurgeableOnEviction
+// returns true.
+//
+// 1. Dead resources in the cache are kept in non-purgeable memory.
+// 2. When we prune dead resources, instead of freeing them, we mark their memory as purgeable and
+// keep the resources until the kernel reclaims the purgeable memory.
+//
+// By leaving the in-cache dead resources in dirty resident memory, we decrease the likelihood of
+// the kernel claiming that memory and forcing us to refetch the resource (for example when a user
+// presses back).
+//
+// And by having an unbounded number of resource objects using purgeable memory, we can use as much
+// memory as is available on the machine. The trade-off here is that the CachedResource object (and
+// its member variables) are allocated in non-purgeable TC-malloc'd memory so we would see slightly
+// more memory use due to this.
+
+class MemoryCache : public Noncopyable {
+public:
+ friend MemoryCache* cache();
+
+ typedef HashMap<String, CachedResource*> CachedResourceMap;
+
+ struct LRUList {
+ CachedResource* m_head;
+ CachedResource* m_tail;
+ LRUList() : m_head(0), m_tail(0) { }
+ };
+
+ struct TypeStatistic {
+ int count;
+ int size;
+ int liveSize;
+ int decodedSize;
+ int purgeableSize;
+ int purgedSize;
+ TypeStatistic() : count(0), size(0), liveSize(0), decodedSize(0), purgeableSize(0), purgedSize(0) { }
+ void addResource(CachedResource*);
+ };
+
+ struct Statistics {
+ TypeStatistic images;
+ TypeStatistic cssStyleSheets;
+ TypeStatistic scripts;
+#if ENABLE(XSLT)
+ TypeStatistic xslStyleSheets;
+#endif
+ TypeStatistic fonts;
+ };
+
+ // The loader that fetches resources.
+ Loader* loader() { return &m_loader; }
+
+ // Request resources from the cache. A load will be initiated and a cache object created if the object is not
+ // found in the cache.
+ CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
+
+ CachedCSSStyleSheet* requestUserCSSStyleSheet(CachedResourceLoader*, const String& url, const String& charset);
+
+ void revalidateResource(CachedResource*, CachedResourceLoader*);
+ void revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse&);
+ void revalidationFailed(CachedResource* revalidatingResource);
+
+ // Sets the cache's memory capacities, in bytes. These will hold only approximately,
+ // since the decoded cost of resources like scripts and stylesheets is not known.
+ // - minDeadBytes: The maximum number of bytes that dead resources should consume when the cache is under pressure.
+ // - maxDeadBytes: The maximum number of bytes that dead resources should consume when the cache is not under pressure.
+ // - totalBytes: The maximum number of bytes that the cache should consume overall.
+ void setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned totalBytes);
+
+ // Turn the cache on and off. Disabling the cache will remove all resources from the cache. They may
+ // still live on if they are referenced by some Web page though.
+ void setDisabled(bool);
+ bool disabled() const { return m_disabled; }
+
+ void setPruneEnabled(bool enabled) { m_pruneEnabled = enabled; }
+ void prune()
+ {
+ if (m_liveSize + m_deadSize <= m_capacity && m_maxDeadCapacity && m_deadSize <= m_maxDeadCapacity) // Fast path.
+ return;
+
+ pruneDeadResources(); // Prune dead first, in case it was "borrowing" capacity from live.
+ pruneLiveResources();
+ }
+
+ void setDeadDecodedDataDeletionInterval(double interval) { m_deadDecodedDataDeletionInterval = interval; }
+ double deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
+
+ // Remove an existing cache entry from both the resource map and from the LRU list.
+ void remove(CachedResource* resource) { evict(resource); }
+
+ void addCachedResourceLoader(CachedResourceLoader*);
+ void removeCachedResourceLoader(CachedResourceLoader*);
+
+ CachedResource* resourceForURL(const String&);
+
+ // Calls to put the cached resource into and out of LRU lists.
+ void insertInLRUList(CachedResource*);
+ void removeFromLRUList(CachedResource*);
+
+ // Called to adjust the cache totals when a resource changes size.
+ void adjustSize(bool live, int delta);
+
+ // Track decoded resources that are in the cache and referenced by a Web page.
+ void insertInLiveDecodedResourcesList(CachedResource*);
+ void removeFromLiveDecodedResourcesList(CachedResource*);
+
+ void addToLiveResourcesSize(CachedResource*);
+ void removeFromLiveResourcesSize(CachedResource*);
+
+ static bool shouldMakeResourcePurgeableOnEviction();
+
+ // Function to collect cache statistics for the caches window in the Safari Debug menu.
+ Statistics getStatistics();
+
+private:
+ MemoryCache();
+ ~MemoryCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
+
+ LRUList* lruListFor(CachedResource*);
+ void resourceAccessed(CachedResource*);
+#ifndef NDEBUG
+ void dumpStats();
+ void dumpLRULists(bool includeLive) const;
+#endif
+
+ unsigned liveCapacity() const;
+ unsigned deadCapacity() const;
+
+ void pruneDeadResources(); // Flush decoded and encoded data from resources not referenced by Web pages.
+ void pruneLiveResources(); // Flush decoded data from resources still referenced by Web pages.
+
+ bool makeResourcePurgeable(CachedResource*);
+ void evict(CachedResource*);
+
+ // Member variables.
+ HashSet<CachedResourceLoader*> m_cachedResourceLoaders;
+ Loader m_loader;
+
+ bool m_disabled; // Whether or not the cache is enabled.
+ bool m_pruneEnabled;
+ bool m_inPruneDeadResources;
+
+ unsigned m_capacity;
+ unsigned m_minDeadCapacity;
+ unsigned m_maxDeadCapacity;
+ double m_deadDecodedDataDeletionInterval;
+
+ unsigned m_liveSize; // The number of bytes currently consumed by "live" resources in the cache.
+ unsigned m_deadSize; // The number of bytes currently consumed by "dead" resources in the cache.
+
+ // Size-adjusted and popularity-aware LRU list collection for cache objects. This collection can hold
+ // more resources than the cached resource map, since it can also hold "stale" multiple versions of objects that are
+ // waiting to die when the clients referencing them go away.
+ Vector<LRUList, 32> m_allResources;
+
+ // List just for live resources with decoded data. Access to this list is based off of painting the resource.
+ LRUList m_liveDecodedResources;
+
+ // A URL-based map of all resources that are in the cache (including the freshest version of objects that are currently being
+ // referenced by a Web page).
+ HashMap<String, CachedResource*> m_resources;
+};
+
+inline bool MemoryCache::shouldMakeResourcePurgeableOnEviction()
+{
+#if PLATFORM(IOS)
+ return true;
+#else
+ return false;
+#endif
+}
+
+// Function to obtain the global cache.
+MemoryCache* cache();
+
+}
+
+#endif
diff --git a/WebCore/loader/loader.cpp b/WebCore/loader/loader.cpp
index 655ff92..6c1736c 100644
--- a/WebCore/loader/loader.cpp
+++ b/WebCore/loader/loader.cpp
@@ -24,7 +24,7 @@
#include "config.h"
#include "loader.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CachedImage.h"
#include "CachedResource.h"
#include "CachedResourceLoader.h"
diff --git a/WebCore/page/EventSource.cpp b/WebCore/page/EventSource.cpp
index 01af087..5e3141d 100644
--- a/WebCore/page/EventSource.cpp
+++ b/WebCore/page/EventSource.cpp
@@ -36,7 +36,7 @@
#include "EventSource.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "DOMWindow.h"
#include "Event.h"
#include "EventException.h"
diff --git a/WebCore/page/Settings.h b/WebCore/page/Settings.h
index 03998cc..1e3c287 100644
--- a/WebCore/page/Settings.h
+++ b/WebCore/page/Settings.h
@@ -143,7 +143,7 @@ namespace WebCore {
// - HTML5/DOM Storage
// - Icon Database
// - Console Messages
- // - Cache
+ // - MemoryCache
// - Application Cache
// - Back/Forward Page History
// - Page Search Results
diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp
index afab73d..43ee8a8 100644
--- a/WebCore/xml/XMLHttpRequest.cpp
+++ b/WebCore/xml/XMLHttpRequest.cpp
@@ -23,7 +23,7 @@
#include "XMLHttpRequest.h"
#include "Blob.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CrossOriginAccessControl.h"
#include "DOMFormData.h"
#include "DOMImplementation.h"
@@ -600,7 +600,7 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
setPendingActivity(this);
// For now we should only balance the nonCached request count for main-thread XHRs and not
- // Worker XHRs, as the Cache is not thread-safe.
+ // Worker XHRs, as the MemoryCache is not thread-safe.
// This will become irrelevant after https://bugs.webkit.org/show_bug.cgi?id=27165 is resolved.
if (!scriptExecutionContext()->isWorkerContext()) {
ASSERT(isMainThread());
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index ff4ad3d..721d251 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,18 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * public/WebCache.h:
+ * src/WebCache.cpp:
+ (WebKit::ToResourceTypeStat):
+ (WebKit::WebCache::setCapacities):
+ (WebKit::WebCache::clear):
+ (WebKit::WebCache::getUsageStats):
+ (WebKit::WebCache::getResourceTypeStats):
+
2010-11-07 Jay Civelli <jcivelli at chromium.org>
Reviewed by Kent Tamura.
diff --git a/WebKit/chromium/public/WebCache.h b/WebKit/chromium/public/WebCache.h
index 433eb1a..e8a18d3 100644
--- a/WebKit/chromium/public/WebCache.h
+++ b/WebKit/chromium/public/WebCache.h
@@ -48,7 +48,7 @@ public:
size_t deadSize;
};
- // A struct mirroring WebCore::Cache::TypeStatistic.
+ // A struct mirroring WebCore::MemoryCache::TypeStatistic.
struct ResourceTypeStat {
size_t count;
size_t size;
@@ -56,7 +56,7 @@ public:
size_t decodedSize;
};
- // A struct mirroring WebCore::Cache::Statistics.
+ // A struct mirroring WebCore::MemoryCache::Statistics.
struct ResourceTypeStats {
ResourceTypeStat images;
ResourceTypeStat cssStyleSheets;
diff --git a/WebKit/chromium/src/WebCache.cpp b/WebKit/chromium/src/WebCache.cpp
index c124bdf..2203498 100644
--- a/WebKit/chromium/src/WebCache.cpp
+++ b/WebKit/chromium/src/WebCache.cpp
@@ -31,20 +31,20 @@
#include "config.h"
#include "WebCache.h"
-// Instead of providing accessors, we make all members of Cache public.
-// This will make it easier to track WebCore changes to the Cache class.
-// FIXME: We should introduce public getters on the Cache class.
+// Instead of providing accessors, we make all members of MemoryCache public.
+// This will make it easier to track WebCore changes to the MemoryCache class.
+// FIXME: We should introduce public getters on the MemoryCache class.
#define private public
-#include "Cache.h"
+#include "MemoryCache.h"
#undef private
using namespace WebCore;
namespace WebKit {
-// A helper method for coverting a Cache::TypeStatistic to a
+// A helper method for coverting a MemoryCache::TypeStatistic to a
// WebCache::ResourceTypeStat.
-static void ToResourceTypeStat(const Cache::TypeStatistic& from,
+static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from,
WebCache::ResourceTypeStat& to)
{
to.count = static_cast<size_t>(from.count);
@@ -56,7 +56,7 @@ static void ToResourceTypeStat(const Cache::TypeStatistic& from,
void WebCache::setCapacities(
size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity)
{
- Cache* cache = WebCore::cache();
+ MemoryCache* cache = WebCore::cache();
if (cache)
cache->setCapacities(static_cast<unsigned int>(minDeadCapacity),
static_cast<unsigned int>(maxDeadCapacity),
@@ -65,7 +65,7 @@ void WebCache::setCapacities(
void WebCache::clear()
{
- Cache* cache = WebCore::cache();
+ MemoryCache* cache = WebCore::cache();
if (cache && !cache->disabled()) {
cache->setDisabled(true);
cache->setDisabled(false);
@@ -76,7 +76,7 @@ void WebCache::getUsageStats(UsageStats* result)
{
ASSERT(result);
- Cache* cache = WebCore::cache();
+ MemoryCache* cache = WebCore::cache();
if (cache) {
result->minDeadCapacity = cache->m_minDeadCapacity;
result->maxDeadCapacity = cache->m_maxDeadCapacity;
@@ -89,9 +89,9 @@ void WebCache::getUsageStats(UsageStats* result)
void WebCache::getResourceTypeStats(ResourceTypeStats* result)
{
- Cache* cache = WebCore::cache();
+ MemoryCache* cache = WebCore::cache();
if (cache) {
- Cache::Statistics stats = cache->getStatistics();
+ MemoryCache::Statistics stats = cache->getStatistics();
ToResourceTypeStat(stats.images, result->images);
ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets);
ToResourceTypeStat(stats.scripts, result->scripts);
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 2d49d64..ea8b042 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,12 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * webkit/webkitwebview.cpp:
+
2010-11-05 Nicolas Dufresne <nicolas.dufresne at collabora.co.uk>
Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 4da9e3a..f419ff7 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -43,7 +43,7 @@
#include "AXObjectCache.h"
#include "AbstractDatabase.h"
#include "BackForwardListImpl.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "ChromeClientGtk.h"
#include "ClipboardUtilitiesGtk.h"
#include "ContextMenuClientGtk.h"
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index dbbb720..dc36fc1 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,16 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * Misc/WebCache.mm:
+ (+[WebCache statistics]):
+ * WebCoreSupport/WebDeviceOrientationClient.mm:
+ (WebDeviceOrientationClient::setController):
+ * WebView/WebView.mm:
+
2010-11-05 Alexey Proskuryakov <ap at apple.com>
Reviewed by Darin Adler.
diff --git a/WebKit/mac/Misc/WebCache.mm b/WebKit/mac/Misc/WebCache.mm
index 747d213..0517bc4 100644
--- a/WebKit/mac/Misc/WebCache.mm
+++ b/WebKit/mac/Misc/WebCache.mm
@@ -31,7 +31,7 @@
#import "WebView.h"
#import "WebViewInternal.h"
#import <WebCore/ApplicationCacheStorage.h>
-#import <WebCore/Cache.h>
+#import <WebCore/MemoryCache.h>
#import <WebCore/CrossOriginPreflightResultCache.h>
@implementation WebCache
@@ -43,7 +43,7 @@
+ (NSArray *)statistics
{
- WebCore::Cache::Statistics s = WebCore::cache()->getStatistics();
+ WebCore::MemoryCache::Statistics s = WebCore::cache()->getStatistics();
return [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
diff --git a/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm b/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm
index f0c624d..3a4d5d7 100644
--- a/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm
@@ -41,7 +41,7 @@ WebDeviceOrientationClient::WebDeviceOrientationClient(WebView* webView)
void WebDeviceOrientationClient::setController(DeviceOrientationController* controller)
{
// This is called by the Page constructor before our WebView has the provider set up.
- // Cache the controller for later use.
+ // MemoryCache the controller for later use.
m_controller = controller;
}
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 5a86eee..49bb451 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -111,7 +111,7 @@
#import <WebCore/AbstractDatabase.h>
#import <WebCore/ApplicationCacheStorage.h>
#import <WebCore/BackForwardListImpl.h>
-#import <WebCore/Cache.h>
+#import <WebCore/MemoryCache.h>
#import <WebCore/ColorMac.h>
#import <WebCore/CSSComputedStyleDeclaration.h>
#import <WebCore/Cursor.h>
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index b906795..a6ca65a 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -38,7 +38,7 @@
#include "CSSParser.h"
#include "ApplicationCacheStorage.h"
#include "BackForwardListImpl.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "Chrome.h"
#include "ChromeClientQt.h"
#include "ClientRect.h"
diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp
index 3cd36f2..ed425c2 100644
--- a/WebKit/qt/Api/qwebsettings.cpp
+++ b/WebKit/qt/Api/qwebsettings.cpp
@@ -25,7 +25,7 @@
#include "qwebplugindatabase_p.h"
#include "AbstractDatabase.h"
-#include "Cache.h"
+#include "MemoryCache.h"
#include "CrossOriginPreflightResultCache.h"
#include "FontCache.h"
#include "Page.h"
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 8483d95..872ead1 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,13 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * Api/qwebpage.cpp:
+ * Api/qwebsettings.cpp:
+
2010-11-07 Chang Shu <chang.shu at nokia.com>
Reviewed by Antonio Gomes.
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index efa7b5c..9ce52ac 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,15 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * WebCache.cpp:
+ (WebCache::statistics):
+ * WebFrame.cpp:
+ * WebView.cpp:
+
2010-11-05 Chris Marrin <cmarrin at apple.com>
Reviewed by Simon Fraser.
diff --git a/WebKit/win/WebCache.cpp b/WebKit/win/WebCache.cpp
index d82fc43..dff53fe 100644
--- a/WebKit/win/WebCache.cpp
+++ b/WebKit/win/WebCache.cpp
@@ -31,7 +31,7 @@
#pragma warning(push, 0)
#include <WebCore/ApplicationCacheStorage.h>
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/CrossOriginPreflightResultCache.h>
#pragma warning(pop)
@@ -100,7 +100,7 @@ HRESULT STDMETHODCALLTYPE WebCache::statistics(
if (!s)
return S_OK;
- WebCore::Cache::Statistics stat = WebCore::cache()->getStatistics();
+ WebCore::MemoryCache::Statistics stat = WebCore::cache()->getStatistics();
static CFStringRef imagesKey = CFSTR("images");
static CFStringRef stylesheetsKey = CFSTR("style sheets");
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index dcf38a4..60be4d5 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -55,7 +55,7 @@
#include "WebView.h"
#pragma warning( push, 0 )
#include <WebCore/BString.h>
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/Document.h>
#include <WebCore/DocumentLoader.h>
#include <WebCore/DOMImplementation.h>
diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
index e99b9da..7ce7812 100644
--- a/WebKit/win/WebView.cpp
+++ b/WebKit/win/WebView.cpp
@@ -69,7 +69,7 @@
#include <WebCore/BString.h>
#include <WebCore/BackForwardListImpl.h>
#include <WebCore/BitmapInfo.h>
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/Chrome.h>
#include <WebCore/ContextMenu.h>
#include <WebCore/ContextMenuController.h>
diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog
index 3895a2e..ee4e773 100644
--- a/WebKit/wx/ChangeLog
+++ b/WebKit/wx/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * WebView.cpp:
+ (wxWebView::SetCachePolicy):
+ * WebView.h:
+
2010-11-01 Brady Eidson <beidson at apple.com>
Reviewed by Anders Carlsson.
diff --git a/WebKit/wx/WebView.cpp b/WebKit/wx/WebView.cpp
index 5980236..667aa88 100644
--- a/WebKit/wx/WebView.cpp
+++ b/WebKit/wx/WebView.cpp
@@ -24,13 +24,14 @@
*/
#include "config.h"
-#include "Cache.h"
+#include "WebView.h"
+
#include "ContextMenu.h"
-#include "ContextMenuItem.h"
#include "ContextMenuController.h"
+#include "ContextMenuItem.h"
#include "Document.h"
-#include "Element.h"
#include "Editor.h"
+#include "Element.h"
#include "EmptyClients.h"
#include "EventHandler.h"
#include "FileChooser.h"
@@ -41,7 +42,7 @@
#include "GraphicsContext.h"
#include "HTMLFormElement.h"
#include "Logging.h"
-#include "markup.h"
+#include "MemoryCache.h"
#include "Page.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformMouseEvent.h"
@@ -56,6 +57,7 @@
#include "Settings.h"
#include "SubstituteData.h"
#include "Threading.h"
+#include "markup.h"
#if __WXMSW__
#include "WebCoreInstanceHandle.h"
#endif
@@ -87,7 +89,6 @@
#include "WebDOMNode.h"
#include "WebFrame.h"
-#include "WebView.h"
#include "WebViewPrivate.h"
#include <wx/defs.h>
@@ -269,12 +270,12 @@ static wxWebViewCachePolicy gs_cachePolicy;
/* static */
void wxWebView::SetCachePolicy(const wxWebViewCachePolicy& cachePolicy)
{
- WebCore::Cache* globalCache = WebCore::cache();
+ WebCore::MemoryCache* globalCache = WebCore::cache();
globalCache->setCapacities(cachePolicy.GetMinDeadCapacity(),
cachePolicy.GetMaxDeadCapacity(),
cachePolicy.GetCapacity());
- // store a copy since there is no getter for Cache values
+ // store a copy since there is no getter for MemoryCache values
gs_cachePolicy = cachePolicy;
}
diff --git a/WebKit/wx/WebView.h b/WebKit/wx/WebView.h
index 3ddb45e..4a6b081 100644
--- a/WebKit/wx/WebView.h
+++ b/WebKit/wx/WebView.h
@@ -54,7 +54,7 @@ namespace WebCore {
extern WXDLLIMPEXP_WEBKIT const wxChar* wxWebViewNameStr;
#endif
-static const int defaultCacheCapacity = 8192 * 1024; // mirrors Cache.cpp
+static const int defaultCacheCapacity = 8192 * 1024; // mirrors MemoryCache.cpp
class WXDLLIMPEXP_WEBKIT wxWebViewCachePolicy
{
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 248cfcc..031fc26 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-07 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Rename Cache to MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=49159
+
+ * WebProcess/WebProcess.cpp:
+ * WebProcess/mac/WebProcessMac.mm:
+ * WebProcess/win/WebProcessWin.cpp:
+
2010-11-06 Balazs Kelemen <kbalazs at webkit.org>
Reviewed by Andreas Kling.
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index 49bd9b5..c71c3cd 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -49,7 +49,7 @@
#include <wtf/RandomNumber.h>
#ifndef NDEBUG
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/GCController.h>
#endif
diff --git a/WebKit2/WebProcess/mac/WebProcessMac.mm b/WebKit2/WebProcess/mac/WebProcessMac.mm
index b3bbdda..119d242 100644
--- a/WebKit2/WebProcess/mac/WebProcessMac.mm
+++ b/WebKit2/WebProcess/mac/WebProcessMac.mm
@@ -25,7 +25,7 @@
#include "WebProcess.h"
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/PageCache.h>
#include <WebKitSystemInterface.h>
#include <algorithm>
diff --git a/WebKit2/WebProcess/win/WebProcessWin.cpp b/WebKit2/WebProcess/win/WebProcessWin.cpp
index e0ba2b3..556a267 100644
--- a/WebKit2/WebProcess/win/WebProcessWin.cpp
+++ b/WebKit2/WebProcess/win/WebProcessWin.cpp
@@ -25,7 +25,7 @@
#include "WebProcess.h"
-#include <WebCore/Cache.h>
+#include <WebCore/MemoryCache.h>
#include <WebCore/FileSystem.h>
#include <WebCore/PageCache.h>
#include <wtf/text/WTFString.h>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list