Change DeferrableOneShotTimer to use std::function instead of being a class template
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jun 2014 23:44:48 +0000 (23:44 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jun 2014 23:44:48 +0000 (23:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133423

Reviewed by Antti Koivisto.

Source/WebCore:
Also, add a new constructor to DeferrableOneShotTimer that takes an std::function. Change the callback
to not pass a DeferrableOneShotTimer& anymore. Change the delay parameter to use std::chrono::milliseconds.

* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage):
(WebCore::CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired):
* css/CSSImageGeneratorValue.h:
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::simulatedMouseClickTimerFired):
* html/HTMLPlugInImageElement.h:
* loader/cache/CachedResource.cpp:
(WebCore::deadDecodedDataDeletionIntervalForResourceType):
(WebCore::CachedResource::destroyDecodedDataIfNeeded):
(WebCore::CachedResource::decodedDataDeletionTimerFired):
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::MemoryCache):
* loader/cache/MemoryCache.h:
(WebCore::MemoryCache::setDeadDecodedDataDeletionInterval):
(WebCore::MemoryCache::deadDecodedDataDeletionInterval):
* platform/Timer.h:
(WebCore::Timer::Timer):
(WebCore::DeferrableOneShotTimer::DeferrableOneShotTimer):
* platform/graphics/cg/SubimageCacheWithTimer.cpp:
(WebCore::SubimageCacheWithTimer::invalidateCacheTimerFired):
* platform/graphics/cg/SubimageCacheWithTimer.h:

Source/WebKit/mac:
* WebView/WebView.mm:
(+[WebView _setCacheModel:]):

Source/WebKit2:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformSetCacheModel):
* Shared/CacheModel.cpp:
(WebKit::calculateCacheSizes):
* Shared/CacheModel.h:
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::pluginSnapshotTimerFired):
* WebProcess/Plugins/PluginView.h:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformSetCacheModel):

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

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSImageGeneratorValue.h
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/loader/cache/MemoryCache.h
Source/WebCore/platform/Timer.h
Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.cpp
Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.h
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
Source/WebKit2/Shared/CacheModel.cpp
Source/WebKit2/Shared/CacheModel.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h
Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm
Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp

index 41829a9..9367c96 100644 (file)
@@ -1,3 +1,37 @@
+2014-05-31  Anders Carlsson  <andersca@apple.com>
+
+        Change DeferrableOneShotTimer to use std::function instead of being a class template
+        https://bugs.webkit.org/show_bug.cgi?id=133423
+
+        Reviewed by Antti Koivisto.
+
+        Also, add a new constructor to DeferrableOneShotTimer that takes an std::function. Change the callback
+        to not pass a DeferrableOneShotTimer& anymore. Change the delay parameter to use std::chrono::milliseconds.
+
+        * css/CSSImageGeneratorValue.cpp:
+        (WebCore::CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage):
+        (WebCore::CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired):
+        * css/CSSImageGeneratorValue.h:
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::simulatedMouseClickTimerFired):
+        * html/HTMLPlugInImageElement.h:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::deadDecodedDataDeletionIntervalForResourceType):
+        (WebCore::CachedResource::destroyDecodedDataIfNeeded):
+        (WebCore::CachedResource::decodedDataDeletionTimerFired):
+        * loader/cache/CachedResource.h:
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::MemoryCache):
+        * loader/cache/MemoryCache.h:
+        (WebCore::MemoryCache::setDeadDecodedDataDeletionInterval):
+        (WebCore::MemoryCache::deadDecodedDataDeletionInterval):
+        * platform/Timer.h:
+        (WebCore::Timer::Timer):
+        (WebCore::DeferrableOneShotTimer::DeferrableOneShotTimer):
+        * platform/graphics/cg/SubimageCacheWithTimer.cpp:
+        (WebCore::SubimageCacheWithTimer::invalidateCacheTimerFired):
+        * platform/graphics/cg/SubimageCacheWithTimer.h:
+
 2014-06-02  Benjamin Poulain  <benjamin@webkit.org>
 
         Make pseudo element matching for style resolution more JIT friendly
index 0d9cfca..0525e41 100644 (file)
@@ -38,7 +38,7 @@
 
 namespace WebCore {
 
-static const double timeToKeepCachedGeneratedImagesInSeconds = 3;
+static const auto timeToKeepCachedGeneratedImages = std::chrono::seconds { 3 };
 
 CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType classType)
     : CSSValue(classType)
