- Revision
- 269802
- Author
- [email protected]
- Date
- 2020-11-13 14:38:53 -0800 (Fri, 13 Nov 2020)
Log Message
Removed DeferrableTaskTimer
https://bugs.webkit.org/show_bug.cgi?id=218874
Reviewed by Chris Dumez.
It was (mostly) redundant.
Source/WebCore:
* platform/Timer.h:
(WebCore::Timer::schedule): This helper function does the same job
that DeferrableTaskTimer used to do.
(WebCore::DeferrableTaskTimer::fired): Deleted.
(WebCore::DeferrableTaskTimer::doTask): Deleted.
(WebCore::DeferrableTaskTimer::cancel): Deleted.
* platform/mediarecorder/MediaRecorderPrivateMock.cpp:
(WebCore::MediaRecorderPrivateMock::fetchData): Use the new helper function.
* platform/mediarecorder/MediaRecorderPrivateMock.h: No need for a data
member anymore since we can use the schedule() convenience function instead.
Source/WebKit:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::updateReportedMediaCaptureState):
* UIProcess/WebPageProxy.h: Use WTF::RunLoop::Timer instead of
WebCore::Timer because WebCore::Timer for WebKit code in the UI process
is a no-no, which can crash if the UI process also uses WebThread.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (269801 => 269802)
--- trunk/Source/WebCore/ChangeLog 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebCore/ChangeLog 2020-11-13 22:38:53 UTC (rev 269802)
@@ -1,3 +1,26 @@
+2020-11-13 Geoffrey Garen <[email protected]>
+
+ Removed DeferrableTaskTimer
+ https://bugs.webkit.org/show_bug.cgi?id=218874
+
+ Reviewed by Chris Dumez.
+
+ It was (mostly) redundant.
+
+ * platform/Timer.h:
+ (WebCore::Timer::schedule): This helper function does the same job
+ that DeferrableTaskTimer used to do.
+
+ (WebCore::DeferrableTaskTimer::fired): Deleted.
+ (WebCore::DeferrableTaskTimer::doTask): Deleted.
+ (WebCore::DeferrableTaskTimer::cancel): Deleted.
+
+ * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
+ (WebCore::MediaRecorderPrivateMock::fetchData): Use the new helper function.
+
+ * platform/mediarecorder/MediaRecorderPrivateMock.h: No need for a data
+ member anymore since we can use the schedule() convenience function instead.
+
2020-11-13 Claudio Saavedra <[email protected]>
Non-unified build fixes.
Modified: trunk/Source/WebCore/platform/Timer.h (269801 => 269802)
--- trunk/Source/WebCore/platform/Timer.h 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebCore/platform/Timer.h 2020-11-13 22:38:53 UTC (rev 269802)
@@ -52,7 +52,7 @@
WEBCORE_EXPORT void start(Seconds nextFireInterval, Seconds repeatInterval);
void startRepeating(Seconds repeatInterval) { start(repeatInterval, repeatInterval); }
- void startOneShot(Seconds interval) { start(interval, 0_s); }
+ void startOneShot(Seconds delay) { start(delay, 0_s); }
WEBCORE_EXPORT void stop();
bool isActive() const;
@@ -109,6 +109,16 @@
class Timer : public TimerBase {
WTF_MAKE_FAST_ALLOCATED;
public:
+ static void schedule(Seconds delay, WTF::Function<void()>&& function)
+ {
+ auto* timer = new Timer([] { });
+ timer->m_function = [timer, function = WTFMove(function)] {
+ function();
+ delete timer;
+ };
+ timer->startOneShot(delay);
+ }
+
template <typename TimerFiredClass, typename TimerFiredBaseClass>
Timer(TimerFiredClass& object, void (TimerFiredBaseClass::*function)())
: m_function(std::bind(function, &object))
@@ -149,7 +159,7 @@
{
}
- DeferrableOneShotTimer(WTF::Function<void ()>&& function, Seconds delay)
+ DeferrableOneShotTimer(WTF::Function<void()>&& function, Seconds delay)
: m_function(WTFMove(function))
, m_delay(delay)
, m_shouldRestartWhenTimerFires(false)
@@ -195,38 +205,4 @@
bool m_shouldRestartWhenTimerFires;
};
-class DeferrableTaskTimer final : private TimerBase {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- DeferrableTaskTimer() = default;
-
- void doTask(Function<void()>&&, Seconds);
- void cancel();
- bool isActive() const { return TimerBase::isActive(); }
-
-private:
- void fired() final;
-
- Function<void()> m_function;
-};
-
-inline void DeferrableTaskTimer::fired()
-{
- std::exchange(m_function, { })();
}
-
-inline void DeferrableTaskTimer::doTask(Function<void()>&& function, Seconds delay)
-{
- ASSERT(!isActive());
- ASSERT(!m_function);
- m_function = WTFMove(function);
- startOneShot(delay);
-}
-
-inline void DeferrableTaskTimer::cancel()
-{
- std::exchange(m_function, { });
- stop();
-}
-
-}
Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp (269801 => 269802)
--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp 2020-11-13 22:38:53 UTC (rev 269802)
@@ -101,9 +101,9 @@
}
// Delay calling the completion handler a bit to mimick real writer behavior.
- m_delayCompletingTimer.doTask([completionHandler = WTFMove(completionHandler), buffer = WTFMove(buffer), mimeType = mimeType(), timeCode = MonotonicTime::now().secondsSinceEpoch().value()]() mutable {
+ Timer::schedule(50_ms, [completionHandler = WTFMove(completionHandler), buffer = WTFMove(buffer), mimeType = mimeType(), timeCode = MonotonicTime::now().secondsSinceEpoch().value()]() mutable {
completionHandler(WTFMove(buffer), mimeType, timeCode);
- }, 50_ms);
+ });
}
const String& MediaRecorderPrivateMock::mimeType() const
Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h (269801 => 269802)
--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h 2020-11-13 22:38:53 UTC (rev 269802)
@@ -32,7 +32,6 @@
namespace WebCore {
-class DeferrableTaskTimer;
class MediaStreamTrackPrivate;
class WEBCORE_EXPORT MediaRecorderPrivateMock final
@@ -58,7 +57,6 @@
unsigned m_counter { 0 };
String m_audioTrackID;
String m_videoTrackID;
- DeferrableTaskTimer m_delayCompletingTimer;
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (269801 => 269802)
--- trunk/Source/WebKit/ChangeLog 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebKit/ChangeLog 2020-11-13 22:38:53 UTC (rev 269802)
@@ -1,3 +1,18 @@
+2020-11-13 Geoffrey Garen <[email protected]>
+
+ Removed DeferrableTaskTimer
+ https://bugs.webkit.org/show_bug.cgi?id=218874
+
+ Reviewed by Chris Dumez.
+
+ It was (mostly) redundant.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::updateReportedMediaCaptureState):
+ * UIProcess/WebPageProxy.h: Use WTF::RunLoop::Timer instead of
+ WebCore::Timer because WebCore::Timer for WebKit code in the UI process
+ is a no-no, which can crash if the UI process also uses WebThread.
+
2020-11-13 Per Arne Vollan <[email protected]>
[macOS] Issue sandbox extension to the WebContent process for com.apple.lskdd
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (269801 => 269802)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-11-13 22:38:53 UTC (rev 269802)
@@ -509,6 +509,7 @@
, m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
#endif
, m_pageLoadState(*this)
+ , m_updateReportedMediaCaptureStateTimer(RunLoop::main(), this, &WebPageProxy::updateReportedMediaCaptureState)
, m_inspectorController(makeUnique<WebPageInspectorController>(*this))
#if ENABLE(REMOTE_INSPECTOR)
, m_inspectorDebuggable(makeUnique<WebPageDebuggable>(*this))
@@ -9052,14 +9053,11 @@
bool haveReportedCapture = m_reportedMediaCaptureState & MediaProducer::MediaCaptureMask;
bool willReportCapture = activeCaptureState;
- if (haveReportedCapture && !willReportCapture && m_delayStopCapturingReportingTimer.isActive())
+ if (haveReportedCapture && !willReportCapture && m_updateReportedMediaCaptureStateTimer.isActive())
return;
- if (!haveReportedCapture && willReportCapture) {
- m_delayStopCapturingReportingTimer.doTask([this] {
- updateReportedMediaCaptureState();
- }, m_mediaCaptureReportingDelay);
- }
+ if (!haveReportedCapture && willReportCapture)
+ m_updateReportedMediaCaptureStateTimer.startOneShot(m_mediaCaptureReportingDelay);
m_reportedMediaCaptureState = activeCaptureState;
m_uiClient->mediaCaptureStateDidChange(m_mediaState);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (269801 => 269802)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-11-13 22:32:01 UTC (rev 269801)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-11-13 22:38:53 UTC (rev 269802)
@@ -2755,7 +2755,7 @@
// To make sure capture indicators are visible long enough, m_reportedMediaCaptureState is the same as m_mediaState except that we might delay a bit transition from capturing to not-capturing.
WebCore::MediaProducer::MediaStateFlags m_reportedMediaCaptureState { WebCore::MediaProducer::IsNotPlaying };
- WebCore::DeferrableTaskTimer m_delayStopCapturingReportingTimer;
+ RunLoop::Timer<WebPageProxy> m_updateReportedMediaCaptureStateTimer;
static constexpr Seconds DefaultMediaCaptureReportingDelay { 3_s };
Seconds m_mediaCaptureReportingDelay { DefaultMediaCaptureReportingDelay };