Chromium Code Reviews| Index: chrome/renderer/net/mockable_one_shot_timer.cc |
| diff --git a/chrome/renderer/net/mockable_one_shot_timer.cc b/chrome/renderer/net/mockable_one_shot_timer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b0352a2f71d23d0d5bb6dcf3e2d350eda27015f6 |
| --- /dev/null |
| +++ b/chrome/renderer/net/mockable_one_shot_timer.cc |
| @@ -0,0 +1,30 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +// MockableOneShotTimer implementation in terms of base::OneShotTimer |
| + |
| +#include "chrome/renderer/net/mockable_one_shot_timer.h" |
| + |
| +MockableOneShotTimer::MockableOneShotTimer() {} |
| +MockableOneShotTimer::~MockableOneShotTimer() {} |
| + |
| +void MockableOneShotTimer::Fired() { |
| + user_task_.Run(); |
| +} |
| + |
| +void MockableOneShotTimer::Start( |
| + const tracked_objects::Location& posted_from, base::TimeDelta delay, |
| + const base::Closure& user_task) { |
|
mmenke
2014/02/05 23:31:43
DCHECK(!user_task.is_empty())? (Or is_null, which
Elly Fong-Jones
2014/02/10 21:42:06
I don't think one can do that.
|
| + user_task_ = user_task; |
| + timer_.Start(posted_from, delay, |
| + base::Bind(&MockableOneShotTimer::Fired, |
| + base::Unretained(this))); |
| +} |
| + |
| +void MockableOneShotTimer::Stop() { |
| + timer_.Stop(); |
| +} |
| + |
| +bool MockableOneShotTimer::IsRunning() const { |
| + return timer_.IsRunning(); |
| +} |