@@ -94,12 +94,12 @@ CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage(CSSImageGener
     : m_owner(owner)
     , m_size(size)
     , m_image(image)
-    , m_evictionTimer(this, &CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired, timeToKeepCachedGeneratedImagesInSeconds)
+    , m_evictionTimer(this, &CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired, timeToKeepCachedGeneratedImages)
 {
     m_evictionTimer.restart();
 }
 
-void CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired(DeferrableOneShotTimer<CachedGeneratedImage>&)
+void CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired()
 {
     // NOTE: This is essentially a "delete this", the object is no longer valid after this line.
     m_owner.evictCachedGeneratedImage(m_size);
index f4ab5d8..63c8137 100644 (file)
@@ -77,12 +77,12 @@ private:
         void puntEvictionTimer() { m_evictionTimer.restart(); }
 
     private:
-        void evictionTimerFired(DeferrableOneShotTimer<CachedGeneratedImage>&);
+        void evictionTimerFired();
 
         CSSImageGeneratorValue& m_owner;
         FloatSize m_size;
         RefPtr<GeneratedImage> m_image;
-        DeferrableOneShotTimer<CachedGeneratedImage> m_evictionTimer;
+        DeferrableOneShotTimer m_evictionTimer;
     };
 
     friend class CachedGeneratedImage;
index 66d49b6..d368186 100644 (file)
@@ -67,8 +67,8 @@ static const float sizingFullPageAreaRatioThreshold = 0.96;
 static const float autostartSoonAfterUserGestureThreshold = 5.0;
 
 // This delay should not exceed the snapshot delay in PluginView.cpp
-static const double simulatedMouseClickTimerDelay = .75;
-static const double removeSnapshotTimerDelay = 1.5;
+static const auto simulatedMouseClickTimerDelay = std::chrono::milliseconds { 750 };
+static const auto removeSnapshotTimerDelay = std::chrono::milliseconds { 1500 };
 
 static const String titleText(Page* page, String mimeType)
 {
@@ -509,7 +509,7 @@ void HTMLPlugInImageElement::dispatchPendingMouseClick()
     m_simulatedMouseClickTimer.restart();
 }
 
-void HTMLPlugInImageElement::simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>&)
+void HTMLPlugInImageElement::simulatedMouseClickTimerFired()
 {
     ASSERT(displayState() == RestartingWithPendingMouseClick);
     ASSERT(m_pendingClickEventFromSnapshot);
index ea83cd5..3645483 100644 (file)
@@ -133,7 +133,7 @@ private:
     void startLoadingImage();
     void updateWidgetIfNecessary();
 
-    void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>&);
+    void simulatedMouseClickTimerFired();
 
     void restartSimilarPlugIns();
     void removeSnapshotTimerFired(Timer<HTMLPlugInImageElement>&);
@@ -144,7 +144,7 @@ private:
     bool m_shouldPreferPlugInsForImages;
     bool m_needsDocumentActivationCallbacks;
     RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
-    DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
+    DeferrableOneShotTimer m_simulatedMouseClickTimer;
     Timer<HTMLPlugInImageElement> m_removeSnapshotTimer;
     RefPtr<Image> m_snapshotImage;
     bool m_createdDuringUserGesture;
index f03a3e5..49efe16 100644 (file)
@@ -138,10 +138,11 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type
     return ResourceLoadPriorityLow;
 }
 
-static double deadDecodedDataDeletionIntervalForResourceType(CachedResource::Type type)
+static std::chrono::milliseconds deadDecodedDataDeletionIntervalForResourceType(CachedResource::Type type)
 {
     if (type == CachedResource::Script)
-        return 0;
+        return std::chrono::milliseconds { 0 };
+
     return memoryCache()->deadDecodedDataDeletionInterval();
 }
 
@@ -530,12 +531,12 @@ void CachedResource::destroyDecodedDataIfNeeded()
 {
     if (!m_decodedSize)
         return;
-    if (!memoryCache()->deadDecodedDataDeletionInterval())
+    if (!memoryCache()->deadDecodedDataDeletionInterval().count())
         return;
     m_decodedDataDeletionTimer.restart();
 }
 
-void CachedResource::decodedDataDeletionTimerFired(DeferrableOneShotTimer<CachedResource>&)
+void CachedResource::decodedDataDeletionTimerFired()
 {
     destroyDecodedData();
 }
index 9f8d1d7..c440948 100644 (file)
@@ -303,12 +303,12 @@ protected:
 
     RefPtr<ResourceBuffer> m_data;
     OwnPtr<PurgeableBuffer> m_purgeableData;
-    DeferrableOneShotTimer<CachedResource> m_decodedDataDeletionTimer;
+    DeferrableOneShotTimer m_decodedDataDeletionTimer;
 
 private:
     bool addClientToSet(CachedResourceClient*);
 
