summaryrefslogtreecommitdiffstats
path: root/base/message_loop.cc
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-01 22:05:10 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-01 22:05:10 +0000
commitad5fb16613da3b87e9b271212616c6538494ba82 (patch)
tree39a79b406b12d5781da2e58642078626dee2b663 /base/message_loop.cc
parent500cc4569242f0c381c8aad56b67909ab6ba40f4 (diff)
downloadchromium_src-ad5fb16613da3b87e9b271212616c6538494ba82.zip
chromium_src-ad5fb16613da3b87e9b271212616c6538494ba82.tar.gz
chromium_src-ad5fb16613da3b87e9b271212616c6538494ba82.tar.bz2
Revert 140102 - Remove old PostDelayedTask interfaces that use int ms instead of TimeDelta.
Compile failed on ChromiumOS x86 and Tegra. BUG=108171 Review URL: https://chromiumcodereview.appspot.com/9703053 TBR=tedvessenes@gmail.com Review URL: https://chromiumcodereview.appspot.com/10496002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.cc')
-rw-r--r--base/message_loop.cc48
1 files changed, 30 insertions, 18 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 5c3b2bf..a207659 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -258,39 +258,50 @@ void MessageLoop::RemoveDestructionObserver(
void MessageLoop::PostTask(
const tracked_objects::Location& from_here, const base::Closure& task) {
DCHECK(!task.is_null()) << from_here.ToString();
- PendingTask pending_task(
- from_here, task, CalculateDelayedRuntime(TimeDelta()), true);
+ PendingTask pending_task(from_here, task, CalculateDelayedRuntime(0), true);
AddToIncomingQueue(&pending_task);
}
void MessageLoop::PostDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
- TimeDelta delay) {
+ int64 delay_ms) {
DCHECK(!task.is_null()) << from_here.ToString();
- PendingTask pending_task(
- from_here, task, CalculateDelayedRuntime(delay), true);
+ PendingTask pending_task(from_here, task,
+ CalculateDelayedRuntime(delay_ms), true);
AddToIncomingQueue(&pending_task);
}
+void MessageLoop::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ PostDelayedTask(from_here, task, delay.InMillisecondsRoundedUp());
+}
+
void MessageLoop::PostNonNestableTask(
const tracked_objects::Location& from_here, const base::Closure& task) {
DCHECK(!task.is_null()) << from_here.ToString();
- PendingTask pending_task(
- from_here, task, CalculateDelayedRuntime(TimeDelta()), false);
+ PendingTask pending_task(from_here, task, CalculateDelayedRuntime(0), false);
AddToIncomingQueue(&pending_task);
}
void MessageLoop::PostNonNestableDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task,
- TimeDelta delay) {
+ const tracked_objects::Location& from_here, const base::Closure& task,
+ int64 delay_ms) {
DCHECK(!task.is_null()) << from_here.ToString();
- PendingTask pending_task(
- from_here, task, CalculateDelayedRuntime(delay), false);
+ PendingTask pending_task(from_here, task,
+ CalculateDelayedRuntime(delay_ms), false);
AddToIncomingQueue(&pending_task);
}
+void MessageLoop::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ PostNonNestableDelayedTask(from_here, task, delay.InMillisecondsRoundedUp());
+}
+
void MessageLoop::Run() {
AutoRunState save_state(this);
RunHandler();
@@ -532,10 +543,11 @@ bool MessageLoop::DeletePendingTasks() {
return did_work;
}
-TimeTicks MessageLoop::CalculateDelayedRuntime(TimeDelta delay) {
+TimeTicks MessageLoop::CalculateDelayedRuntime(int64 delay_ms) {
TimeTicks delayed_run_time;
- if (delay > TimeDelta()) {
- delayed_run_time = TimeTicks::Now() + delay;
+ if (delay_ms > 0) {
+ delayed_run_time =
+ TimeTicks::Now() + TimeDelta::FromMilliseconds(delay_ms);
#if defined(OS_WIN)
if (high_resolution_timer_expiration_.is_null()) {
@@ -544,8 +556,8 @@ TimeTicks MessageLoop::CalculateDelayedRuntime(TimeDelta delay) {
// which as a percentage is pretty inaccurate. So enable high
// res timers for any timer which is within 2x of the granularity.
// This is a tradeoff between accuracy and power management.
- bool needs_high_res_timers = delay.InMilliseconds() <
- (2 * base::Time::kMinLowResolutionThresholdMs);
+ bool needs_high_res_timers =
+ delay_ms < (2 * base::Time::kMinLowResolutionThresholdMs);
if (needs_high_res_timers) {
if (base::Time::ActivateHighResolutionTimer(true)) {
high_resolution_timer_expiration_ = TimeTicks::Now() +
@@ -555,7 +567,7 @@ TimeTicks MessageLoop::CalculateDelayedRuntime(TimeDelta delay) {
}
#endif
} else {
- DCHECK_EQ(delay.InMilliseconds(), 0) << "delay should not be negative";
+ DCHECK_EQ(delay_ms, 0) << "delay should not be negative";
}
#if defined(OS_WIN)