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

Side by Side Diff: cc/CCDelayBasedTimeSource.cpp

Issue 10947047: Fix remaining cc files to compile with Clang (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: All remaining files Created 8 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCDelayBasedTimeSource.h" 7 #include "CCDelayBasedTimeSource.h"
8 8
9 #include "TraceEvent.h" 9 #include "TraceEvent.h"
10 #include <algorithm> 10 #include <algorithm>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 m_timer.startOneShot(0); 66 m_timer.startOneShot(0);
67 return; 67 return;
68 } 68 }
69 69
70 m_state = STATE_ACTIVE; 70 m_state = STATE_ACTIVE;
71 71
72 double now = monotonicTimeNow(); 72 double now = monotonicTimeNow();
73 postNextTickTask(now); 73 postNextTickTask(now);
74 } 74 }
75 75
76 bool CCDelayBasedTimeSource::active() const
77 {
78 return m_state != STATE_INACTIVE;
79 }
80
76 double CCDelayBasedTimeSource::lastTickTime() 81 double CCDelayBasedTimeSource::lastTickTime()
77 { 82 {
78 return m_lastTickTime; 83 return m_lastTickTime;
79 } 84 }
80 85
81 double CCDelayBasedTimeSource::nextTickTimeIfActivated() 86 double CCDelayBasedTimeSource::nextTickTimeIfActivated()
82 { 87 {
83 return active() ? m_currentParameters.tickTarget : nextTickTarget(monotonicT imeNow()); 88 return active() ? m_currentParameters.tickTarget : nextTickTarget(monotonicT imeNow());
84 } 89 }
85 90
86 void CCDelayBasedTimeSource::onTimerFired() 91 void CCDelayBasedTimeSource::onTimerFired()
87 { 92 {
88 ASSERT(m_state != STATE_INACTIVE); 93 ASSERT(m_state != STATE_INACTIVE);
89 94
90 double now = monotonicTimeNow(); 95 double now = monotonicTimeNow();
91 m_lastTickTime = now; 96 m_lastTickTime = now;
92 97
93 if (m_state == STATE_STARTING) { 98 if (m_state == STATE_STARTING) {
94 setTimebaseAndInterval(now, m_currentParameters.interval); 99 setTimebaseAndInterval(now, m_currentParameters.interval);
95 m_state = STATE_ACTIVE; 100 m_state = STATE_ACTIVE;
96 } 101 }
97 102
98 postNextTickTask(now); 103 postNextTickTask(now);
99 104
100 // Fire the tick 105 // Fire the tick
101 if (m_client) 106 if (m_client)
102 m_client->onTimerTick(); 107 m_client->onTimerTick();
103 } 108 }
104 109
110 void CCDelayBasedTimeSource::setClient(CCTimeSourceClient* client)
111 {
112 m_client = client;
113 }
114
105 void CCDelayBasedTimeSource::setTimebaseAndInterval(double timebase, double inte rvalSeconds) 115 void CCDelayBasedTimeSource::setTimebaseAndInterval(double timebase, double inte rvalSeconds)
106 { 116 {
107 m_nextParameters.interval = intervalSeconds; 117 m_nextParameters.interval = intervalSeconds;
108 m_nextParameters.tickTarget = timebase; 118 m_nextParameters.tickTarget = timebase;
109 m_hasTickTarget = true; 119 m_hasTickTarget = true;
110 120
111 if (m_state != STATE_ACTIVE) { 121 if (m_state != STATE_ACTIVE) {
112 // If we aren't active, there's no need to reset the timer. 122 // If we aren't active, there's no need to reset the timer.
113 return; 123 return;
114 } 124 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Post another task *before* the tick and update state 222 // Post another task *before* the tick and update state
213 double delay = newTickTarget - now; 223 double delay = newTickTarget - now;
214 ASSERT(delay <= m_nextParameters.interval * (1.0 + doubleTickThreshold)); 224 ASSERT(delay <= m_nextParameters.interval * (1.0 + doubleTickThreshold));
215 m_timer.startOneShot(delay); 225 m_timer.startOneShot(delay);
216 226
217 m_nextParameters.tickTarget = newTickTarget; 227 m_nextParameters.tickTarget = newTickTarget;
218 m_currentParameters = m_nextParameters; 228 m_currentParameters = m_nextParameters;
219 } 229 }
220 230
221 } 231 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698