-    void decodedDataDeletionTimerFired(DeferrableOneShotTimer<CachedResource>&);
+    void decodedDataDeletionTimerFired();
 
     virtual PurgePriority purgePriority() const { return PurgeDefault; }
     virtual bool mayTryReplaceEncodedData() const { return false; }
index 928d2ee..d32badf 100644 (file)
@@ -58,7 +58,7 @@ 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;
+static const auto defaultDecodedDataDeletionInterval = std::chrono::seconds { 0 };
 
 MemoryCache* memoryCache()
 {
@@ -75,7 +75,7 @@ MemoryCache::MemoryCache()
     , m_capacity(cDefaultCacheCapacity)
     , m_minDeadCapacity(0)
     , m_maxDeadCapacity(cDefaultCacheCapacity)
-    , m_deadDecodedDataDeletionInterval(cDefaultDecodedDataDeletionInterval)
+    , m_deadDecodedDataDeletionInterval(defaultDecodedDataDeletionInterval)
     , m_liveSize(0)
     , m_deadSize(0)
 {
index c218fe9..b6bc8a1 100644 (file)
@@ -150,8 +150,8 @@ public:
     void prune();
     void pruneToPercentage(float targetPercentLive);
 
-    void setDeadDecodedDataDeletionInterval(double interval) { m_deadDecodedDataDeletionInterval = interval; }
-    double deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
+    void setDeadDecodedDataDeletionInterval(std::chrono::milliseconds interval) { m_deadDecodedDataDeletionInterval = interval; }
+    std::chrono::milliseconds deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
 
     // Calls to put the cached resource into and out of LRU lists.
     void insertInLRUList(CachedResource*);
@@ -240,7 +240,7 @@ private:
     unsigned m_capacity;
     unsigned m_minDeadCapacity;
     unsigned m_maxDeadCapacity;
-    double m_deadDecodedDataDeletionInterval;
+    std::chrono::milliseconds 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.
index ff2aeeb..b9efae2 100644 (file)
@@ -117,7 +117,7 @@ public:
     typedef void (TimerFiredClass::*TimerFiredFunction)(Timer&);
     typedef void (TimerFiredClass::*DeprecatedTimerFiredFunction)(Timer*);
 
-    Timer(TimerFiredClass* object , TimerFiredFunction function)
+    Timer(TimerFiredClass* object, TimerFiredFunction function)
         : m_function(std::bind(function, object, std::ref(*this)))
     {
     }
@@ -147,13 +147,16 @@ inline bool TimerBase::isActive() const
     return m_nextFireTime;
 }
 
-template <typename TimerFiredClass> class DeferrableOneShotTimer : protected TimerBase {
+class DeferrableOneShotTimer : protected TimerBase {
 public:
-    typedef void (TimerFiredClass::*TimerFiredFunction)(DeferrableOneShotTimer&);
+    template<typename TimerFiredClass>
+    DeferrableOneShotTimer(TimerFiredClass* object, void (TimerFiredClass::*function)(), std::chrono::milliseconds delay)
+        : DeferrableOneShotTimer(std::bind(function, object), delay)
+    {
+    }
 
-    DeferrableOneShotTimer(TimerFiredClass* object, TimerFiredFunction function, double delay)
-        : m_object(object)
-        , m_function(function)
+    DeferrableOneShotTimer(std::function<void ()> function, std::chrono::milliseconds delay)
+        : m_function(std::move(function))
         , m_delay(delay)
         , m_shouldRestartWhenTimerFires(false)
     {
@@ -189,13 +192,12 @@ private:
             return;
         }
 
-        (m_object->*m_function)(*this);
+        m_function();
     }
 
-    TimerFiredClass* m_object;
-    TimerFiredFunction m_function;
+    std::function<void ()> m_function;
 
-    double m_delay;
+    std::chrono::milliseconds m_delay;
     bool m_shouldRestartWhenTimerFires;
 };
 
index be30403..86714e3 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-static const double subimageCacheClearDelay = 1;
+static const auto subimageCacheClearDelay = std::chrono::seconds { 1 };
 static const int maxSubimageCacheSize = 300;
 
 struct SubimageRequest {
@@ -65,7 +65,7 @@ SubimageCacheWithTimer::SubimageCacheWithTimer()
 {
 }
 
-void SubimageCacheWithTimer::invalidateCacheTimerFired(DeferrableOneShotTimer<SubimageCacheWithTimer>&)
+void SubimageCacheWithTimer::invalidateCacheTimerFired()
 {
     m_images.clear();
     m_cache.clear();
index b54cd42..9033e79 100644 (file)
@@ -88,11 +88,11 @@ public:
     void clearImage(CGImageRef);
 
 private:
-    void invalidateCacheTimerFired(DeferrableOneShotTimer<SubimageCacheWithTimer>&);
+    void invalidateCacheTimerFired();
 
     HashCountedSet<CGImageRef> m_images;
     SubimageCache m_cache;
-    DeferrableOneShotTimer<SubimageCacheWithTimer> m_timer;
+    DeferrableOneShotTimer m_timer;
 };
 
 SubimageCacheWithTimer& subimageCache();
index fce2dae..967f817 100644 (file)
@@ -409,7 +409,7 @@ size_t DumpRenderTreeSupportEfl::javaScriptObjectsCount()
 
 void DumpRenderTreeSupportEfl::setDeadDecodedDataDeletionInterval(double interval)
 {
-    WebCore::memoryCache()->setDeadDecodedDataDeletionInterval(interval);
+    WebCore::memoryCache()->setDeadDecodedDataDeletionInterval(std::chrono::milliseconds { static_cast<std::chrono::milliseconds::rep>(interval * 1000) });
 }
 
 HistoryItemChildrenVector DumpRenderTreeSupportEfl::childHistoryItems(const Ewk_History_Item* ewkHistoryItem)
index f92f607..3c4a6df 100644 (file)
@@ -1,3 +1,13 @@
+2014-05-31  Anders Carlsson  <andersca@apple.com>
+
+        Change DeferrableOneShotTimer to use std::function instead of being a class template
+        https://bugs.webkit.org/show_bug.cgi?id=133423
+
+        Reviewed by Antti Koivisto.
+
+        * WebView/WebView.mm:
+        (+[WebView _setCacheModel:]):
+
 2014-05-27  Jon Lee  <jonlee@apple.com>
 
         Update ENABLE(MEDIA_SOURCE) on Mac
index 584f5b1..25a6f7f 100644 (file)
@@ -7708,7 +7708,7 @@ static inline uint64_t roundUpToPowerOf2(uint64_t num)
     unsigned cacheTotalCapacity = 0;
     unsigned cacheMinDeadCapacity = 0;
     unsigned cacheMaxDeadCapacity = 0;
-    double deadDecodedDataDeletionInterval = 0;
+    auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 };
 
     unsigned pageCacheCapacity = 0;
 
@@ -7863,7 +7863,7 @@ static inline uint64_t roundUpToPowerOf2(uint64_t num)
         // can prove that the overall system gain would justify the regression.
         cacheMaxDeadCapacity = std::max<unsigned>(24, cacheMaxDeadCapacity);
 
-        deadDecodedDataDeletionInterval = 60;
+        deadDecodedDataDeletionInterval = std::chrono::seconds { 60 };
 
 #if PLATFORM(IOS)
         if (memSize >= 1024)
index aa1947f..fc64ff1 100644 (file)
@@ -504,7 +504,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
     unsigned cacheTotalCapacity = 0;
     unsigned cacheMinDeadCapacity = 0;
     unsigned cacheMaxDeadCapacity = 0;
-    double deadDecodedDataDeletionInterval = 0;
+    auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 };
 
     unsigned pageCacheCapacity = 0;
 
