2013-05-30 18:19:00 +00:00
|
|
|
/*
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
* Copyright (C) 2014 Apple Inc. All rights reserved.
|
2013-05-30 18:19:00 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-10-15 14:24:49 +00:00
|
|
|
#pragma once
|
2013-05-30 18:19:00 +00:00
|
|
|
|
2017-06-18 19:49:12 +00:00
|
|
|
#include <wtf/Function.h>
|
2013-05-30 18:19:00 +00:00
|
|
|
#include <wtf/Noncopyable.h>
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
#include <wtf/RefPtr.h>
|
2017-11-08 22:50:59 +00:00
|
|
|
#include <wtf/SetForScope.h>
|
2013-05-30 18:19:00 +00:00
|
|
|
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
namespace WTF {
|
2013-05-30 18:19:00 +00:00
|
|
|
|
2016-02-29 18:55:21 +00:00
|
|
|
enum class RefCounterEvent { Decrement, Increment };
|
|
|
|
|
2016-02-25 22:24:32 +00:00
|
|
|
template<typename T>
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
class RefCounter {
|
2019-02-08 02:38:46 +00:00
|
|
|
WTF_MAKE_FAST_ALLOCATED;
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
WTF_MAKE_NONCOPYABLE(RefCounter);
|
2014-12-19 00:51:47 +00:00
|
|
|
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
class Count {
|
|
|
|
WTF_MAKE_NONCOPYABLE(Count);
|
|
|
|
public:
|
2016-02-26 00:45:35 +00:00
|
|
|
void ref();
|
|
|
|
void deref();
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
|
2017-11-08 22:50:59 +00:00
|
|
|
void refCounterWasDeleted();
|
|
|
|
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
private:
|
|
|
|
friend class RefCounter;
|
|
|
|
|
|
|
|
Count(RefCounter& refCounter)
|
|
|
|
: m_refCounter(&refCounter)
|
|
|
|
, m_value(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RefCounter* m_refCounter;
|
2016-02-26 18:20:07 +00:00
|
|
|
size_t m_value;
|
2017-11-08 22:50:59 +00:00
|
|
|
bool m_inValueDidChange { false };
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
};
|
|
|
|
|
2014-12-19 00:51:47 +00:00
|
|
|
public:
|
2016-02-26 00:54:13 +00:00
|
|
|
using Token = RefPtr<Count>;
|
2017-06-18 19:49:12 +00:00
|
|
|
using ValueChangeFunction = WTF::Function<void (RefCounterEvent)>;
|
2014-12-19 00:51:47 +00:00
|
|
|
|
2017-06-18 19:49:12 +00:00
|
|
|
RefCounter(ValueChangeFunction&& = nullptr);
|
2016-02-26 00:45:35 +00:00
|
|
|
~RefCounter();
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
|
2016-02-25 22:24:32 +00:00
|
|
|
Token count() const
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
{
|
2016-02-26 00:54:13 +00:00
|
|
|
return m_count;
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
}
|
|
|
|
|
2016-02-26 18:20:07 +00:00
|
|
|
size_t value() const
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
{
|
|
|
|
return m_count->m_value;
|
|
|
|
}
|
2013-05-30 18:19:00 +00:00
|
|
|
|
|
|
|
private:
|
2016-02-26 18:20:07 +00:00
|
|
|
ValueChangeFunction m_valueDidChange;
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
Count* m_count;
|
2013-05-30 18:19:00 +00:00
|
|
|
};
|
|
|
|
|
2016-02-25 22:24:32 +00:00
|
|
|
template<typename T>
|
|
|
|
inline void RefCounter<T>::Count::ref()
|
|
|
|
{
|
|
|
|
++m_value;
|
2016-02-26 18:20:07 +00:00
|
|
|
if (m_refCounter && m_refCounter->m_valueDidChange)
|
2016-02-29 18:55:21 +00:00
|
|
|
m_refCounter->m_valueDidChange(RefCounterEvent::Increment);
|
2016-02-25 22:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline void RefCounter<T>::Count::deref()
|
|
|
|
{
|
|
|
|
ASSERT(m_value);
|
|
|
|
|
2016-02-26 18:20:07 +00:00
|
|
|
--m_value;
|
2017-11-08 22:50:59 +00:00
|
|
|
|
|
|
|
if (m_refCounter && m_refCounter->m_valueDidChange) {
|
|
|
|
SetForScope<bool> inCallback(m_inValueDidChange, true);
|
2016-02-29 18:55:21 +00:00
|
|
|
m_refCounter->m_valueDidChange(RefCounterEvent::Decrement);
|
2017-11-08 22:50:59 +00:00
|
|
|
}
|
2016-02-25 22:24:32 +00:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
// If the RefCounter has already been deallocted then delete the Count when its reference
|
|
|
|
// count reaches zero.
|
2016-02-26 18:20:07 +00:00
|
|
|
if (!m_refCounter && !m_value)
|
2016-02-25 22:24:32 +00:00
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-11-08 22:50:59 +00:00
|
|
|
template<typename T>
|
|
|
|
inline void RefCounter<T>::Count::refCounterWasDeleted()
|
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
// If the reference count of the Count is already zero then delete it now, otherwise
|
|
|
|
// clear its m_refCounter pointer.
|
|
|
|
|
|
|
|
m_refCounter = nullptr;
|
|
|
|
|
|
|
|
if (m_inValueDidChange)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!m_value)
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2016-02-25 22:24:32 +00:00
|
|
|
template<typename T>
|
2017-06-18 19:49:12 +00:00
|
|
|
inline RefCounter<T>::RefCounter(ValueChangeFunction&& valueDidChange)
|
|
|
|
: m_valueDidChange(WTFMove(valueDidChange))
|
2016-02-25 22:24:32 +00:00
|
|
|
, m_count(new Count(*this))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline RefCounter<T>::~RefCounter()
|
|
|
|
{
|
2017-11-08 22:50:59 +00:00
|
|
|
m_count->refCounterWasDeleted();
|
|
|
|
|
2016-02-25 22:24:32 +00:00
|
|
|
}
|
|
|
|
|
Generalize PageActivityAssertionToken
https://bugs.webkit.org/show_bug.cgi?id=139106
Reviewed by Sam Weinig.
Source/WebCore:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WebCore.xcodeproj/project.pbxproj:
- removed PageActivityAssertionToken.cpp/.h
* html/HTMLMediaElement.cpp:
- removed PageActivityAssertionToken.h
* html/HTMLMediaElement.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/FrameLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/FrameLoader.h:
- std::unique_ptr<PageActivityAssertionToken> -> RefPtr<RefCounter::Count>
* loader/SubresourceLoader.cpp:
- removed PageActivityAssertionToken.h
* loader/SubresourceLoader.h:
- removed class PageActivityAssertionToken
* page/Page.cpp:
- removed PageActivityAssertionToken.h
(WebCore::Page::Page):
- removed Page* parameter to PageThrottler
* page/Page.h:
- removed class PageActivityAssertionToken
* page/PageActivityAssertionToken.cpp: Removed.
* page/PageActivityAssertionToken.h: Removed.
- removed PageActivityAssertionToken.cpp/.h
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
- removed m_page, m_weakPtrFactory, m_activityCount; added m_pageActivityCounter.
(WebCore::PageThrottler::mediaActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageLoadActivityToken):
- std::unique_ptr<PageActivityAssertionToken> -> PassRefPtr<RefCounter::Count>
(WebCore::PageThrottler::pageActivityCounterValueDidChange):
- merged functionality of incrementActivityCount/decrementActivityCount
(WebCore::PageThrottler::incrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
(WebCore::PageThrottler::decrementActivityCount): Deleted.
- see pageActivityCounterValueDidChange
* page/PageThrottler.h:
(WebCore::PageThrottler::weakPtr): Deleted.
- no longer required; this functionality is now encapsulated within RefCounter.
Source/WTF:
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.
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::Count stores the counter value, and also manage the lifetime
of this object.
- standard RefPtrs are used to manage references to the RefCounter::Count.
* WTF.xcodeproj/project.pbxproj:
- added RefCounter.cpp/.h
* wtf/RefCounter.cpp: Added.
(WTF::RefCounter::Count::ref):
- increment the counter.
(WTF::RefCounter::Count::deref):
- decrement the counter, and delete as necessary.
(WTF::RefCounter::RefCounter):
- create a RefCounter::Count.
(WTF::RefCounter::~RefCounter):
- eagerly delete the Counter if it has no references, otherwise let it be deleted on last deref.
* wtf/RefCounter.h: Added.
(WTF::RefCounter::Count::Count):
- initialize count to 0.
(WTF::RefCounter::RefCounter):
- takes a lambda to be called when the value changes.
(WTF::RefCounter::count):
- reference the counter (and in doing so increment the count).
(WTF::RefCounter::value):
- access the current value of the counter.
Tools:
Add an API test for WTF::RefCounter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp: Added.
(TestWebKitAPI::TEST):
- added RefCounter test.
Canonical link: https://commits.webkit.org/157031@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 20:30:17 +00:00
|
|
|
} // namespace WTF
|
|
|
|
|
|
|
|
using WTF::RefCounter;
|
2016-02-29 18:55:21 +00:00
|
|
|
using WTF::RefCounterEvent;
|