Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: remoting/host/backoff_timer.h

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/audio_pump_unittest.cc ('k') | remoting/host/backoff_timer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
12 #include "net/base/backoff_entry.h" 13 #include "net/base/backoff_entry.h"
13 14
14 namespace remoting { 15 namespace remoting {
15 16
16 // An object similar to a base::Timer with exponential backoff. 17 // An object similar to a base::Timer with exponential backoff.
17 class BackoffTimer { 18 class BackoffTimer {
18 public: 19 public:
19 BackoffTimer(); 20 BackoffTimer();
20 ~BackoffTimer(); 21 ~BackoffTimer();
21 22
22 // Invokes |user_task| at intervals specified by |delay|, and 23 // Invokes |user_task| at intervals specified by |delay|, and
23 // increasing up to |max_delay|. Always invokes |user_task| before 24 // increasing up to |max_delay|. Always invokes |user_task| before
24 // the first scheduled delay. 25 // the first scheduled delay.
25 void Start(const tracked_objects::Location& posted_from, 26 void Start(const tracked_objects::Location& posted_from,
26 base::TimeDelta delay, 27 base::TimeDelta delay,
27 base::TimeDelta max_delay, 28 base::TimeDelta max_delay,
28 const base::Closure& user_task); 29 const base::Closure& user_task);
29 30
30 // Prevents the user task from being invoked again. 31 // Prevents the user task from being invoked again.
31 void Stop(); 32 void Stop();
32 33
33 // Returns true if the user task may be invoked in the future. 34 // Returns true if the user task may be invoked in the future.
34 bool IsRunning() const { return !!backoff_entry_; } 35 bool IsRunning() const { return !!backoff_entry_; }
35 36
36 void SetTimerForTest(scoped_ptr<base::Timer> timer); 37 void SetTimerForTest(std::unique_ptr<base::Timer> timer);
37 38
38 private: 39 private:
39 void StartTimer(); 40 void StartTimer();
40 void OnTimerFired(); 41 void OnTimerFired();
41 42
42 scoped_ptr<base::Timer> timer_; 43 std::unique_ptr<base::Timer> timer_;
43 base::Closure user_task_; 44 base::Closure user_task_;
44 tracked_objects::Location posted_from_; 45 tracked_objects::Location posted_from_;
45 net::BackoffEntry::Policy backoff_policy_ = {}; 46 net::BackoffEntry::Policy backoff_policy_ = {};
46 scoped_ptr<net::BackoffEntry> backoff_entry_; 47 std::unique_ptr<net::BackoffEntry> backoff_entry_;
47 48
48 DISALLOW_COPY_AND_ASSIGN(BackoffTimer); 49 DISALLOW_COPY_AND_ASSIGN(BackoffTimer);
49 }; 50 };
50 51
51 } // namespace remoting 52 } // namespace remoting
52 53
53 #endif // REMOTING_HOST_BACKOFF_TIMER_H_ 54 #endif // REMOTING_HOST_BACKOFF_TIMER_H_
OLDNEW
« no previous file with comments | « remoting/host/audio_pump_unittest.cc ('k') | remoting/host/backoff_timer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698