Title: [197599] trunk/Source/WebCore
Revision
197599
Author
[email protected]
Date
2016-03-04 16:56:07 -0800 (Fri, 04 Mar 2016)

Log Message

Convert DOMTimer interval from int to std::chromo::milliseconds
https://bugs.webkit.org/show_bug.cgi?id=155051

Reviewed by Ryosuke Niwa.

This change is pretty much mechanical, replacing int with std::chrono::milliseconds.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl):
(WebCore::InspectorInstrumentation::didInstallTimerImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willSendXMLHttpRequest):
(WebCore::InspectorInstrumentation::didInstallTimer):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didPaint):
(WebCore::InspectorTimelineAgent::didInstallTimer):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createGenericTimerData):
(WebCore::TimelineRecordFactory::createTimerInstallData):
* inspector/TimelineRecordFactory.h:
* page/DOMTimer.cpp:
(WebCore::shouldForwardUserGesture):
(WebCore::DOMTimer::DOMTimer):
(WebCore::DOMTimer::~DOMTimer):
(WebCore::DOMTimer::install):
(WebCore::DOMTimer::intervalClampedToMinimum):
* page/DOMTimer.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::setTimeout):
(WebCore::DOMWindow::clearTimeout):
(WebCore::DOMWindow::setInterval):
(WebCore::DOMWindow::clearInterval):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::setTimeout):
(WebCore::WorkerGlobalScope::clearTimeout):
(WebCore::WorkerGlobalScope::setInterval):
(WebCore::WorkerGlobalScope::clearInterval):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (197598 => 197599)


--- trunk/Source/WebCore/ChangeLog	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/ChangeLog	2016-03-05 00:56:07 UTC (rev 197599)
@@ -1,3 +1,44 @@
+2016-03-04  Gavin Barraclough  <[email protected]>
+
+        Convert DOMTimer interval from int to std::chromo::milliseconds
+        https://bugs.webkit.org/show_bug.cgi?id=155051
+
+        Reviewed by Ryosuke Niwa.
+
+        This change is pretty much mechanical, replacing int with std::chrono::milliseconds.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl):
+        (WebCore::InspectorInstrumentation::didInstallTimerImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::willSendXMLHttpRequest):
+        (WebCore::InspectorInstrumentation::didInstallTimer):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::didPaint):
+        (WebCore::InspectorTimelineAgent::didInstallTimer):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createGenericTimerData):
+        (WebCore::TimelineRecordFactory::createTimerInstallData):
+        * inspector/TimelineRecordFactory.h:
+        * page/DOMTimer.cpp:
+        (WebCore::shouldForwardUserGesture):
+        (WebCore::DOMTimer::DOMTimer):
+        (WebCore::DOMTimer::~DOMTimer):
+        (WebCore::DOMTimer::install):
+        (WebCore::DOMTimer::intervalClampedToMinimum):
+        * page/DOMTimer.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::setTimeout):
+        (WebCore::DOMWindow::clearTimeout):
+        (WebCore::DOMWindow::setInterval):
+        (WebCore::DOMWindow::clearInterval):
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::setTimeout):
+        (WebCore::WorkerGlobalScope::clearTimeout):
+        (WebCore::WorkerGlobalScope::setInterval):
+        (WebCore::WorkerGlobalScope::clearInterval):
+
 2016-03-03  Enrica Casucci  <[email protected]>
 
         Add a mechanism to customize the long press action.

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (197598 => 197599)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2016-03-05 00:56:07 UTC (rev 197599)
@@ -310,7 +310,7 @@
         domDebuggerAgent->willSendXMLHttpRequest(url);
 }
 
-void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, int timeout, bool singleShot, ScriptExecutionContext* context)
+void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext* context)
 {
     pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true);
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (197598 => 197599)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2016-03-05 00:56:07 UTC (rev 197599)
@@ -140,7 +140,7 @@
     static bool forcePseudoState(Element&, CSSSelector::PseudoClassType);
 
     static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
-    static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
+    static void didInstallTimer(ScriptExecutionContext*, int timerId, std::chrono::milliseconds timeout, bool singleShot);
     static void didRemoveTimer(ScriptExecutionContext*, int timerId);
 
     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
@@ -309,7 +309,7 @@
     static bool forcePseudoStateImpl(InstrumentingAgents&, Element&, CSSSelector::PseudoClassType);
 
     static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
-    static void didInstallTimerImpl(InstrumentingAgents&, int timerId, int timeout, bool singleShot, ScriptExecutionContext*);
+    static void didInstallTimerImpl(InstrumentingAgents&, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext*);
     static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext*);
 
     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, ScriptExecutionContext*);
@@ -648,7 +648,7 @@
         willSendXMLHttpRequestImpl(*instrumentingAgents, url);
 }
 
-inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot)
+inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, std::chrono::milliseconds timeout, bool singleShot)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (197598 => 197599)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2016-03-05 00:56:07 UTC (rev 197599)
@@ -339,7 +339,7 @@
     didCompleteCurrentRecord(TimelineRecordType::Paint);
 }
 
-void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot, Frame* frame)
+void InspectorTimelineAgent::didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame* frame)
 {
     appendRecord(TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot), TimelineRecordType::TimerInstall, true, frame);
 }

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (197598 => 197599)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2016-03-05 00:56:07 UTC (rev 197599)
@@ -110,7 +110,7 @@
     RefPtr<JSC::Profile> stopFromConsole(JSC::ExecState*, const String& title);
 
     // InspectorInstrumentation callbacks.
-    void didInstallTimer(int timerId, int timeout, bool singleShot, Frame*);
+    void didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame*);
     void didRemoveTimer(int timerId, Frame*);
     void willFireTimer(int timerId, Frame*);
     void didFireTimer();

Modified: trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp (197598 => 197599)


--- trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp	2016-03-05 00:56:07 UTC (rev 197599)
@@ -95,11 +95,11 @@
     return data;
 }
 
-Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
+Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot)
 {
     Ref<InspectorObject> data = ""
     data->setInteger(ASCIILiteral("timerId"), timerId);
-    data->setInteger(ASCIILiteral("timeout"), timeout);
+    data->setInteger(ASCIILiteral("timeout"), timeout.count());
     data->setBoolean(ASCIILiteral("singleShot"), singleShot);
     return data;
 }

Modified: trunk/Source/WebCore/inspector/TimelineRecordFactory.h (197598 => 197599)


--- trunk/Source/WebCore/inspector/TimelineRecordFactory.h	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/inspector/TimelineRecordFactory.h	2016-03-05 00:56:07 UTC (rev 197599)
@@ -58,7 +58,7 @@
     static Ref<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, unsigned sampleId);
     static Ref<Inspector::InspectorObject> createEventDispatchData(const Event&);
     static Ref<Inspector::InspectorObject> createGenericTimerData(int timerId);
-    static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
+    static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot);
     static Ref<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber);
     static Ref<Inspector::InspectorObject> createTimeStampData(const String&);
     static Ref<Inspector::InspectorObject> createAnimationFrameData(int callbackId);

Modified: trunk/Source/WebCore/page/DOMTimer.cpp (197598 => 197599)


--- trunk/Source/WebCore/page/DOMTimer.cpp	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/page/DOMTimer.cpp	2016-03-05 00:56:07 UTC (rev 197599)
@@ -52,7 +52,7 @@
 
 namespace WebCore {
 
-static const int maxIntervalForUserGestureForwarding = 1000; // One second matches Gecko.
+static const std::chrono::milliseconds maxIntervalForUserGestureForwarding = std::chrono::milliseconds(1000); // One second matches Gecko.
 static const int minIntervalForNonUserObservableChangeTimers = 1000; // Empirically determined to maximize battery life.
 static const int maxTimerNestingLevel = 5;
 static const double _oneMillisecond_ = 0.001;
@@ -162,14 +162,14 @@
 
 bool NestedTimersMap::isTrackingNestedTimers = false;
 
-static inline bool shouldForwardUserGesture(int interval, int nestingLevel)
+static inline bool shouldForwardUserGesture(std::chrono::milliseconds interval, int nestingLevel)
 {
     return UserGestureIndicator::processingUserGesture()
         && interval <= maxIntervalForUserGestureForwarding
         && !nestingLevel; // Gestures should not be forwarded to nested timers.
 }
 
-DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, int interval, bool singleShot)
+DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds interval, bool singleShot)
     : SuspendableTimer(context)
     , m_nestingLevel(context.timerNestingLevel())
     , m_action(WTFMove(action))
@@ -195,7 +195,7 @@
 {
 }
 
-int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, int timeout, bool singleShot)
+int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds timeout, bool singleShot)
 {
     // DOMTimer constructor passes ownership of the initial ref on the object to the constructor.
     // This reference will be released automatically when a one-shot timer fires, when the context
@@ -408,7 +408,7 @@
     ASSERT(scriptExecutionContext());
     ASSERT(m_nestingLevel <= maxTimerNestingLevel);
 
-    double intervalInSeconds = std::max(oneMillisecond, m_originalInterval * oneMillisecond);
+    double intervalInSeconds = std::max(oneMillisecond, m_originalInterval.count() * oneMillisecond);
 
     // Only apply throttling to repeating timers.
     if (m_nestingLevel < maxTimerNestingLevel)

Modified: trunk/Source/WebCore/page/DOMTimer.h (197598 => 197599)


--- trunk/Source/WebCore/page/DOMTimer.h	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/page/DOMTimer.h	2016-03-05 00:56:07 UTC (rev 197599)
@@ -33,66 +33,66 @@
 
 namespace WebCore {
 
-    class DOMTimerFireState;
-    class Document;
-    class Element;
-    class HTMLPlugInElement;
-    class IntRect;
-    class ScheduledAction;
+class DOMTimerFireState;
+class Document;
+class Element;
+class HTMLPlugInElement;
+class IntRect;
+class ScheduledAction;
 
-    class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {
-        WTF_MAKE_NONCOPYABLE(DOMTimer);
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
-        virtual ~DOMTimer();
+class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {
+    WTF_MAKE_NONCOPYABLE(DOMTimer);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    virtual ~DOMTimer();
 
-        static double defaultMinimumInterval() { return 0.004; } // 4 milliseconds.
-        static double defaultAlignmentInterval() { return 0; }
-        static double hiddenPageAlignmentInterval() { return 1.0; } // 1 second.
+    static double defaultMinimumInterval() { return 0.004; } // 4 milliseconds.
+    static double defaultAlignmentInterval() { return 0; }
+    static double hiddenPageAlignmentInterval() { return 1.0; } // 1 second.
 
-        // Creates a new timer owned by specified ScriptExecutionContext, starts it
-        // and returns its Id.
-        static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int timeout, bool singleShot);
-        static void removeById(ScriptExecutionContext&, int timeoutId);
+    // Creates a new timer owned by specified ScriptExecutionContext, starts it
+    // and returns its Id.
+    static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds timeout, bool singleShot);
+    static void removeById(ScriptExecutionContext&, int timeoutId);
 
-        // Notify that the interval may need updating (e.g. because the minimum interval
-        // setting for the context has changed).
-        void updateTimerIntervalIfNecessary();
+    // Notify that the interval may need updating (e.g. because the minimum interval
+    // setting for the context has changed).
+    void updateTimerIntervalIfNecessary();
 
-        static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
+    static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
 
-    private:
-        DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
-        friend class Internals;
+private:
+    DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds interval, bool singleShot);
+    friend class Internals;
 
-        double intervalClampedToMinimum() const;
+    double intervalClampedToMinimum() const;
 
-        bool isDOMTimersThrottlingEnabled(Document&) const;
-        void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
+    bool isDOMTimersThrottlingEnabled(Document&) const;
+    void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
 
-        // SuspendableTimer
-        void fired() override;
-        void didStop() override;
-        double alignedFireTime(double) const override;
+    // SuspendableTimer
+    void fired() override;
+    void didStop() override;
+    double alignedFireTime(double) const override;
 
-        // ActiveDOMObject API.
-        const char* activeDOMObjectName() const override;
+    // ActiveDOMObject API.
+    const char* activeDOMObjectName() const override;
 
-        enum TimerThrottleState {
-            Undetermined,
-            ShouldThrottle,
-            ShouldNotThrottle
-        };
-
-        int m_timeoutId;
-        int m_nestingLevel;
-        std::unique_ptr<ScheduledAction> m_action;
-        int m_originalInterval;
-        TimerThrottleState m_throttleState;
-        double m_currentTimerInterval;
-        bool m_shouldForwardUserGesture;
+    enum TimerThrottleState {
+        Undetermined,
+        ShouldThrottle,
+        ShouldNotThrottle
     };
 
+    int m_timeoutId;
+    int m_nestingLevel;
+    std::unique_ptr<ScheduledAction> m_action;
+    std::chrono::milliseconds m_originalInterval;
+    TimerThrottleState m_throttleState;
+    double m_currentTimerInterval;
+    bool m_shouldForwardUserGesture;
+};
+
 } // namespace WebCore
 
 #endif // DOMTimer_h

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (197598 => 197599)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2016-03-05 00:56:07 UTC (rev 197599)
@@ -1603,7 +1603,7 @@
         ec = INVALID_ACCESS_ERR;
         return -1;
     }
-    return DOMTimer::install(*context, WTFMove(action), timeout, true);
+    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true);
 }
 
 void DOMWindow::clearTimeout(int timeoutId)
@@ -1637,7 +1637,7 @@
         ec = INVALID_ACCESS_ERR;
         return -1;
     }
-    return DOMTimer::install(*context, WTFMove(action), timeout, false);
+    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false);
 }
 
 void DOMWindow::clearInterval(int timeoutId)

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (197598 => 197599)


--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp	2016-03-05 00:40:14 UTC (rev 197598)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp	2016-03-05 00:56:07 UTC (rev 197599)
@@ -150,7 +150,7 @@
 
 int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    return DOMTimer::install(*this, WTFMove(action), timeout, true);
+    return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), true);
 }
 
 void WorkerGlobalScope::clearTimeout(int timeoutId)
@@ -160,7 +160,7 @@
 
 int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    return DOMTimer::install(*this, WTFMove(action), timeout, false);
+    return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), false);
 }
 
 void WorkerGlobalScope::clearInterval(int timeoutId)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to