Title: [123385] trunk/Source/WebCore
Revision
123385
Author
[email protected]
Date
2012-07-23 14:38:06 -0700 (Mon, 23 Jul 2012)

Log Message

Destroy CSS decoded data more eagerly once they become dead caches.
https://bugs.webkit.org/show_bug.cgi?id=91733

Patch by Huang Dongsung <[email protected]> on 2012-07-23
Reviewed by Geoffrey Garen.

Internal review by Kwang Yul Seo.

There are three CachedResources with decoded data: CachedImage, CachedScript
and CachedCSSStyleSheet. In the cases of CachedImage and CachedScript, we
eagerly destroy the decoded data using Timer in CacehdResource::allClientsRemoved().
We must apply the same policy here in CachedCSSStyleSheet because priority
inversion can occur. For example, we can't destroy the decoded data of CachedImages
when they are referenced by CachedCSSStyleSheet as background, mask or border
images.

No new tests - no new testable functionality.

* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):
(WebCore::CachedCSSStyleSheet::didAddClient):
(WebCore::CachedCSSStyleSheet::allClientsRemoved):
(WebCore::CachedCSSStyleSheet::destroyDecodedData):
(WebCore):
(WebCore::CachedCSSStyleSheet::decodedDataDeletionTimerFired):
* loader/cache/CachedCSSStyleSheet.h:
(CachedCSSStyleSheet):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123384 => 123385)


--- trunk/Source/WebCore/ChangeLog	2012-07-23 21:24:22 UTC (rev 123384)
+++ trunk/Source/WebCore/ChangeLog	2012-07-23 21:38:06 UTC (rev 123385)
@@ -1,3 +1,32 @@
+2012-07-23  Huang Dongsung  <[email protected]>
+
+        Destroy CSS decoded data more eagerly once they become dead caches.
+        https://bugs.webkit.org/show_bug.cgi?id=91733
+
+        Reviewed by Geoffrey Garen.
+
+        Internal review by Kwang Yul Seo.
+
+        There are three CachedResources with decoded data: CachedImage, CachedScript
+        and CachedCSSStyleSheet. In the cases of CachedImage and CachedScript, we
+        eagerly destroy the decoded data using Timer in CacehdResource::allClientsRemoved().
+        We must apply the same policy here in CachedCSSStyleSheet because priority
+        inversion can occur. For example, we can't destroy the decoded data of CachedImages
+        when they are referenced by CachedCSSStyleSheet as background, mask or border
+        images.
+
+        No new tests - no new testable functionality.
+
+        * loader/cache/CachedCSSStyleSheet.cpp:
+        (WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):
+        (WebCore::CachedCSSStyleSheet::didAddClient):
+        (WebCore::CachedCSSStyleSheet::allClientsRemoved):
+        (WebCore::CachedCSSStyleSheet::destroyDecodedData):
+        (WebCore):
+        (WebCore::CachedCSSStyleSheet::decodedDataDeletionTimerFired):
+        * loader/cache/CachedCSSStyleSheet.h:
+        (CachedCSSStyleSheet):
+
 2012-07-23  Simon Fraser  <[email protected]>
 
         Part 2 of: Implement sticky positioning

Modified: trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp (123384 => 123385)


--- trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp	2012-07-23 21:24:22 UTC (rev 123384)
+++ trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp	2012-07-23 21:38:06 UTC (rev 123385)
@@ -43,6 +43,7 @@
 CachedCSSStyleSheet::CachedCSSStyleSheet(const ResourceRequest& resourceRequest, const String& charset)
     : CachedResource(resourceRequest, CSSStyleSheet)
     , m_decoder(TextResourceDecoder::create("text/css", charset))
+    , m_decodedDataDeletionTimer(this, &CachedCSSStyleSheet::decodedDataDeletionTimerFired)
 {
     // Prefer text/css but accept any type (dell.com serves a stylesheet
     // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>).
@@ -58,14 +59,17 @@
 void CachedCSSStyleSheet::didAddClient(CachedResourceClient* c)
 {
     ASSERT(c->resourceClientType() == CachedStyleSheetClient::expectedType());
+    if (m_decodedDataDeletionTimer.isActive())
+        m_decodedDataDeletionTimer.stop();
+
     if (!isLoading())
         static_cast<CachedStyleSheetClient*>(c)->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this);
 }
 
 void CachedCSSStyleSheet::allClientsRemoved()
 {
-    if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
-        makePurgeable(true);
+    if (double interval = memoryCache()->deadDecodedDataDeletionInterval())
+        m_decodedDataDeletionTimer.startOneShot(interval);
 }
 
 void CachedCSSStyleSheet::setEncoding(const String& chs)
@@ -163,8 +167,16 @@
     m_parsedStyleSheetCache.clear();
 
     setDecodedSize(0);
+
+    if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
+        makePurgeable(true);
 }
 
+void CachedCSSStyleSheet::decodedDataDeletionTimerFired(Timer<CachedCSSStyleSheet>*)
+{
+    destroyDecodedData();
+}
+
 PassRefPtr<StyleSheetContents> CachedCSSStyleSheet::restoreParsedStyleSheet(const CSSParserContext& context)
 {
     if (!m_parsedStyleSheetCache)

Modified: trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.h (123384 => 123385)


--- trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.h	2012-07-23 21:24:22 UTC (rev 123384)
+++ trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.h	2012-07-23 21:38:06 UTC (rev 123385)
@@ -27,6 +27,7 @@
 #define CachedCSSStyleSheet_h
 
 #include "CachedResource.h"
+#include "Timer.h"
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -61,12 +62,14 @@
         void saveParsedStyleSheet(PassRefPtr<StyleSheetContents>);
     
     private:
+        void decodedDataDeletionTimerFired(Timer<CachedCSSStyleSheet>*);
         bool canUseSheet(bool enforceMIMEType, bool* hasValidMIMEType) const;
         virtual PurgePriority purgePriority() const { return PurgeLast; }
 
     protected:
         RefPtr<TextResourceDecoder> m_decoder;
         String m_decodedSheetText;
+        Timer<CachedCSSStyleSheet> m_decodedDataDeletionTimer;
 
         RefPtr<StyleSheetContents> m_parsedStyleSheetCache;
     };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to