| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/component_updater/timer.h" | 5 #include "components/component_updater/timer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 | 10 |
| 11 namespace component_updater { | 11 namespace component_updater { |
| 12 | 12 |
| 13 Timer::Timer() : timer_(false, false) { | 13 Timer::Timer() {} |
| 14 } | |
| 15 | 14 |
| 16 Timer::~Timer() { | 15 Timer::~Timer() { |
| 17 DCHECK(thread_checker_.CalledOnValidThread()); | 16 DCHECK(thread_checker_.CalledOnValidThread()); |
| 18 Stop(); | 17 Stop(); |
| 19 } | 18 } |
| 20 | 19 |
| 21 void Timer::Start(base::TimeDelta initial_delay, | 20 void Timer::Start(base::TimeDelta initial_delay, |
| 22 base::TimeDelta delay, | 21 base::TimeDelta delay, |
| 23 const base::Closure& user_task) { | 22 const base::Closure& user_task) { |
| 24 DCHECK(thread_checker_.CalledOnValidThread()); | 23 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 void Timer::OnDelay() { | 37 void Timer::OnDelay() { |
| 39 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
| 40 | 39 |
| 41 user_task_.Run(); | 40 user_task_.Run(); |
| 42 | 41 |
| 43 timer_.Start(FROM_HERE, delay_, | 42 timer_.Start(FROM_HERE, delay_, |
| 44 base::Bind(&Timer::OnDelay, base::Unretained(this))); | 43 base::Bind(&Timer::OnDelay, base::Unretained(this))); |
| 45 } | 44 } |
| 46 | 45 |
| 47 } // namespace component_updater | 46 } // namespace component_updater |
| OLD | NEW |