@@ -617,7 +617,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
         // can prove that the overall system gain would justify the regression.
         cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity);
 
-        deadDecodedDataDeletionInterval = 60;
+        deadDecodedDataDeletionInterval = std::chrono::seconds { 60 };
 
         // Foundation memory cache capacity (in bytes)
         // (These values are small because WebCore does most caching itself.)
index c1b6c6b..f3891a5 100644 (file)
@@ -1,3 +1,21 @@
+2014-05-31  Anders Carlsson  <andersca@apple.com>
+
+        Change DeferrableOneShotTimer to use std::function instead of being a class template
+        https://bugs.webkit.org/show_bug.cgi?id=133423
+
+        Reviewed by Antti Koivisto.
+
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::platformSetCacheModel):
+        * Shared/CacheModel.cpp:
+        (WebKit::calculateCacheSizes):
+        * Shared/CacheModel.h:
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::pluginSnapshotTimerFired):
+        * WebProcess/Plugins/PluginView.h:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformSetCacheModel):
+
 2014-06-02  Benjamin Poulain  <bpoulain@apple.com>
 
         [iOS][WK2] Round the UIScrollView content size to device pixel
index 9f4f239..9f8c28c 100644 (file)
@@ -122,7 +122,7 @@ void NetworkProcess::platformSetCacheModel(CacheModel cacheModel)
     unsigned cacheTotalCapacity = 0;
     unsigned cacheMinDeadCapacity = 0;
     unsigned cacheMaxDeadCapacity = 0;
