RefCounter<T>::Event -> RefCounterEvent
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Feb 2016 18:55:21 +0000 (18:55 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Feb 2016 18:55:21 +0000 (18:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154767

Reviewed by Darin Adler.

RefCounter<T>::Event is kinda verbose to use, and there is no need for this
to be specific to a particular typeof RefCounter. Move the enum class up to
the top level & rename to RefCounterEvent.

Source/WebCore:

* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
(WebCore::m_audiblePluginHysteresis):
(WebCore::m_mediaActivityCounter):
(WebCore::m_pageLoadActivityCounter):
* platform/VNodeTracker.cpp:
(WebCore::VNodeTracker::singleton):
(WebCore::VNodeTracker::VNodeTracker):
(WebCore::m_lastWarningTime):

Source/WebKit2:

Also remove UserObservablePageToken - this is vestigial & not really offering
anything over just using UserObservablePageCounter::Token directly.

* UIProcess/Plugins/PluginProcessManager.cpp:
(WebKit::PluginProcessManager::PluginProcessManager):
* UIProcess/Plugins/PluginProcessManager.h:
* UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
(WebKit::PluginProcessManager::updateProcessSuppressionDisabled):
* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::ProcessThrottler):
(WebKit::m_backgroundCounter):
(WebKit::m_suspendMessageCount):
* UIProcess/ProcessThrottler.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::WebProcessPool):
(WebKit::m_processSuppressionDisabledForPageCounter):
(WebKit::m_hiddenPageThrottlingAutoIncreasesCounter):
* UIProcess/WebProcessPool.h:

Source/WTF:

* wtf/RefCounter.h:
(WTF::RefCounter<T>::Count::ref):
(WTF::RefCounter<T>::Count::deref):

Tools:

* TestWebKitAPI/Tests/WTF/RefCounter.cpp:
(TestWebKitAPI::TEST):

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

16 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/RefCounter.h
Source/WebCore/ChangeLog
Source/WebCore/page/PageThrottler.cpp
Source/WebCore/platform/VNodeTracker.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp
Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h
Source/WebKit2/UIProcess/Plugins/mac/PluginProcessManagerMac.mm
Source/WebKit2/UIProcess/ProcessThrottler.cpp
Source/WebKit2/UIProcess/ProcessThrottler.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/RefCounter.cpp

index c21e39b..d2a4462 100644 (file)
@@ -1,3 +1,18 @@
+2016-02-29  Gavin Barraclough  <barraclough@apple.com>
+
+        RefCounter<T>::Event -> RefCounterEvent
+        https://bugs.webkit.org/show_bug.cgi?id=154767
+
+        Reviewed by Darin Adler.
+
+        RefCounter<T>::Event is kinda verbose to use, and there is no need for this
+        to be specific to a particular typeof RefCounter. Move the enum class up to
+        the top level & rename to RefCounterEvent.
+
+        * wtf/RefCounter.h:
+        (WTF::RefCounter<T>::Count::ref):
+        (WTF::RefCounter<T>::Count::deref):
+
 2016-02-26  Oliver Hunt  <oliver@apple.com>
 
         Remove the on demand executable allocator
