| 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 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/Compiler.h" | 33 #include "wtf/Compiler.h" |
| 34 #include "wtf/OwnPtr.h" | 34 #include "wtf/OwnPtr.h" |
| 35 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 class ScriptExecutionContext; | 39 class ScriptExecutionContext; |
| 40 | 40 |
| 41 class DOMTimer : public SuspendableTimer { | 41 class DOMTimer : public SuspendableTimer { |
| 42 public: | 42 public: |
| 43 enum Type { |
| 44 TimeoutType, |
| 45 IntervalType |
| 46 }; |
| 47 |
| 43 // Creates a new timer owned by the ScriptExecutionContext, starts it and re
turns its ID. | 48 // Creates a new timer owned by the ScriptExecutionContext, starts it and re
turns its ID. |
| 44 static int install(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int
timeout, bool singleShot); | 49 static int install(ScriptExecutionContext*, Type, PassOwnPtr<ScheduledAction
>, int timeout); |
| 45 static void removeByID(ScriptExecutionContext*, int timeoutID); | 50 static void removeByIDIfTypeMatches(ScriptExecutionContext*, Type, int timeo
utID); |
| 46 | 51 |
| 47 virtual ~DOMTimer(); | 52 virtual ~DOMTimer(); |
| 48 | 53 |
| 49 int timeoutID() const; | 54 int timeoutID() const; |
| 55 Type type() const; |
| 50 | 56 |
| 51 // ActiveDOMObject | 57 // ActiveDOMObject |
| 52 virtual void contextDestroyed() OVERRIDE; | 58 virtual void contextDestroyed() OVERRIDE; |
| 53 virtual void stop() OVERRIDE; | 59 virtual void stop() OVERRIDE; |
| 54 | 60 |
| 55 // The following are essentially constants. All intervals are in seconds. | 61 // The following are essentially constants. All intervals are in seconds. |
| 56 static double hiddenPageAlignmentInterval(); | 62 static double hiddenPageAlignmentInterval(); |
| 57 static double visiblePageAlignmentInterval(); | 63 static double visiblePageAlignmentInterval(); |
| 58 | 64 |
| 59 private: | 65 private: |
| 60 friend class ScriptExecutionContext; // For create(). | 66 friend class ScriptExecutionContext; // For create(). |
| 61 | 67 |
| 62 // Should only be used by ScriptExecutionContext. | 68 // Should only be used by ScriptExecutionContext. |
| 63 static PassOwnPtr<DOMTimer> create(ScriptExecutionContext* context, PassOwnP
tr<ScheduledAction> action, int timeout, bool singleShot, int timeoutID) | 69 static PassOwnPtr<DOMTimer> create(ScriptExecutionContext* context, Type typ
e, PassOwnPtr<ScheduledAction> action, int timeout, int timeoutID) |
| 64 { | 70 { |
| 65 return adoptPtr(new DOMTimer(context, action, timeout, singleShot, timeo
utID)); | 71 return adoptPtr(new DOMTimer(context, type, action, timeout, timeoutID))
; |
| 66 } | 72 } |
| 67 | 73 |
| 68 DOMTimer(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int interval,
bool singleShot, int timeoutID); | 74 DOMTimer(ScriptExecutionContext*, Type, PassOwnPtr<ScheduledAction>, int int
erval, int timeoutID); |
| 69 virtual void fired(); | 75 virtual void fired() OVERRIDE; |
| 70 | 76 |
| 71 // Retuns timer fire time rounded to the next multiple of timer alignment in
terval. | 77 // Returns timer fire time rounded to the next multiple of timer alignment i
nterval. |
| 72 virtual double alignedFireTime(double) const; | 78 virtual double alignedFireTime(double) const OVERRIDE; |
| 73 | 79 |
| 80 Type m_type; |
| 74 int m_timeoutID; | 81 int m_timeoutID; |
| 75 int m_nestingLevel; | 82 int m_nestingLevel; |
| 76 OwnPtr<ScheduledAction> m_action; | 83 OwnPtr<ScheduledAction> m_action; |
| 77 RefPtr<UserGestureToken> m_userGestureToken; | 84 RefPtr<UserGestureToken> m_userGestureToken; |
| 78 }; | 85 }; |
| 79 | 86 |
| 80 } // namespace WebCore | 87 } // namespace WebCore |
| 81 | 88 |
| 82 #endif // DOMTimer_h | 89 #endif // DOMTimer_h |
| OLD | NEW |