⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269802 in webkit


Ignore:
Timestamp:
Nov 13, 2020, 2:38:53 PM (6 years ago)
Author:
ggaren@apple.com
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.

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269789 r269802  
     12020-11-13  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Removed DeferrableTaskTimer
     4        https://bugs.webkit.org/show_bug.cgi?id=218874
     5
     6        Reviewed by Chris Dumez.
     7
     8        It was (mostly) redundant.
     9
     10        * platform/Timer.h:
     11        (WebCore::Timer::schedule): This helper function does the same job
     12        that DeferrableTaskTimer used to do.
     13
     14        (WebCore::DeferrableTaskTimer::fired): Deleted.
     15        (WebCore::DeferrableTaskTimer::doTask): Deleted.
     16        (WebCore::DeferrableTaskTimer::cancel): Deleted.
     17
     18        * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
     19        (WebCore::MediaRecorderPrivateMock::fetchData): Use the new helper function.
     20
     21        * platform/mediarecorder/MediaRecorderPrivateMock.h: No need for a data
     22        member anymore since we can use the schedule() convenience function instead.
     23
    1242020-11-13  Claudio Saavedra  <csaavedra@igalia.com>
    225
  • trunk/Source/WebCore/platform/Timer.h

    r267081 r269802  
    5353
    5454    void startRepeating(Seconds repeatInterval) { start(repeatInterval, repeatInterval); }
    55     void startOneShot(Seconds interval) { start(interval, 0_s); }
     55    void startOneShot(Seconds delay) { start(delay, 0_s); }
    5656
    5757    WEBCORE_EXPORT void stop();
     
    110110    WTF_MAKE_FAST_ALLOCATED;
    111111public:
     112    static void schedule(Seconds delay, WTF::Function<void()>&& function)
     113    {
     114        auto* timer = new Timer([] { });
     115        timer->m_function = [timer, function = WTFMove(function)] {
     116            function();
     117            delete timer;
     118        };
     119        timer->startOneShot(delay);
     120    }
     121
    112122    template <typename TimerFiredClass, typename TimerFiredBaseClass>
    113123    Timer(TimerFiredClass& object, void (TimerFiredBaseClass::*function)())
     
    150160    }
    151161
    152     DeferrableOneShotTimer(WTF::Function<void ()>&& function, Seconds delay)
     162    DeferrableOneShotTimer(WTF::Function<void()>&& function, Seconds delay)
    153163        : m_function(WTFMove(function))
    154164        , m_delay(delay)
     
    196206};
    197207
    198 class DeferrableTaskTimer final : private TimerBase {
    199     WTF_MAKE_FAST_ALLOCATED;
    200 public:
    201     DeferrableTaskTimer() = default;
    202 
    203     void doTask(Function<void()>&&, Seconds);
    204     void cancel();
    205     bool isActive() const { return TimerBase::isActive(); }
    206 
    207 private:
    208     void fired() final;
    209 
    210     Function<void()> m_function;
    211 };
    212 
    213 inline void DeferrableTaskTimer::fired()
    214 {
    215     std::exchange(m_function, { })();
    216208}
    217 
    218 inline void DeferrableTaskTimer::doTask(Function<void()>&& function, Seconds delay)
    219 {
    220     ASSERT(!isActive());
    221     ASSERT(!m_function);
    222     m_function = WTFMove(function);
    223     startOneShot(delay);
    224 }
    225 
    226 inline void DeferrableTaskTimer::cancel()
    227 {
    228     std::exchange(m_function, { });
    229     stop();
    230 }
    231 
    232 }
  • trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp

    r268136 r269802  
    102102
    103103    // Delay calling the completion handler a bit to mimick real writer behavior.
    104     m_delayCompletingTimer.doTask([completionHandler = WTFMove(completionHandler), buffer = WTFMove(buffer), mimeType = mimeType(), timeCode = MonotonicTime::now().secondsSinceEpoch().value()]() mutable {
     104    Timer::schedule(50_ms, [completionHandler = WTFMove(completionHandler), buffer = WTFMove(buffer), mimeType = mimeType(), timeCode = MonotonicTime::now().secondsSinceEpoch().value()]() mutable {
    105105        completionHandler(WTFMove(buffer), mimeType, timeCode);
    106     }, 50_ms);
     106    });
    107107}
    108108
  • trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h

    r268130 r269802  
    3333namespace WebCore {
    3434
    35 class DeferrableTaskTimer;
    3635class MediaStreamTrackPrivate;
    3736
     
    5958    String m_audioTrackID;
    6059    String m_videoTrackID;
    61     DeferrableTaskTimer m_delayCompletingTimer;
    6260};
    6361
  • trunk/Source/WebKit/ChangeLog

    r269792 r269802  
     12020-11-13  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Removed DeferrableTaskTimer
     4        https://bugs.webkit.org/show_bug.cgi?id=218874
     5
     6        Reviewed by Chris Dumez.
     7
     8        It was (mostly) redundant.
     9
     10        * UIProcess/WebPageProxy.cpp:
     11        (WebKit::WebPageProxy::updateReportedMediaCaptureState):
     12        * UIProcess/WebPageProxy.h: Use WTF::RunLoop::Timer instead of
     13        WebCore::Timer because WebCore::Timer for WebKit code in the UI process
     14        is a no-no, which can crash if the UI process also uses WebThread.
     15
    1162020-11-13  Per Arne Vollan  <pvollan@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r269792 r269802  
    510510#endif
    511511    , m_pageLoadState(*this)
     512    , m_updateReportedMediaCaptureStateTimer(RunLoop::main(), this, &WebPageProxy::updateReportedMediaCaptureState)
    512513    , m_inspectorController(makeUnique<WebPageInspectorController>(*this))
    513514#if ENABLE(REMOTE_INSPECTOR)
     
    90539054    bool willReportCapture = activeCaptureState;
    90549055
    9055     if (haveReportedCapture && !willReportCapture && m_delayStopCapturingReportingTimer.isActive())
    9056         return;
    9057 
    9058     if (!haveReportedCapture && willReportCapture) {
    9059         m_delayStopCapturingReportingTimer.doTask([this] {
    9060             updateReportedMediaCaptureState();
    9061         }, m_mediaCaptureReportingDelay);
    9062     }
     9056    if (haveReportedCapture && !willReportCapture && m_updateReportedMediaCaptureStateTimer.isActive())
     9057        return;
     9058
     9059    if (!haveReportedCapture && willReportCapture)
     9060        m_updateReportedMediaCaptureStateTimer.startOneShot(m_mediaCaptureReportingDelay);
    90639061
    90649062    m_reportedMediaCaptureState = activeCaptureState;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r269785 r269802  
    27562756    // 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.
    27572757    WebCore::MediaProducer::MediaStateFlags m_reportedMediaCaptureState { WebCore::MediaProducer::IsNotPlaying };
    2758     WebCore::DeferrableTaskTimer m_delayStopCapturingReportingTimer;
     2758    RunLoop::Timer<WebPageProxy> m_updateReportedMediaCaptureStateTimer;
    27592759    static constexpr Seconds DefaultMediaCaptureReportingDelay { 3_s };
    27602760    Seconds m_mediaCaptureReportingDelay { DefaultMediaCaptureReportingDelay };
Note: See TracChangeset for help on using the changeset viewer.