index ec959f7..b1aad56 100644 (file)
@@ -32,6 +32,8 @@
 
 namespace WTF {
 
+enum class RefCounterEvent { Decrement, Increment };
+
 template<typename T>
 class RefCounter {
     WTF_MAKE_NONCOPYABLE(RefCounter);
@@ -57,8 +59,7 @@ class RefCounter {
 
 public:
     using Token = RefPtr<Count>;
-    enum class Event { Decrement, Increment };
-    using ValueChangeFunction = std::function<void (Event)>;
+    using ValueChangeFunction = std::function<void (RefCounterEvent)>;
 
     RefCounter(ValueChangeFunction = nullptr);
     ~RefCounter();
@@ -83,7 +84,7 @@ inline void RefCounter<T>::Count::ref()
 {
     ++m_value;
     if (m_refCounter && m_refCounter->m_valueDidChange)
-        m_refCounter->m_valueDidChange(Event::Increment);
+        m_refCounter->m_valueDidChange(RefCounterEvent::Increment);
 }
 
 template<typename T>
@@ -93,7 +94,7 @@ inline void RefCounter<T>::Count::deref()
 
     --m_value;
     if (m_refCounter && m_refCounter->m_valueDidChange)
-        m_refCounter->m_valueDidChange(Event::Decrement);
+        m_refCounter->m_valueDidChange(RefCounterEvent::Decrement);
 
     // The Count object is kept alive so long as either the RefCounter that created it remains
     // allocated, or so long as its reference count is non-zero.
@@ -126,5 +127,6 @@ inline RefCounter<T>::~RefCounter()
 } // namespace WTF
 
 using WTF::RefCounter;
+using WTF::RefCounterEvent;
 
 #endif // RefCounter_h
index bd69987..c12d67e 100644 (file)
@@ -1,3 +1,24 @@
+2016-02-29  Gavin Barraclough  <barraclough@apple.com>
+
+        RefCounter<T>::Event -> RefCounterEvent
+        https://bugs.webkit.org/show_bug.cgi?id=154767
+
+        Reviewed by Darin Adler.
+
+        RefCounter<T>::Event is kinda verbose to use, and there is no need for this
+        to be specific to a particular typeof RefCounter. Move the enum class up to
+        the top level & rename to RefCounterEvent.
+
+        * page/PageThrottler.cpp:
+        (WebCore::PageThrottler::PageThrottler):
+        (WebCore::m_audiblePluginHysteresis):
+        (WebCore::m_mediaActivityCounter):
+        (WebCore::m_pageLoadActivityCounter):
+        * platform/VNodeTracker.cpp:
+        (WebCore::VNodeTracker::singleton):
+        (WebCore::VNodeTracker::VNodeTracker):
+        (WebCore::m_lastWarningTime):
+
 2016-02-29  Chris Dumez  <cdumez@apple.com>
 
         Use HTML parsing rules for textarea.maxLength
index 1be4164..24545d8 100644 (file)
@@ -34,8 +34,8 @@ PageThrottler::PageThrottler(Page& page)
     : m_page(page)
     , m_userInputHysteresis([this](HysteresisState state) { setActivityFlag(PageActivityState::UserInputActivity, state == HysteresisState::Started); })
     , m_audiblePluginHysteresis([this](HysteresisState state) { setActivityFlag(PageActivityState::AudiblePlugin, state == HysteresisState::Started); })
-    , m_mediaActivityCounter([this](PageActivityCounter::Event) { setActivityFlag(PageActivityState::MediaActivity, m_mediaActivityCounter.value()); })
-    , m_pageLoadActivityCounter([this](PageActivityCounter::Event) { setActivityFlag(PageActivityState::PageLoadActivity, m_pageLoadActivityCounter.value()); })
+    , m_mediaActivityCounter([this](RefCounterEvent) { setActivityFlag(PageActivityState::MediaActivity, m_mediaActivityCounter.value()); })
+    , m_pageLoadActivityCounter([this](RefCounterEvent) { setActivityFlag(PageActivityState::PageLoadActivity, m_pageLoadActivityCounter.value()); })
 {
 }
 
index 48b5531..364c705 100644 (file)
@@ -39,7 +39,7 @@ VNodeTracker& VNodeTracker::singleton()
 }
 
 VNodeTracker::VNodeTracker()
-    : m_vnodeCounter([this](VNodeCounter::Event event) { if (event == VNodeCounter::Event::Increment) checkPressureState(); })
+    : m_vnodeCounter([this](RefCounterEvent event) { if (event == RefCounterEvent::Increment) checkPressureState(); })
     , m_pressureWarningTimer(*this, &VNodeTracker::pressureWarningTimerFired)
     , m_lastWarningTime(std::chrono::steady_clock::now())
 {
index cf3dacb..728b708 100644 (file)
@@ -1,3 +1,34 @@
+2016-02-29  Gavin Barraclough  <barraclough@apple.com>
+
+        RefCounter<T>::Event -> RefCounterEvent
+        https://bugs.webkit.org/show_bug.cgi?id=154767
+
+        Reviewed by Darin Adler.
+
+        RefCounter<T>::Event is kinda verbose to use, and there is no need for this
+        to be specific to a particular typeof RefCounter. Move the enum class up to
+        the top level & rename to RefCounterEvent.
+
+        Also remove UserObservablePageToken - this is vestigial & not really offering
+        anything over just using UserObservablePageCounter::Token directly.
+
+        * UIProcess/Plugins/PluginProcessManager.cpp:
+        (WebKit::PluginProcessManager::PluginProcessManager):
+        * UIProcess/Plugins/PluginProcessManager.h:
+        * UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
+        (WebKit::PluginProcessManager::updateProcessSuppressionDisabled):
+        * UIProcess/ProcessThrottler.cpp:
+        (WebKit::ProcessThrottler::ProcessThrottler):
+        (WebKit::m_backgroundCounter):
+        (WebKit::m_suspendMessageCount):
+        * UIProcess/ProcessThrottler.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::WebProcessPool):
+        (WebKit::m_processSuppressionDisabledForPageCounter):
+        (WebKit::m_hiddenPageThrottlingAutoIncreasesCounter):
+        * UIProcess/WebProcessPool.h:
+
 2016-02-29  Konstantin Tokarev  <annulen@yandex.ru>
 
         Fixed compilation with !ENABLE(DATABASE_PROCESS).
index b6fc103..bd00bdc 100644 (file)
@@ -43,7 +43,7 @@ PluginProcessManager& PluginProcessManager::singleton()
 
 PluginProcessManager::PluginProcessManager()
 #if PLATFORM(COCOA)
-    : m_processSuppressionDisabledForPageCounter([this](ProcessSuppressionDisabledCounter::Event event) { updateProcessSuppressionDisabled(event); })
+    : m_processSuppressionDisabledForPageCounter([this](RefCounterEvent event) { updateProcessSuppressionDisabled(event); })
 #endif
 {
 }
index 27b8312..39410d8 100644 (file)
@@ -68,7 +68,7 @@ public:
 #if PLATFORM(COCOA)
     inline ProcessSuppressionDisabledToken processSuppressionDisabledToken();
     inline bool processSuppressionDisabled() const;
-    void updateProcessSuppressionDisabled(ProcessSuppressionDisabledCounter::Event);
+    void updateProcessSuppressionDisabled(RefCounterEvent);
 #endif
 
 private:
index 07a1a16..801abd2 100644 (file)
 
 namespace WebKit {
 
-void PluginProcessManager::updateProcessSuppressionDisabled(ProcessSuppressionDisabledCounter::Event event)
+void PluginProcessManager::updateProcessSuppressionDisabled(RefCounterEvent event)
 {
     size_t disableCount = m_processSuppressionDisabledForPageCounter.value();
 
     // We only care about zero/non-zero edge changes; ignore cases where the count was previously non-zero, and still is.
-    if (disableCount >= 2 || (disableCount == 1 && event == ProcessSuppressionDisabledCounter::Event::Decrement))
+    if (disableCount >= 2 || (disableCount == 1 && event == RefCounterEvent::Decrement))
         return;
-    ASSERT((event == ProcessSuppressionDisabledCounter::Event::Increment && disableCount == 1)
-        || (event == ProcessSuppressionDisabledCounter::Event::Decrement && !disableCount));
+    ASSERT((event == RefCounterEvent::Increment && disableCount == 1)
+        || (event == RefCounterEvent::Decrement && !disableCount));
 
     bool enabled = !disableCount;
     for (auto& pluginProcess : m_pluginProcesses)
index 2854b94..b8d39c6 100644 (file)
@@ -35,8 +35,8 @@ static const unsigned processSuspensionTimeout = 30;
 ProcessThrottler::ProcessThrottler(ProcessThrottlerClient& process)
     : m_process(process)
     , m_suspendTimer(RunLoop::main(), this, &ProcessThrottler::suspendTimerFired)
-    , m_foregroundCounter([this](ForegroundActivityCounter::Event) { updateAssertion(); })
-    , m_backgroundCounter([this](BackgroundActivityCounter::Event) { updateAssertion(); })
+    , m_foregroundCounter([this](RefCounterEvent) { updateAssertion(); })
+    , m_backgroundCounter([this](RefCounterEvent) { updateAssertion(); })
     , m_suspendMessageCount(0)
 {
 }
index fbc61f6..29f58a1 100644 (file)
@@ -36,7 +36,6 @@ namespace WebKit {
     
 enum UserObservablePageCounterType { };
 typedef RefCounter<UserObservablePageCounterType> UserObservablePageCounter;
-typedef UserObservablePageCounter::Token UserObservablePageToken;
 enum ProcessSuppressionDisabledCounterType { };
 typedef RefCounter<ProcessSuppressionDisabledCounterType> ProcessSuppressionDisabledCounter;
 typedef ProcessSuppressionDisabledCounter::Token ProcessSuppressionDisabledToken;
index bb95bff..be7c644 100644 (file)
@@ -1764,7 +1764,7 @@ private:
     std::unique_ptr<RemoteLayerTreeScrollingPerformanceData> m_scrollingPerformanceData;
     bool m_scrollPerformanceDataCollectionEnabled;
 #endif
-    UserObservablePageToken m_pageIsUserObservableCount;
+    UserObservablePageCounter::Token m_pageIsUserObservableCount;
     ProcessSuppressionDisabledToken m_preventProcessSuppressionCount;
     HiddenPageThrottlingAutoIncreasesCounter::Token m_hiddenPageDOMTimerThrottlingAutoIncreasesCount;
         
index 8d0c591..3c668c2 100644 (file)
@@ -158,9 +158,9 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
     , m_canHandleHTTPSServerTrustEvaluation(true)
     , m_didNetworkProcessCrash(false)
     , m_memoryCacheDisabled(false)
-    , m_userObservablePageCounter([this](UserObservablePageCounter::Event) { updateProcessSuppressionState(); })
-    , m_processSuppressionDisabledForPageCounter([this](ProcessSuppressionDisabledCounter::Event) { updateProcessSuppressionState(); })
-    , m_hiddenPageThrottlingAutoIncreasesCounter([this](HiddenPageThrottlingAutoIncreasesCounter::Event) { updateHiddenPageThrottlingAutoIncreaseLimit(); })
+    , m_userObservablePageCounter([this](RefCounterEvent) { updateProcessSuppressionState(); })
+    , m_processSuppressionDisabledForPageCounter([this](RefCounterEvent) { updateProcessSuppressionState(); })
+    , m_hiddenPageThrottlingAutoIncreasesCounter([this](RefCounterEvent) { updateHiddenPageThrottlingAutoIncreaseLimit(); })
 {
     for (auto& scheme : m_configuration->alwaysRevalidatedURLSchemes())
         m_schemesToRegisterAsAlwaysRevalidated.add(scheme);
index 24ab928..3761cc3 100644 (file)
@@ -339,7 +339,7 @@ public:
     void setMemoryCacheDisabled(bool);
     void setFontWhitelist(API::Array*);
 
-    UserObservablePageToken userObservablePageCount()
+    UserObservablePageCounter::Token userObservablePageCount()
     {
         return m_userObservablePageCounter.count();
     }
index 4b0b4ef..cf56f42 100644 (file)
@@ -1,3 +1,17 @@
+2016-02-29  Gavin Barraclough  <barraclough@apple.com>
+
+        RefCounter<T>::Event -> RefCounterEvent
+        https://bugs.webkit.org/show_bug.cgi?id=154767
+
+        Reviewed by Darin Adler.
+
+        RefCounter<T>::Event is kinda verbose to use, and there is no need for this
+        to be specific to a particular typeof RefCounter. Move the enum class up to
+        the top level & rename to RefCounterEvent.
+
+        * TestWebKitAPI/Tests/WTF/RefCounter.cpp:
+        (TestWebKitAPI::TEST):
+
 2016-02-29  Csaba OsztrogonĂ¡c  <ossy@webkit.org>
 
         Remove more LLVM related cruft
index ba4a335..4c0a14b 100644 (file)
@@ -80,11 +80,11 @@ TEST(WTF, RefCounter)
     {
         // Testing (1a) - Construction with a callback.
         TestCounter* counterPtr = nullptr;
-        TestCounter counter([&](TestCounter::Event event) {
+        TestCounter counter([&](RefCounterEvent event) {
             // Check that the callback is called at the expected times, and the correct number of times.
-            if (TestCounter::Event::Increment == event)
+            if (RefCounterEvent::Increment == event)
                 EXPECT_EQ(callbackValue, IncrementExpected);
-            if (TestCounter::Event::Decrement == event)
+            if (RefCounterEvent::Decrement == event)
                 EXPECT_EQ(callbackValue, DecrementExpected);
             // return the value of the counter in the callback.
             callbackValue = counterPtr->value();