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 #ifndef REMOTING_HOST_BACKOFF_TIMER_H_ | 5 #ifndef REMOTING_HOST_BACKOFF_TIMER_H_ |
6 #define REMOTING_HOST_BACKOFF_TIMER_H_ | 6 #define REMOTING_HOST_BACKOFF_TIMER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 base::TimeDelta delay, | 25 base::TimeDelta delay, |
26 base::TimeDelta max_delay, | 26 base::TimeDelta max_delay, |
27 const base::Closure& user_task); | 27 const base::Closure& user_task); |
28 | 28 |
29 // Prevents the user task from being invoked again. | 29 // Prevents the user task from being invoked again. |
30 void Stop(); | 30 void Stop(); |
31 | 31 |
32 // Returns true if the user task may be invoked in the future. | 32 // Returns true if the user task may be invoked in the future. |
33 bool IsRunning() const { return backoff_entry_; } | 33 bool IsRunning() const { return backoff_entry_; } |
34 | 34 |
35 void SetTimerForTest(scoped_ptr<base::Timer> timer) { timer_ = timer.Pass(); } | 35 void SetTimerForTest(scoped_ptr<base::Timer> timer) { |
| 36 timer_ = std::move(timer); |
| 37 } |
36 | 38 |
37 private: | 39 private: |
38 void StartTimer(); | 40 void StartTimer(); |
39 void OnTimerFired(); | 41 void OnTimerFired(); |
40 | 42 |
41 scoped_ptr<base::Timer> timer_; | 43 scoped_ptr<base::Timer> timer_; |
42 base::Closure user_task_; | 44 base::Closure user_task_; |
43 tracked_objects::Location posted_from_; | 45 tracked_objects::Location posted_from_; |
44 net::BackoffEntry::Policy backoff_policy_ = {}; | 46 net::BackoffEntry::Policy backoff_policy_ = {}; |
45 scoped_ptr<net::BackoffEntry> backoff_entry_; | 47 scoped_ptr<net::BackoffEntry> backoff_entry_; |
46 | 48 |
47 DISALLOW_COPY_AND_ASSIGN(BackoffTimer); | 49 DISALLOW_COPY_AND_ASSIGN(BackoffTimer); |
48 }; | 50 }; |
49 | 51 |
50 } // namespace remoting | 52 } // namespace remoting |
51 | 53 |
52 #endif // REMOTING_HOST_BACKOFF_TIMER_H_ | 54 #endif // REMOTING_HOST_BACKOFF_TIMER_H_ |
OLD | NEW |