license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 4 | |
5 | #include "base/timer.h" | ||||
[email protected] | a5b94a9 | 2008-08-12 23:25:43 | [diff] [blame] | 6 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 7 | #include "base/message_loop.h" |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 8 | |
[email protected] | aeab57ea | 2008-08-28 20:50:12 | [diff] [blame] | 9 | namespace base { |
10 | |||||
[email protected] | aeab57ea | 2008-08-28 20:50:12 | [diff] [blame] | 11 | void BaseTimer_Helper::OrphanDelayedTask() { |
12 | if (delayed_task_) { | ||||
13 | delayed_task_->timer_ = NULL; | ||||
14 | delayed_task_ = NULL; | ||||
15 | } | ||||
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 16 | } |
17 | |||||
[email protected] | aeab57ea | 2008-08-28 20:50:12 | [diff] [blame] | 18 | void BaseTimer_Helper::InitiateDelayedTask(TimerTask* timer_task) { |
19 | OrphanDelayedTask(); | ||||
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 20 | |
[email protected] | aeab57ea | 2008-08-28 20:50:12 | [diff] [blame] | 21 | delayed_task_ = timer_task; |
22 | delayed_task_->timer_ = this; | ||||
23 | MessageLoop::current()->PostDelayedTask( | ||||
[email protected] | d323a17 | 2011-09-02 18:23:02 | [diff] [blame] | 24 | timer_task->posted_from_, timer_task, |
[email protected] | 6b17538 | 2009-10-13 06:47:47 | [diff] [blame] | 25 | static_cast<int>(timer_task->delay_.InMillisecondsRoundedUp())); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 26 | } |
27 | |||||
[email protected] | aeab57ea | 2008-08-28 20:50:12 | [diff] [blame] | 28 | } // namespace base |