Title: [93782] trunk/Source
Revision
93782
Author
mnaga...@chromium.org
Date
2011-08-25 07:37:21 -0700 (Thu, 25 Aug 2011)

Log Message

Chromium: expose MemoryCache::prune and FontCache::purgeInactiveFontData.
https://bugs.webkit.org/show_bug.cgi?id=66132

Reviewed by Tony Gentilcore.

* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::prune):
(WebCore::MemoryCache::pruneToPercentage):
* loader/cache/MemoryCache.h: Methods moved from .h to .cpp to work around compilation problem with the Win Chromium port.

* public/WebCache.h:
* public/WebFontCache.h:
* src/WebCache.cpp:
(WebKit::WebCache::clear):
(WebKit::WebCache::prune):
* src/WebFontCache.cpp:
(WebKit::WebFontCache::prune):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (93781 => 93782)


--- trunk/Source/WebCore/ChangeLog	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebCore/ChangeLog	2011-08-25 14:37:21 UTC (rev 93782)
@@ -1,3 +1,15 @@
+2011-08-25  Mikhail Naganov  <mnaga...@chromium.org>
+
+        Chromium: expose MemoryCache::prune and FontCache::purgeInactiveFontData.
+        https://bugs.webkit.org/show_bug.cgi?id=66132
+
+        Reviewed by Tony Gentilcore.
+
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::prune):
+        (WebCore::MemoryCache::pruneToPercentage):
+        * loader/cache/MemoryCache.h: Methods moved from .h to .cpp to work around compilation problem with the Win Chromium port.
+
 2011-08-25  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r93771.

Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (93781 => 93782)


--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2011-08-25 14:37:21 UTC (rev 93782)
@@ -697,6 +697,22 @@
     setDisabled(false);
 }
 
+void MemoryCache::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 MemoryCache::pruneToPercentage(float targetPercentLive)
+{
+    pruneDeadResourcesToPercentage(targetPercentLive); // Prune dead first, in case it was "borrowing" capacity from live.
+    pruneLiveResourcesToPercentage(targetPercentLive);
+}
+
+
 #ifndef NDEBUG
 void MemoryCache::dumpStats()
 {

Modified: trunk/Source/WebCore/loader/cache/MemoryCache.h (93781 => 93782)


--- trunk/Source/WebCore/loader/cache/MemoryCache.h	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.h	2011-08-25 14:37:21 UTC (rev 93782)
@@ -130,21 +130,9 @@
     void evictResources();
     
     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 prune();
+    void pruneToPercentage(float targetPercentLive);
 
-    void pruneToPercentage(float targetPercentLive)
-    {
-        pruneDeadResourcesToPercentage(targetPercentLive); // Prune dead first, in case it was "borrowing" capacity from live.
-        pruneLiveResourcesToPercentage(targetPercentLive);
-    }
-
     void setDeadDecodedDataDeletionInterval(double interval) { m_deadDecodedDataDeletionInterval = interval; }
     double deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (93781 => 93782)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-08-25 14:37:21 UTC (rev 93782)
@@ -1,3 +1,18 @@
+2011-08-25  Mikhail Naganov  <mnaga...@chromium.org>
+
+        Chromium: expose MemoryCache::prune and FontCache::purgeInactiveFontData.
+        https://bugs.webkit.org/show_bug.cgi?id=66132
+
+        Reviewed by Tony Gentilcore.
+
+        * public/WebCache.h:
+        * public/WebFontCache.h:
+        * src/WebCache.cpp:
+        (WebKit::WebCache::clear):
+        (WebKit::WebCache::prune):
+        * src/WebFontCache.cpp:
+        (WebKit::WebFontCache::prune):
+
 2011-08-24  Kentaro Hara  <hara...@google.com>
 
         Implement a keypath parser strictly following the specification

Modified: trunk/Source/WebKit/chromium/public/WebCache.h (93781 => 93782)


--- trunk/Source/WebKit/chromium/public/WebCache.h	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebKit/chromium/public/WebCache.h	2011-08-25 14:37:21 UTC (rev 93782)
@@ -71,9 +71,14 @@
                                             size_t capacity);
 
     // Clears the cache (as much as possible; some resources may not be
-    // cleared if they are actively referenced).
+    // cleared if they are actively referenced). Note that this method
+    // only removes resources from live list, w/o releasing cache memory.
     WEBKIT_EXPORT static void clear();
 
+    // Prunes resource cache. Destroys decoded images data and returns
+    // memory to the system.
+    WEBKIT_EXPORT static void prune();
+
     // Gets the usage statistics from the resource cache.
     WEBKIT_EXPORT static void getUsageStats(UsageStats*);
 

Modified: trunk/Source/WebKit/chromium/public/WebFontCache.h (93781 => 93782)


--- trunk/Source/WebKit/chromium/public/WebFontCache.h	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebKit/chromium/public/WebFontCache.h	2011-08-25 14:37:21 UTC (rev 93782)
@@ -47,6 +47,9 @@
     // Clears the cache.
     WEBKIT_EXPORT static void clear();
 
+    // Purges inactive font data.
+    WEBKIT_EXPORT static void prune();
+
 private:
     WebFontCache();  // Not intended to be instanced.
 };

Modified: trunk/Source/WebKit/chromium/src/WebCache.cpp (93781 => 93782)


--- trunk/Source/WebKit/chromium/src/WebCache.cpp	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebKit/chromium/src/WebCache.cpp	2011-08-25 14:37:21 UTC (rev 93782)
@@ -66,12 +66,17 @@
 void WebCache::clear()
 {
     MemoryCache* cache = WebCore::memoryCache();
-    if (cache && !cache->disabled()) {
-        cache->setDisabled(true);
-        cache->setDisabled(false);
-    }
+    if (cache)
+        cache->evictResources();
 }
 
+void WebCache::prune()
+{
+    MemoryCache* cache = WebCore::memoryCache();
+    if (cache)
+        cache->prune();
+}
+
 void WebCache::getUsageStats(UsageStats* result)
 {
     ASSERT(result);

Modified: trunk/Source/WebKit/chromium/src/WebFontCache.cpp (93781 => 93782)


--- trunk/Source/WebKit/chromium/src/WebFontCache.cpp	2011-08-25 13:08:05 UTC (rev 93781)
+++ trunk/Source/WebKit/chromium/src/WebFontCache.cpp	2011-08-25 14:37:21 UTC (rev 93782)
@@ -55,4 +55,10 @@
     fontCache()->invalidate();
 }
 
+// static
+void WebFontCache::prune()
+{
+    fontCache()->purgeInactiveFontData();
+}
+
 }  // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to