Use DeferrableOneShotTimer for deleting decoded data
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jul 2013 13:27:28 +0000 (13:27 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jul 2013 13:27:28 +0000 (13:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118150

Reviewed by Andreas Kling.

Adam Barth pointed out that the virtual function for overriding the default delay doesn't work
as expected from base class constructor.

* loader/cache/CachedResource.cpp:
(WebCore::deadDecodedDataDeletionIntervalForResourceType):
(WebCore::CachedResource::CachedResource):

    Use static function instead of calling a virtual.

* loader/cache/CachedResource.h:
* loader/cache/CachedScript.cpp:
* loader/cache/CachedScript.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152219 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedScript.cpp
Source/WebCore/loader/cache/CachedScript.h

index e17a1c0..f46caaa 100644 (file)
@@ -1,4 +1,25 @@
-2013-07-01  Kangil Han  <kangil.han@samsung.com>
+2013-07-01  Antti Koivisto  <antti@apple.com>
+
+        Use DeferrableOneShotTimer for deleting decoded data
+        https://bugs.webkit.org/show_bug.cgi?id=118150
+
+        Reviewed by Andreas Kling.
+
+        Adam Barth pointed out that the virtual function for overriding the default delay doesn't work
+        as expected from base class constructor.
+
+        * loader/cache/CachedResource.cpp:
+        (WebCore::deadDecodedDataDeletionIntervalForResourceType):
+        (WebCore::CachedResource::CachedResource):
+        
+            Use static function instead of calling a virtual.
+
+        * loader/cache/CachedResource.h:
+        * loader/cache/CachedScript.cpp:
+        * loader/cache/CachedScript.h:
+
+2013-07-01  Kangil Han  <k
+angil.han@samsung.com>
 
         Adopt toHTMLTextAreaElement for code cleanup
         https://bugs.webkit.org/show_bug.cgi?id=118226
index 8789f74..8b3cddb 100644 (file)
@@ -182,13 +182,20 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource
 }
 #endif
 
+static double deadDecodedDataDeletionIntervalForResourceType(CachedResource::Type type)
+{
+    if (type == CachedResource::Script)
+        return 0;
+    return memoryCache()->deadDecodedDataDeletionInterval();
+}
+
 DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, ("CachedResource"));
 
 CachedResource::CachedResource(const ResourceRequest& request, Type type)
     : m_resourceRequest(request)
     , m_loadPriority(defaultPriorityForResourceType(type))
     , m_responseTimestamp(currentTime())
-    , m_decodedDataDeletionTimer(this, &CachedResource::decodedDataDeletionTimerFired, decodedDataDeletionTimerDelay())
+    , m_decodedDataDeletionTimer(this, &CachedResource::decodedDataDeletionTimerFired, deadDecodedDataDeletionIntervalForResourceType(type))
     , m_lastDecodedAccessTime(0)
     , m_loadFinishTime(0)
     , m_encodedSize(0)
@@ -888,11 +895,6 @@ void CachedResource::setLoadPriority(ResourceLoadPriority loadPriority)
         m_loader->didChangePriority(loadPriority);
 }
 
-double CachedResource::decodedDataDeletionTimerDelay() const
-{
-    return memoryCache()->deadDecodedDataDeletionInterval();
-}
-
 CachedResource::CachedResourceCallback::CachedResourceCallback(CachedResource* resource, CachedResourceClient* client)
     : m_resource(resource)
     , m_client(client)
index 7d63d6f..18a4e65 100644 (file)
@@ -296,7 +296,6 @@ protected:
 private:
     bool addClientToSet(CachedResourceClient*);
 
-    virtual double decodedDataDeletionTimerDelay() const;
     void decodedDataDeletionTimerFired(DeferrableOneShotTimer<CachedResource>*);
 
     virtual PurgePriority purgePriority() const { return PurgeDefault; }
index 51a5bf7..4b2a8c8 100644 (file)
@@ -97,11 +97,6 @@ void CachedScript::destroyDecodedData()
         makePurgeable(true);
 }
 
-double CachedScript::decodedDataDeletionTimerDelay() const
-{
-    return 0;
-}
-
 #if ENABLE(NOSNIFF)
 bool CachedScript::mimeTypeAllowedByNosniff() const
 {
index 4ae3608..733b535 100644 (file)
@@ -57,7 +57,6 @@ namespace WebCore {
         virtual void finishLoading(ResourceBuffer*) OVERRIDE;
 
         virtual void destroyDecodedData() OVERRIDE;
-        virtual double decodedDataDeletionTimerDelay() const OVERRIDE;
 
         String m_script;
         RefPtr<TextResourceDecoder> m_decoder;