Change HysteresisActivity to use a lambda
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 19:37:33 +0000 (19:37 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 19:37:33 +0000 (19:37 +0000)
commite97b78b9a570bfd1a5040ee90bdead55157f8a5f
tree31c96ae3b142e5cb0fb9047de0822e5d07ff5533
parent81fec1b6d67bf4eea9eb08ccdcbb99d0b3ea91e7
Change HysteresisActivity to use a lambda
https://bugs.webkit.org/show_bug.cgi?id=139636

Reviewed by Darin Adler.

The current implementation provides notifications via callbacks to a delegate. Using a delegate
with callbacks is limiting a number of ways. The callback names are very ambiguous, the callbacks
must either be on a separate object (more boilerplate), or the callback must be public for
HysteresisActivity to call them, or friends get involved. Without the boilerplate of extra
delegate objects it's hard to scale use of these objects – a single object can't serve as a
delegate for multiple HysteresisActivity members.

Instead, make HysteresisActivity take a lambda to callback on state change. To simplify, changed
HysteresisState to only track Started/Stopped states (removed WillStopPendingTimeout).

Source/WebCore:

* WebCore.exp.in:
    - removed exports of deleted functions.
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
    - m_hysteresis lambda calls updateUserActivity.
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
    - ASSERT updated due to removal of WillStopPendingTimeout state.
(WebCore::PageThrottler::started): Deleted.
(WebCore::PageThrottler::stopped): Deleted.
    - functionality replaced by lambda.
* page/PageThrottler.h:
    - HysteresisActivity is no longer templated on delegate type, removed function declarations & friend.
* platform/HysteresisActivity.h:
(WebCore::HysteresisActivity::HysteresisActivity):
    - HysteresisActivity takes a lambda, not a delegate.
(WebCore::HysteresisActivity::start):
    - delegate call -> callback.
(WebCore::HysteresisActivity::state):
    - simplified to remove WillStopPendingTimeout.
(WebCore::HysteresisActivity::hysteresisTimerFired):
    - delegate call -> callback.
* platform/UserActivity.cpp:
(WebCore::UserActivity::UserActivity):
    - HysteresisActivity lambda calls hysteresisUpdated.
(WebCore::UserActivity::hysteresisUpdated):
(WebCore::UserActivity::started): Deleted.
(WebCore::UserActivity::stopped): Deleted.
    - started/stopped -> hysteresisUpdated.
* platform/UserActivity.h:
    - started/stopped -> hysteresisUpdated, removed friend.

Source/WebKit2:

* WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp:
(WebKit::WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker):
    - HysteresisActivity now takes a lambda, not a delegate.
(WebKit::WebSQLiteDatabaseTracker::hysteresisUpdated):
(WebKit::WebSQLiteDatabaseTracker::started): Deleted.
(WebKit::WebSQLiteDatabaseTracker::stopped): Deleted.
    - started/stopped merged into hysteresisUpdated
* WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h:
    - HysteresisActivity is no longer templated on delegate type, changed function declarations.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/PageThrottler.cpp
Source/WebCore/page/PageThrottler.h
Source/WebCore/platform/HysteresisActivity.h
Source/WebCore/platform/UserActivity.cpp
Source/WebCore/platform/UserActivity.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h