Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: Source/core/frame/DOMTimerCoordinator.h

Issue 1334243004: Post DOMTimers on the corresponding LocalFrame's timer queue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed layout test failures. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/DOMTimer.cpp ('k') | Source/core/frame/DOMTimerCoordinator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DOMTimerCoordinator_h 5 #ifndef DOMTimerCoordinator_h
6 #define DOMTimerCoordinator_h 6 #define DOMTimerCoordinator_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "wtf/Noncopyable.h" 9 #include "wtf/Noncopyable.h"
10 #include "wtf/PassOwnPtr.h" 10 #include "wtf/PassOwnPtr.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class DOMTimer; 14 class DOMTimer;
15 class ExecutionContext; 15 class ExecutionContext;
16 class ScheduledAction; 16 class ScheduledAction;
17 class WebTaskRunner;
17 18
18 // Maintains a set of DOMTimers for a given page or 19 // Maintains a set of DOMTimers for a given page or
19 // worker. DOMTimerCoordinator assigns IDs to timers; these IDs are 20 // worker. DOMTimerCoordinator assigns IDs to timers; these IDs are
20 // the ones returned to web authors from setTimeout or setInterval. It 21 // the ones returned to web authors from setTimeout or setInterval. It
21 // also tracks recursive creation or iterative scheduling of timers, 22 // also tracks recursive creation or iterative scheduling of timers,
22 // which is used as a signal for throttling repetitive timers. 23 // which is used as a signal for throttling repetitive timers.
23 class DOMTimerCoordinator { 24 class DOMTimerCoordinator {
24 DISALLOW_ALLOCATION(); 25 DISALLOW_ALLOCATION();
25 WTF_MAKE_NONCOPYABLE(DOMTimerCoordinator); 26 WTF_MAKE_NONCOPYABLE(DOMTimerCoordinator);
26 public: 27 public:
27 DOMTimerCoordinator(); 28 explicit DOMTimerCoordinator(WebTaskRunner*);
28 29
29 // Creates and installs a new timer. Returns the assigned ID. 30 // Creates and installs a new timer. Returns the assigned ID.
30 int installNewTimeout(ExecutionContext*, PassOwnPtrWillBeRawPtr<ScheduledAct ion>, int timeout, bool singleShot); 31 int installNewTimeout(ExecutionContext*, PassOwnPtrWillBeRawPtr<ScheduledAct ion>, int timeout, bool singleShot);
31 32
32 // Removes and disposes the timer with the specified ID, if any. This may 33 // Removes and disposes the timer with the specified ID, if any. This may
33 // destroy the timer. 34 // destroy the timer.
34 void removeTimeoutByID(int id); 35 void removeTimeoutByID(int id);
35 36
36 // Notifies registered timers that 37 // Notifies registered timers that
37 // ExecutionContext::timerAlignmentInterval has changed so that 38 // ExecutionContext::timerAlignmentInterval has changed so that
38 // timers can adjust their schedule to the new alignment interval. 39 // timers can adjust their schedule to the new alignment interval.
39 void didChangeTimerAlignmentInterval(); 40 void didChangeTimerAlignmentInterval();
40 41
41 // Timers created during the execution of other timers, and 42 // Timers created during the execution of other timers, and
42 // repeating timers, are throttled. Timer nesting level tracks the 43 // repeating timers, are throttled. Timer nesting level tracks the
43 // number of linked timers or repetitions of a timer. See 44 // number of linked timers or repetitions of a timer. See
44 // https://html.spec.whatwg.org/#timers 45 // https://html.spec.whatwg.org/#timers
45 int timerNestingLevel() { return m_timerNestingLevel; } 46 int timerNestingLevel() { return m_timerNestingLevel; }
46 47
47 // Sets the timer nesting level. Set when a timer executes so that 48 // Sets the timer nesting level. Set when a timer executes so that
48 // any timers created while the timer is executing will incur a 49 // any timers created while the timer is executing will incur a
49 // deeper timer nesting level, see DOMTimer::DOMTimer. 50 // deeper timer nesting level, see DOMTimer::DOMTimer.
50 void setTimerNestingLevel(int level) { m_timerNestingLevel = level; } 51 void setTimerNestingLevel(int level) { m_timerNestingLevel = level; }
51 52
53 void setTimerTaskRunner(WebTaskRunner* timerTaskRunner) { m_timerTaskRunner = timerTaskRunner; }
54
55 WebTaskRunner* timerTaskRunner() const { return m_timerTaskRunner; }
56
52 DECLARE_TRACE(); // Oilpan. 57 DECLARE_TRACE(); // Oilpan.
53 58
54 private: 59 private:
55 int nextID(); 60 int nextID();
56 61
57 using TimeoutMap = WillBeHeapHashMap<int, RefPtrWillBeMember<DOMTimer>>; 62 using TimeoutMap = WillBeHeapHashMap<int, RefPtrWillBeMember<DOMTimer>>;
58 TimeoutMap m_timers; 63 TimeoutMap m_timers;
59 64
60 int m_circularSequentialID; 65 int m_circularSequentialID;
61 int m_timerNestingLevel; 66 int m_timerNestingLevel;
67 WebTaskRunner* m_timerTaskRunner; // NOT OWNED
62 }; 68 };
63 69
64 } // namespace blink 70 } // namespace blink
65 71
66 #endif // DOMTimerCoordinator_h 72 #endif // DOMTimerCoordinator_h
OLDNEW
« no previous file with comments | « Source/core/frame/DOMTimer.cpp ('k') | Source/core/frame/DOMTimerCoordinator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698