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

Side by Side Diff: third_party/WebKit/Source/platform/Timer.h

Issue 2020513003: Prevent augmentRepeatInterval from computing a negative delay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/TimerTest.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 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 void stop(); 62 void stop();
63 bool isActive() const; 63 bool isActive() const;
64 const WebTraceLocation& location() const { return m_location; } 64 const WebTraceLocation& location() const { return m_location; }
65 65
66 double nextFireInterval() const; 66 double nextFireInterval() const;
67 double repeatInterval() const { return m_repeatInterval; } 67 double repeatInterval() const { return m_repeatInterval; }
68 68
69 void augmentRepeatInterval(double delta) { 69 void augmentRepeatInterval(double delta) {
70 double now = timerMonotonicallyIncreasingTime(); 70 double now = timerMonotonicallyIncreasingTime();
71 setNextFireTime(now, m_nextFireTime - now + delta); 71 setNextFireTime(now, std::max(m_nextFireTime - now + delta, 0.0));
72 m_repeatInterval += delta; 72 m_repeatInterval += delta;
73 } 73 }
74 74
75 struct PLATFORM_EXPORT Comparator { 75 struct PLATFORM_EXPORT Comparator {
76 bool operator()(const TimerBase* a, const TimerBase* b) const; 76 bool operator()(const TimerBase* a, const TimerBase* b) const;
77 }; 77 };
78 78
79 protected: 79 protected:
80 static WebTaskRunner* UnthrottledWebTaskRunner(); 80 static WebTaskRunner* UnthrottledWebTaskRunner();
81 81
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 NO_LAZY_SWEEP_SANITIZE_ADDRESS 213 NO_LAZY_SWEEP_SANITIZE_ADDRESS
214 inline bool TimerBase::isActive() const 214 inline bool TimerBase::isActive() const
215 { 215 {
216 ASSERT(m_thread == currentThread()); 216 ASSERT(m_thread == currentThread());
217 return m_cancellableTimerTask; 217 return m_cancellableTimerTask;
218 } 218 }
219 219
220 } // namespace blink 220 } // namespace blink
221 221
222 #endif // Timer_h 222 #endif // Timer_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/TimerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698