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

Side by Side Diff: Source/core/page/DOMTimer.h

Issue 19494002: Distinguish actions registered with setTimeout() and setInterval(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test, and add a new test. Created 7 years, 5 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
OLDNEW
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
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 TimerType {
44 TimerTypeTimeout,
45 TimerTypeInterval
Ken Russell (switch to Gerrit) 2013/07/18 19:05:13 This seems verbose; since it's scoped in DOMTimer,
Yuta Kitamura 2013/07/19 05:14:08 Done.
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*, TimerType, PassOwnPtr<ScheduledA ction>, int timeout);
45 static void removeByID(ScriptExecutionContext*, int timeoutID); 50 static void removeByIDIfTypeMatches(ScriptExecutionContext*, TimerType, int timeoutID);
46 51
47 virtual ~DOMTimer(); 52 virtual ~DOMTimer();
48 53
49 int timeoutID() const; 54 int timeoutID() const;
55 TimerType timerType() 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 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; 61 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
56 62
57 // The following are essentially constants. All intervals are in seconds. 63 // The following are essentially constants. All intervals are in seconds.
58 static double hiddenPageAlignmentInterval(); 64 static double hiddenPageAlignmentInterval();
59 static double visiblePageAlignmentInterval(); 65 static double visiblePageAlignmentInterval();
60 66
61 private: 67 private:
62 friend class ScriptExecutionContext; // For create(). 68 friend class ScriptExecutionContext; // For create().
63 69
64 // Should only be used by ScriptExecutionContext. 70 // Should only be used by ScriptExecutionContext.
65 static PassOwnPtr<DOMTimer> create(ScriptExecutionContext* context, PassOwnP tr<ScheduledAction> action, int timeout, bool singleShot, int timeoutID) 71 static PassOwnPtr<DOMTimer> create(ScriptExecutionContext* context, TimerTyp e timerType, PassOwnPtr<ScheduledAction> action, int timeout, int timeoutID)
66 { 72 {
67 return adoptPtr(new DOMTimer(context, action, timeout, singleShot, timeo utID)); 73 return adoptPtr(new DOMTimer(context, timerType, action, timeout, timeou tID));
68 } 74 }
69 75
70 DOMTimer(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int interval, bool singleShot, int timeoutID); 76 DOMTimer(ScriptExecutionContext*, TimerType, PassOwnPtr<ScheduledAction>, in t interval, int timeoutID);
71 virtual void fired(); 77 virtual void fired() OVERRIDE;
72 78
73 // Retuns timer fire time rounded to the next multiple of timer alignment in terval. 79 // Returns timer fire time rounded to the next multiple of timer alignment i nterval.
74 virtual double alignedFireTime(double) const; 80 virtual double alignedFireTime(double) const OVERRIDE;
75 81
82 TimerType m_timerType;
76 int m_timeoutID; 83 int m_timeoutID;
77 int m_nestingLevel; 84 int m_nestingLevel;
78 OwnPtr<ScheduledAction> m_action; 85 OwnPtr<ScheduledAction> m_action;
79 RefPtr<UserGestureToken> m_userGestureToken; 86 RefPtr<UserGestureToken> m_userGestureToken;
80 }; 87 };
81 88
82 } // namespace WebCore 89 } // namespace WebCore
83 90
84 #endif // DOMTimer_h 91 #endif // DOMTimer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698