summaryrefslogtreecommitdiffstats
path: root/base/message_loop.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-06 22:23:29 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-06 22:23:29 +0000
commit7e7fab44ba1068bdce201757e82b6650fbca455d (patch)
treea25d1d1235e61672c95d66a7a287cc47f175799f /base/message_loop.cc
parentffb65401dabf6ce5a74fcc416690b2525168ab8a (diff)
downloadchromium_src-7e7fab44ba1068bdce201757e82b6650fbca455d.zip
chromium_src-7e7fab44ba1068bdce201757e82b6650fbca455d.tar.gz
chromium_src-7e7fab44ba1068bdce201757e82b6650fbca455d.tar.bz2
Switch to using TimeTicks rather than Time in message loops
Switch to using TimeTicks rather than Time so that we are not dependent on changes in the system clock. r=mbelshe,darin Review URL: http://codereview.chromium.org/3884001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.cc')
-rw-r--r--base/message_loop.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc
index b860fd8..efbced1b 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -29,6 +29,7 @@
using base::Time;
using base::TimeDelta;
+using base::TimeTicks;
namespace {
@@ -332,7 +333,7 @@ void MessageLoop::PostTask_Helper(
if (delay_ms > 0) {
pending_task.delayed_run_time =
- Time::Now() + TimeDelta::FromMilliseconds(delay_ms);
+ TimeTicks::Now() + TimeDelta::FromMilliseconds(delay_ms);
#if defined(OS_WIN)
if (high_resolution_timer_expiration_.is_null()) {
@@ -345,7 +346,7 @@ void MessageLoop::PostTask_Helper(
delay_ms < (2 * Time::kMinLowResolutionThresholdMs);
if (needs_high_res_timers) {
Time::ActivateHighResolutionTimer(true);
- high_resolution_timer_expiration_ = base::TimeTicks::Now() +
+ high_resolution_timer_expiration_ = TimeTicks::Now() +
TimeDelta::FromMilliseconds(kHighResolutionTimerModeLeaseTimeMs);
}
}
@@ -356,9 +357,9 @@ void MessageLoop::PostTask_Helper(
#if defined(OS_WIN)
if (!high_resolution_timer_expiration_.is_null()) {
- if (base::TimeTicks::Now() > high_resolution_timer_expiration_) {
+ if (TimeTicks::Now() > high_resolution_timer_expiration_) {
Time::ActivateHighResolutionTimer(false);
- high_resolution_timer_expiration_ = base::TimeTicks();
+ high_resolution_timer_expiration_ = TimeTicks();
}
}
#endif
@@ -540,21 +541,22 @@ bool MessageLoop::DoWork() {
return false;
}
-bool MessageLoop::DoDelayedWork(base::Time* next_delayed_work_time) {
+bool MessageLoop::DoDelayedWork(base::TimeTicks* next_delayed_work_time) {
if (!nestable_tasks_allowed_ || delayed_work_queue_.empty()) {
- recent_time_ = *next_delayed_work_time = base::Time();
+ recent_time_ = *next_delayed_work_time = TimeTicks();
return false;
}
- // When we "fall behind," there may be a lot of tasks in the delayed work
+ // When we "fall behind," there will be a lot of tasks in the delayed work
// queue that are ready to run. To increase efficiency when we fall behind,
// we will only call Time::Now() intermittently, and then process all tasks
// that are ready to run before calling it again. As a result, the more we
// fall behind (and have a lot of ready-to-run delayed tasks), the more
// efficient we'll be at handling the tasks.
- base::Time next_run_time = delayed_work_queue_.top().delayed_run_time;
+
+ TimeTicks next_run_time = delayed_work_queue_.top().delayed_run_time;
if (next_run_time > recent_time_) {
- recent_time_ = base::Time::Now(); // Get a better view of Now().
+ recent_time_ = TimeTicks::Now(); // Get a better view of Now();
if (next_run_time > recent_time_) {
*next_delayed_work_time = next_run_time;
return false;