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

Changeset 197599 in webkit


Ignore:
Timestamp:
Mar 4, 2016, 4:56:07 PM (11 years ago)
Author:
barraclough@apple.com
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):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197596 r197599  
     12016-03-04  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Convert DOMTimer interval from int to std::chromo::milliseconds
     4        https://bugs.webkit.org/show_bug.cgi?id=155051
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        This change is pretty much mechanical, replacing int with std::chrono::milliseconds.
     9
     10        * inspector/InspectorInstrumentation.cpp:
     11        (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl):
     12        (WebCore::InspectorInstrumentation::didInstallTimerImpl):
     13        * inspector/InspectorInstrumentation.h:
     14        (WebCore::InspectorInstrumentation::willSendXMLHttpRequest):
     15        (WebCore::InspectorInstrumentation::didInstallTimer):
     16        * inspector/InspectorTimelineAgent.cpp:
     17        (WebCore::InspectorTimelineAgent::didPaint):
     18        (WebCore::InspectorTimelineAgent::didInstallTimer):
     19        * inspector/InspectorTimelineAgent.h:
     20        * inspector/TimelineRecordFactory.cpp:
     21        (WebCore::TimelineRecordFactory::createGenericTimerData):
     22        (WebCore::TimelineRecordFactory::createTimerInstallData):
     23        * inspector/TimelineRecordFactory.h:
     24        * page/DOMTimer.cpp:
     25        (WebCore::shouldForwardUserGesture):
     26        (WebCore::DOMTimer::DOMTimer):
     27        (WebCore::DOMTimer::~DOMTimer):
     28        (WebCore::DOMTimer::install):
     29        (WebCore::DOMTimer::intervalClampedToMinimum):
     30        * page/DOMTimer.h:
     31        * page/DOMWindow.cpp:
     32        (WebCore::DOMWindow::setTimeout):
     33        (WebCore::DOMWindow::clearTimeout):
     34        (WebCore::DOMWindow::setInterval):
     35        (WebCore::DOMWindow::clearInterval):
     36        * workers/WorkerGlobalScope.cpp:
     37        (WebCore::WorkerGlobalScope::setTimeout):
     38        (WebCore::WorkerGlobalScope::clearTimeout):
     39        (WebCore::WorkerGlobalScope::setInterval):
     40        (WebCore::WorkerGlobalScope::clearInterval):
     41
    1422016-03-03  Enrica Casucci  <enrica@apple.com>
    243
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r194496 r197599  
    311311}
    312312
    313 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, int timeout, bool singleShot, ScriptExecutionContext* context)
     313void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext* context)
    314314{
    315315    pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true);
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r194496 r197599  
    141141
    142142    static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
    143     static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
     143    static void didInstallTimer(ScriptExecutionContext*, int timerId, std::chrono::milliseconds timeout, bool singleShot);
    144144    static void didRemoveTimer(ScriptExecutionContext*, int timerId);
    145145
    … …  
    310310
    311311    static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
    312     static void didInstallTimerImpl(InstrumentingAgents&, int timerId, int timeout, bool singleShot, ScriptExecutionContext*);
     312    static void didInstallTimerImpl(InstrumentingAgents&, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext*);
    313313    static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext*);
    314314
    … …  
    649649}
    650650
    651 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot)
     651inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, std::chrono::milliseconds timeout, bool singleShot)
    652652{
    653653    FAST_RETURN_IF_NO_FRONTENDS(void());
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r196165 r197599  
    340340}
    341341
    342 void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot, Frame* frame)
     342void InspectorTimelineAgent::didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame* frame)
    343343{
    344344    appendRecord(TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot), TimelineRecordType::TimerInstall, true, frame);
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.h

    r197563 r197599  
    111111
    112112    // InspectorInstrumentation callbacks.
    113     void didInstallTimer(int timerId, int timeout, bool singleShot, Frame*);
     113    void didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame*);
    114114    void didRemoveTimer(int timerId, Frame*);
    115115    void willFireTimer(int timerId, Frame*);
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp

    r194496 r197599  
    9696}
    9797
    98 Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
     98Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot)
    9999{
    100100    Ref<InspectorObject> data = InspectorObject::create();
    101101    data->setInteger(ASCIILiteral("timerId"), timerId);
    102     data->setInteger(ASCIILiteral("timeout"), timeout);
     102    data->setInteger(ASCIILiteral("timeout"), timeout.count());
    103103    data->setBoolean(ASCIILiteral("singleShot"), singleShot);
    104104    return data;
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.h

    r191967 r197599  
    5959    static Ref<Inspector::InspectorObject> createEventDispatchData(const Event&);
    6060    static Ref<Inspector::InspectorObject> createGenericTimerData(int timerId);
    61     static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
     61    static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot);
    6262    static Ref<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber);
    6363    static Ref<Inspector::InspectorObject> createTimeStampData(const String&);
  • trunk/Source/WebCore/page/DOMTimer.cpp

    r197415 r197599  
    5353namespace WebCore {
    5454
    55 static const int maxIntervalForUserGestureForwarding = 1000; // One second matches Gecko.
     55static const std::chrono::milliseconds maxIntervalForUserGestureForwarding = std::chrono::milliseconds(1000); // One second matches Gecko.
    5656static const int minIntervalForNonUserObservableChangeTimers = 1000; // Empirically determined to maximize battery life.
    5757static const int maxTimerNestingLevel = 5;
    … …  
    163163bool NestedTimersMap::isTrackingNestedTimers = false;
    164164
    165 static inline bool shouldForwardUserGesture(int interval, int nestingLevel)
     165static inline bool shouldForwardUserGesture(std::chrono::milliseconds interval, int nestingLevel)
    166166{
    167167    return UserGestureIndicator::processingUserGesture()
    … …  
    170170}
    171171
    172 DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, int interval, bool singleShot)
     172DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds interval, bool singleShot)
    173173    : SuspendableTimer(context)
    174174    , m_nestingLevel(context.timerNestingLevel())
    … …  
    196196}
    197197
    198 int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, int timeout, bool singleShot)
     198int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds timeout, bool singleShot)
    199199{
    200200    // DOMTimer constructor passes ownership of the initial ref on the object to the constructor.
    … …  
    409409    ASSERT(m_nestingLevel <= maxTimerNestingLevel);
    410410
    411     double intervalInSeconds = std::max(oneMillisecond, m_originalInterval * oneMillisecond);
     411    double intervalInSeconds = std::max(oneMillisecond, m_originalInterval.count() * oneMillisecond);
    412412
    413413    // Only apply throttling to repeating timers.
  • trunk/Source/WebCore/page/DOMTimer.h

    r197563 r197599  
    3434namespace WebCore {
    3535
    36     class DOMTimerFireState;
    37     class Document;
    38     class Element;
    39     class HTMLPlugInElement;
    40     class IntRect;
    41     class ScheduledAction;
     36class DOMTimerFireState;
     37class Document;
     38class Element;
     39class HTMLPlugInElement;
     40class IntRect;
     41class ScheduledAction;
    4242
    43     class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {
    44         WTF_MAKE_NONCOPYABLE(DOMTimer);
    45         WTF_MAKE_FAST_ALLOCATED;
    46     public:
    47         virtual ~DOMTimer();
     43class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {
     44    WTF_MAKE_NONCOPYABLE(DOMTimer);
     45    WTF_MAKE_FAST_ALLOCATED;
     46public:
     47    virtual ~DOMTimer();
    4848
    49         static double defaultMinimumInterval() { return 0.004; } // 4 milliseconds.
    50         static double defaultAlignmentInterval() { return 0; }
    51         static double hiddenPageAlignmentInterval() { return 1.0; } // 1 second.
     49    static double defaultMinimumInterval() { return 0.004; } // 4 milliseconds.
     50    static double defaultAlignmentInterval() { return 0; }
     51    static double hiddenPageAlignmentInterval() { return 1.0; } // 1 second.
    5252
    53         // Creates a new timer owned by specified ScriptExecutionContext, starts it
    54         // and returns its Id.
    55         static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int timeout, bool singleShot);
    56         static void removeById(ScriptExecutionContext&, int timeoutId);
     53    // Creates a new timer owned by specified ScriptExecutionContext, starts it
     54    // and returns its Id.
     55    static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds timeout, bool singleShot);
     56    static void removeById(ScriptExecutionContext&, int timeoutId);
    5757
    58         // Notify that the interval may need updating (e.g. because the minimum interval
    59         // setting for the context has changed).
    60         void updateTimerIntervalIfNecessary();
     58    // Notify that the interval may need updating (e.g. because the minimum interval
     59    // setting for the context has changed).
     60    void updateTimerIntervalIfNecessary();
    6161
    62         static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
     62    static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
    6363
    64     private:
    65         DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
    66         friend class Internals;
     64private:
     65    DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds interval, bool singleShot);
     66    friend class Internals;
    6767
    68         double intervalClampedToMinimum() const;
     68    double intervalClampedToMinimum() const;
    6969
    70         bool isDOMTimersThrottlingEnabled(Document&) const;
    71         void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
     70    bool isDOMTimersThrottlingEnabled(Document&) const;
     71    void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
    7272
    73         // SuspendableTimer
    74         void fired() override;
    75         void didStop() override;
    76         double alignedFireTime(double) const override;
     73    // SuspendableTimer
     74    void fired() override;
     75    void didStop() override;
     76    double alignedFireTime(double) const override;
    7777
    78         // ActiveDOMObject API.
    79         const char* activeDOMObjectName() const override;
     78    // ActiveDOMObject API.
     79    const char* activeDOMObjectName() const override;
    8080
    81         enum TimerThrottleState {
    82             Undetermined,
    83             ShouldThrottle,
    84             ShouldNotThrottle
    85         };
     81    enum TimerThrottleState {
     82        Undetermined,
     83        ShouldThrottle,
     84        ShouldNotThrottle
     85    };
    8686
    87         int m_timeoutId;
    88         int m_nestingLevel;
    89         std::unique_ptr<ScheduledAction> m_action;
    90         int m_originalInterval;
    91         TimerThrottleState m_throttleState;
    92         double m_currentTimerInterval;
    93         bool m_shouldForwardUserGesture;
    94     };
     87    int m_timeoutId;
     88    int m_nestingLevel;
     89    std::unique_ptr<ScheduledAction> m_action;
     90    std::chrono::milliseconds m_originalInterval;
     91    TimerThrottleState m_throttleState;
     92    double m_currentTimerInterval;
     93    bool m_shouldForwardUserGesture;
     94};
    9595
    9696} // namespace WebCore
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r197591 r197599  
    16041604        return -1;
    16051605    }
    1606     return DOMTimer::install(*context, WTFMove(action), timeout, true);
     1606    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true);
    16071607}
    16081608
    … …  
    16381638        return -1;
    16391639    }
    1640     return DOMTimer::install(*context, WTFMove(action), timeout, false);
     1640    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false);
    16411641}
    16421642
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r196594 r197599  
    151151int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
    152152{
    153     return DOMTimer::install(*this, WTFMove(action), timeout, true);
     153    return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), true);
    154154}
    155155
    … …  
    161161int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
    162162{
    163     return DOMTimer::install(*this, WTFMove(action), timeout, false);
     163    return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), false);
    164164}
    165165
Note: See TracChangeset for help on using the changeset viewer.