-    double deadDecodedDataDeletionInterval = 0;
+    auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 };
     unsigned pageCacheCapacity = 0;
     unsigned long urlCacheMemoryCapacity = 0;
     unsigned long urlCacheDiskCapacity = 0;
index 6207f8e..1bb8352 100644 (file)
@@ -104,7 +104,7 @@ void NetworkProcess::platformSetCacheModel(CacheModel cacheModel)
     unsigned cacheTotalCapacity = 0;
     unsigned cacheMinDeadCapacity = 0;
     unsigned cacheMaxDeadCapacity = 0;
-    double deadDecodedDataDeletionInterval = 0;
+    auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 };
     unsigned pageCacheCapacity = 0;
 
     unsigned long urlCacheMemoryCapacity = 0;
index 346e3c0..a204184 100644 (file)
@@ -31,7 +31,7 @@
 namespace WebKit {
 
 void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
-    unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
+    unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval,
     unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity)
 {
     switch (cacheModel) {
@@ -137,7 +137,7 @@ void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t di
         // can prove that the overall system gain would justify the regression.
         cacheMaxDeadCapacity = std::max(24u, cacheMaxDeadCapacity);
 
-        deadDecodedDataDeletionInterval = 60;
+        deadDecodedDataDeletionInterval = std::chrono::seconds { 60 };
 
 #if PLATFORM(IOS)
         if (memorySize >= 1024)
index fe8c9bb..34ddd04 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef CacheModel_h
 #define CacheModel_h
 
+#include <chrono>
 #include <stdint.h>
 
 namespace WebKit {
@@ -37,7 +38,7 @@ enum CacheModel {
 };
 
 void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
-    unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
+    unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval,
     unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity);
 
 } // namespace WebKit
index 45a6f79..b05df82 100644 (file)
@@ -77,7 +77,7 @@ using namespace WebCore;
 namespace WebKit {
 
 // This simulated mouse click delay in HTMLPlugInImageElement.cpp should generally be the same or shorter than this delay.
-static const double pluginSnapshotTimerDelay = 1.1;
+static const auto pluginSnapshotTimerDelay = std::chrono::milliseconds { 1100 };
 
 class PluginView::URLRequest : public RefCounted<URLRequest> {
 public:
@@ -1679,7 +1679,7 @@ static bool isAlmostSolidColor(BitmapImage* bitmap)
 }
 #endif
 
-void PluginView::pluginSnapshotTimerFired(DeferrableOneShotTimer<PluginView>&)
+void PluginView::pluginSnapshotTimerFired()
 {
     ASSERT(m_plugin);
 
index 4df5bdd..6250c98 100644 (file)
@@ -138,7 +138,7 @@ private:
 
     void redeliverManualStream();
 
-    void pluginSnapshotTimerFired(WebCore::DeferrableOneShotTimer<PluginView>&);
+    void pluginSnapshotTimerFired();
     void pluginDidReceiveUserInteraction();
 
     bool shouldCreateTransientPaintingSnapshot() const;
@@ -270,7 +270,7 @@ private:
     // This snapshot is used to avoid side effects should the plugin run JS during painting.
     RefPtr<ShareableBitmap> m_transientPaintingSnapshot;
     // This timer is used when plugin snapshotting is enabled, to capture a plugin placeholder.
-    WebCore::DeferrableOneShotTimer<PluginView> m_pluginSnapshotTimer;
+    WebCore::DeferrableOneShotTimer m_pluginSnapshotTimer;
     unsigned m_countSnapshotRetries;
     bool m_didReceiveUserInteraction;
 
index cd6aa76..6cedbb6 100644 (file)
@@ -104,7 +104,7 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
     unsigned cacheTotalCapacity = 0;
     unsigned cacheMinDeadCapacity = 0;
     unsigned cacheMaxDeadCapacity = 0;
-    double deadDecodedDataDeletionInterval = 0;
+    auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 };
     unsigned pageCacheCapacity = 0;
     unsigned long urlCacheMemoryCapacity = 0;
     unsigned long urlCacheDiskCapacity = 0;
index edb4a28..a86cdc8 100644 (file)
@@ -86,7 +86,7 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
     unsigned cacheTotalCapacity = 0;
     unsigned cacheMinDeadCapacity = 0;
     unsigned cacheMaxDeadCapacity = 0;
-    double deadDecodedDataDeletionInterval = 0;
+    auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 };
     unsigned pageCacheCapacity = 0;
 
     unsigned long urlCacheMemoryCapacity = 0;