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

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

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/backoff_timer.h ('k') | remoting/host/backoff_timer_unittest.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 #include "remoting/host/backoff_timer.h" 5 #include "remoting/host/backoff_timer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 namespace remoting { 9 namespace remoting {
10 10
(...skipping 15 matching lines...) Expand all
26 user_task_ = user_task; 26 user_task_ = user_task;
27 StartTimer(); 27 StartTimer();
28 } 28 }
29 29
30 void BackoffTimer::Stop() { 30 void BackoffTimer::Stop() {
31 timer_->Stop(); 31 timer_->Stop();
32 user_task_.Reset(); 32 user_task_.Reset();
33 backoff_entry_.reset(); 33 backoff_entry_.reset();
34 }; 34 };
35 35
36 void BackoffTimer::SetTimerForTest(scoped_ptr<base::Timer> timer) { 36 void BackoffTimer::SetTimerForTest(std::unique_ptr<base::Timer> timer) {
37 timer_ = std::move(timer); 37 timer_ = std::move(timer);
38 } 38 }
39 39
40 void BackoffTimer::StartTimer() { 40 void BackoffTimer::StartTimer() {
41 timer_->Start( 41 timer_->Start(
42 posted_from_, backoff_entry_->GetTimeUntilRelease(), 42 posted_from_, backoff_entry_->GetTimeUntilRelease(),
43 base::Bind(&BackoffTimer::OnTimerFired, base::Unretained(this))); 43 base::Bind(&BackoffTimer::OnTimerFired, base::Unretained(this)));
44 } 44 }
45 45
46 void BackoffTimer::OnTimerFired() { 46 void BackoffTimer::OnTimerFired() {
47 DCHECK(IsRunning()); 47 DCHECK(IsRunning());
48 DCHECK(!user_task_.is_null()); 48 DCHECK(!user_task_.is_null());
49 backoff_entry_->InformOfRequest(false); 49 backoff_entry_->InformOfRequest(false);
50 StartTimer(); 50 StartTimer();
51 51
52 // Running the user task may destroy this object, so don't reference 52 // Running the user task may destroy this object, so don't reference
53 // any fields of this object after running it. 53 // any fields of this object after running it.
54 base::Closure user_task(user_task_); 54 base::Closure user_task(user_task_);
55 user_task.Run(); 55 user_task.Run();
56 } 56 }
57 57
58 } // namespace remoting 58 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/backoff_timer.h ('k') | remoting/host/backoff_timer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698