Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "wtf/Atomics.h" | 33 #include "wtf/Atomics.h" |
| 34 #include "wtf/CurrentTime.h" | 34 #include "wtf/CurrentTime.h" |
| 35 #include "wtf/HashSet.h" | 35 #include "wtf/HashSet.h" |
| 36 #include <algorithm> | 36 #include <algorithm> |
| 37 #include <limits.h> | 37 #include <limits.h> |
| 38 #include <limits> | 38 #include <limits> |
| 39 #include <math.h> | 39 #include <math.h> |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 TimerBase::TimerBase() : TimerBase(Platform::current()->currentThread()->schedul er()->timerTaskRunner()) { } | |
| 44 | |
| 45 TimerBase::TimerBase(WebTaskRunner* webTaskRunner) | 43 TimerBase::TimerBase(WebTaskRunner* webTaskRunner) |
| 46 : m_nextFireTime(0) | 44 : m_nextFireTime(0) |
| 47 , m_repeatInterval(0) | 45 , m_repeatInterval(0) |
| 48 , m_cancellableTimerTask(nullptr) | 46 , m_cancellableTimerTask(nullptr) |
| 49 , m_webTaskRunner(webTaskRunner) | 47 , m_webTaskRunner(webTaskRunner) |
| 50 #if DCHECK_IS_ON() | 48 #if DCHECK_IS_ON() |
| 51 , m_thread(currentThread()) | 49 , m_thread(currentThread()) |
| 52 #endif | 50 #endif |
| 53 { | 51 { |
| 54 ASSERT(m_webTaskRunner); | 52 ASSERT(m_webTaskRunner); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 81 | 79 |
| 82 double TimerBase::nextFireInterval() const | 80 double TimerBase::nextFireInterval() const |
| 83 { | 81 { |
| 84 ASSERT(isActive()); | 82 ASSERT(isActive()); |
| 85 double current = timerMonotonicallyIncreasingTime(); | 83 double current = timerMonotonicallyIncreasingTime(); |
| 86 if (m_nextFireTime < current) | 84 if (m_nextFireTime < current) |
| 87 return 0; | 85 return 0; |
| 88 return m_nextFireTime - current; | 86 return m_nextFireTime - current; |
| 89 } | 87 } |
| 90 | 88 |
| 89 // static | |
| 90 WebTaskRunner* TimerBase::getTimerTaskRunner() | |
| 91 { | |
| 92 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); | |
| 93 } | |
| 94 | |
| 95 // static | |
| 96 WebTaskRunner* TimerBase::getDefaultTaskRunner() | |
|
haraken
2016/07/28 14:44:46
getDefaultTaskRunner => getUnthrottledTaskRunner ?
Sami
2016/07/28 16:38:55
+1
dcheng
2016/07/29 02:23:18
Done.
| |
| 97 { | |
| 98 return Platform::current()->currentThread()->getWebTaskRunner(); | |
| 99 } | |
| 100 | |
| 91 WebTaskRunner* TimerBase::timerTaskRunner() const | 101 WebTaskRunner* TimerBase::timerTaskRunner() const |
| 92 { | 102 { |
| 93 return m_webTaskRunner; | 103 return m_webTaskRunner; |
| 94 } | 104 } |
| 95 | 105 |
| 96 void TimerBase::setNextFireTime(double now, double delay) | 106 void TimerBase::setNextFireTime(double now, double delay) |
| 97 { | 107 { |
| 98 ASSERT(m_thread == currentThread()); | 108 ASSERT(m_thread == currentThread()); |
| 99 | 109 |
| 100 double newTime = now + delay; | 110 double newTime = now + delay; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 fired(); | 146 fired(); |
| 137 TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping"); | 147 TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping"); |
| 138 } | 148 } |
| 139 | 149 |
| 140 bool TimerBase::Comparator::operator()(const TimerBase* a, const TimerBase* b) c onst | 150 bool TimerBase::Comparator::operator()(const TimerBase* a, const TimerBase* b) c onst |
| 141 { | 151 { |
| 142 return a->m_nextFireTime < b->m_nextFireTime; | 152 return a->m_nextFireTime < b->m_nextFireTime; |
| 143 } | 153 } |
| 144 | 154 |
| 145 // static | 155 // static |
| 146 WebTaskRunner* TimerBase::UnthrottledWebTaskRunner() | |
| 147 { | |
| 148 return Platform::current()->currentThread()->getWebTaskRunner(); | |
| 149 } | |
| 150 | |
| 151 double TimerBase::timerMonotonicallyIncreasingTime() const | 156 double TimerBase::timerMonotonicallyIncreasingTime() const |
| 152 { | 157 { |
| 153 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); | 158 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); |
| 154 } | 159 } |
| 155 | 160 |
| 156 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |