[Webkit-unassigned] [Bug 139106] New: Generalize PageActivityAssertionToken
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Nov 29 16:20:06 PST 2014
https://bugs.webkit.org/show_bug.cgi?id=139106
Bug ID: 139106
Summary: Generalize PageActivityAssertionToken
Classification: Unclassified
Product: WebKit
Version: 528+ (Nightly build)
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: WebCore Misc.
Assignee: webkit-unassigned at lists.webkit.org
Reporter: barraclough at apple.com
PageActivityAssertionToken is a RAII mechanism implementing a counter, used by PageThrottler to count user visible activity in progress on the page (currently page load and media playback). Use of an RAII type is prevents a number of possible errors, including double counting a single media element, or failing to decrement the count after a media element has been deallocated.
Generalizing the mechanism would both make it available for new uses (currently I want to track page load separately from media playback in PageThrottler, and track processes with active pages in WK2), and also may provide a better implementation for some existing accounting mechanisms (tracking processes suppression state across processes/contexts/globally in WK2, tracking outstanding user visible resource requests).
The current implementation has a number of drawbacks that have been addressed by this refactoring:
- specific to single use in PageThrottler class - not reusable.
- incomplete encapsulation - the counter and WeakPtrFactory that comprise the current implementation are not encapsulated (are in the client type, PageThrottler).
- tokens are not shared - PageActivityAssertionToken instances are managed by std::unique, every increment requires an object allocation.
- redundancy - the current implementation uses a WeakPtr to safely reference the PageThrottler, this is internally implemented using a reference counted type, resulting in two counters being incremented (one in the PageActivityAssertionToken, one in the PageThrottler).
In the reimplementation:
- a callback is provided via a lambda function, which allows for easy reuse without a lot of boilerplate code.
- the counter, callback and ownership of the otherwise weakly-owned token is encapsulated within the RefCounter type.
- a single count within RefCounter::Counter stores the counter value, and also manage the lifetime of this object.
- standard RefPtrs are used to manage references to the RefCounter::Counter.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20141130/466d97bf/attachment-0002.html>
More information about the webkit-unassigned
mailing list