OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 class ExecutionContext; | 41 class ExecutionContext; |
42 | 42 |
43 class CORE_EXPORT DOMTimer final : public RefCountedWillBeGarbageCollectedFinali
zed<DOMTimer>, public SuspendableTimer { | 43 class CORE_EXPORT DOMTimer final : public RefCountedWillBeGarbageCollectedFinali
zed<DOMTimer>, public SuspendableTimer { |
44 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DOMTimer); | 44 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DOMTimer); |
45 public: | 45 public: |
46 // Creates a new timer owned by the ExecutionContext, starts it and returns
its ID. | 46 // Creates a new timer owned by the ExecutionContext, starts it and returns
its ID. |
47 static int install(ExecutionContext*, PassOwnPtrWillBeRawPtr<ScheduledAction
>, int timeout, bool singleShot); | 47 static int install(ExecutionContext*, PassOwnPtrWillBeRawPtr<ScheduledAction
>, int timeout, bool singleShot); |
48 static void removeByID(ExecutionContext*, int timeoutID); | 48 static void removeByID(ExecutionContext*, int timeoutID); |
49 | 49 |
50 virtual ~DOMTimer(); | 50 ~DOMTimer() override; |
51 | 51 |
52 // ActiveDOMObject | 52 // ActiveDOMObject |
53 virtual void stop() override; | 53 void stop() override; |
54 | 54 |
55 // The following are essentially constants. All intervals are in seconds. | 55 // The following are essentially constants. All intervals are in seconds. |
56 static double hiddenPageAlignmentInterval(); | 56 static double hiddenPageAlignmentInterval(); |
57 static double visiblePageAlignmentInterval(); | 57 static double visiblePageAlignmentInterval(); |
58 | 58 |
59 // Eager finalization is needed to promptly stop this Timer object. | 59 // Eager finalization is needed to promptly stop this Timer object. |
60 // Otherwise timer events might fire at an object that's slated for destruct
ion | 60 // Otherwise timer events might fire at an object that's slated for destruct
ion |
61 // (when lazily swept), but some of its members (m_action) may already have | 61 // (when lazily swept), but some of its members (m_action) may already have |
62 // been finalized & must not be accessed. | 62 // been finalized & must not be accessed. |
63 EAGERLY_FINALIZE(); | 63 EAGERLY_FINALIZE(); |
64 DECLARE_VIRTUAL_TRACE(); | 64 DECLARE_VIRTUAL_TRACE(); |
65 | 65 |
66 void disposeTimer(); | 66 void disposeTimer(); |
67 | 67 |
68 private: | 68 private: |
69 friend class DOMTimerCoordinator; // For create(). | 69 friend class DOMTimerCoordinator; // For create(). |
70 | 70 |
71 static PassRefPtrWillBeRawPtr<DOMTimer> create(ExecutionContext* context, Pa
ssOwnPtrWillBeRawPtr<ScheduledAction> action, int timeout, bool singleShot, int
timeoutID) | 71 static PassRefPtrWillBeRawPtr<DOMTimer> create(ExecutionContext* context, Pa
ssOwnPtrWillBeRawPtr<ScheduledAction> action, int timeout, bool singleShot, int
timeoutID) |
72 { | 72 { |
73 return adoptRefWillBeNoop(new DOMTimer(context, action, timeout, singleS
hot, timeoutID)); | 73 return adoptRefWillBeNoop(new DOMTimer(context, action, timeout, singleS
hot, timeoutID)); |
74 } | 74 } |
75 | 75 |
76 DOMTimer(ExecutionContext*, PassOwnPtrWillBeRawPtr<ScheduledAction>, int int
erval, bool singleShot, int timeoutID); | 76 DOMTimer(ExecutionContext*, PassOwnPtrWillBeRawPtr<ScheduledAction>, int int
erval, bool singleShot, int timeoutID); |
77 virtual void fired() override; | 77 void fired() override; |
78 | 78 |
79 // Retuns timer fire time rounded to the next multiple of timer alignment in
terval. | 79 // Retuns timer fire time rounded to the next multiple of timer alignment in
terval. |
80 virtual double alignedFireTime(double) const override; | 80 double alignedFireTime(double) const override; |
81 | 81 |
82 int m_timeoutID; | 82 int m_timeoutID; |
83 int m_nestingLevel; | 83 int m_nestingLevel; |
84 OwnPtrWillBeMember<ScheduledAction> m_action; | 84 OwnPtrWillBeMember<ScheduledAction> m_action; |
85 RefPtr<UserGestureToken> m_userGestureToken; | 85 RefPtr<UserGestureToken> m_userGestureToken; |
86 }; | 86 }; |
87 | 87 |
88 } // namespace blink | 88 } // namespace blink |
89 | 89 |
90 #endif // DOMTimer_h | 90 #endif // DOMTimer_h |
OLD | NEW |