Changeset 269802 in webkit
- Timestamp:
- Nov 13, 2020, 2:38:53 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/Timer.h (modified) (4 diffs)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp (modified) (1 diff)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.cpp (modified) (2 diffs)
-
WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269789 r269802 1 2020-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 1 24 2020-11-13 Claudio Saavedra <csaavedra@igalia.com> 2 25 -
trunk/Source/WebCore/platform/Timer.h
r267081 r269802 53 53 54 54 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); } 56 56 57 57 WEBCORE_EXPORT void stop(); … … 110 110 WTF_MAKE_FAST_ALLOCATED; 111 111 public: 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 112 122 template <typename TimerFiredClass, typename TimerFiredBaseClass> 113 123 Timer(TimerFiredClass& object, void (TimerFiredBaseClass::*function)()) … … 150 160 } 151 161 152 DeferrableOneShotTimer(WTF::Function<void ()>&& function, Seconds delay)162 DeferrableOneShotTimer(WTF::Function<void()>&& function, Seconds delay) 153 163 : m_function(WTFMove(function)) 154 164 , m_delay(delay) … … 196 206 }; 197 207 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, { })();216 208 } 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 102 102 103 103 // 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 { 105 105 completionHandler(WTFMove(buffer), mimeType, timeCode); 106 } , 50_ms);106 }); 107 107 } 108 108 -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h
r268130 r269802 33 33 namespace WebCore { 34 34 35 class DeferrableTaskTimer;36 35 class MediaStreamTrackPrivate; 37 36 … … 59 58 String m_audioTrackID; 60 59 String m_videoTrackID; 61 DeferrableTaskTimer m_delayCompletingTimer;62 60 }; 63 61 -
trunk/Source/WebKit/ChangeLog
r269792 r269802 1 2020-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 1 16 2020-11-13 Per Arne Vollan <pvollan@apple.com> 2 17 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r269792 r269802 510 510 #endif 511 511 , m_pageLoadState(*this) 512 , m_updateReportedMediaCaptureStateTimer(RunLoop::main(), this, &WebPageProxy::updateReportedMediaCaptureState) 512 513 , m_inspectorController(makeUnique<WebPageInspectorController>(*this)) 513 514 #if ENABLE(REMOTE_INSPECTOR) … … 9053 9054 bool willReportCapture = activeCaptureState; 9054 9055 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); 9063 9061 9064 9062 m_reportedMediaCaptureState = activeCaptureState; -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r269785 r269802 2756 2756 // 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. 2757 2757 WebCore::MediaProducer::MediaStateFlags m_reportedMediaCaptureState { WebCore::MediaProducer::IsNotPlaying }; 2758 WebCore::DeferrableTaskTimer m_delayStopCapturingReportingTimer;2758 RunLoop::Timer<WebPageProxy> m_updateReportedMediaCaptureStateTimer; 2759 2759 static constexpr Seconds DefaultMediaCaptureReportingDelay { 3_s }; 2760 2760 Seconds m_mediaCaptureReportingDelay { DefaultMediaCaptureReportingDelay };
Note:
See TracChangeset
for help on using the changeset viewer.