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

Side by Side Diff: remoting/base/auto_thread_task_runner.h

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 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 | « net/quic/chromium/test_task_runner.cc ('k') | remoting/base/auto_thread_task_runner.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BASE_AUTO_THREAD_TASK_RUNNER_H_ 5 #ifndef REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_
6 #define REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_ 6 #define REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 14
15 namespace remoting { 15 namespace remoting {
16 16
17 // A wrapper around |SingleThreadTaskRunner| that provides automatic lifetime 17 // A wrapper around |SingleThreadTaskRunner| that provides automatic lifetime
18 // management, by posting a caller-supplied task to the underlying task runner 18 // management, by posting a caller-supplied task to the underlying task runner
19 // when no more references remain. 19 // when no more references remain.
20 class AutoThreadTaskRunner : public base::SingleThreadTaskRunner { 20 class AutoThreadTaskRunner : public base::SingleThreadTaskRunner {
21 public: 21 public:
22 // Constructs an instance of |AutoThreadTaskRunner| wrapping |task_runner|. 22 // Constructs an instance of |AutoThreadTaskRunner| wrapping |task_runner|.
23 // |stop_task| is posted to |task_runner| when the last reference to 23 // |stop_task| is posted to |task_runner| when the last reference to
24 // the AutoThreadTaskRunner is dropped. 24 // the AutoThreadTaskRunner is dropped.
25 AutoThreadTaskRunner(scoped_refptr<base::SingleThreadTaskRunner> task_runner, 25 AutoThreadTaskRunner(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
26 base::Closure stop_task); 26 base::OnceClosure stop_task);
27 27
28 // SingleThreadTaskRunner implementation 28 // SingleThreadTaskRunner implementation
29 bool PostDelayedTask(const tracked_objects::Location& from_here, 29 bool PostDelayedTask(const tracked_objects::Location& from_here,
30 base::Closure task, 30 base::OnceClosure task,
31 base::TimeDelta delay) override; 31 base::TimeDelta delay) override;
32 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 32 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
33 base::Closure task, 33 base::OnceClosure task,
34 base::TimeDelta delay) override; 34 base::TimeDelta delay) override;
35 bool RunsTasksOnCurrentThread() const override; 35 bool RunsTasksOnCurrentThread() const override;
36 36
37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() { 37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() {
38 return task_runner_; 38 return task_runner_;
39 } 39 }
40 40
41 private: 41 private:
42 ~AutoThreadTaskRunner() override; 42 ~AutoThreadTaskRunner() override;
43 43
44 // Task posted to |task_runner_| to notify the caller that it may be stopped. 44 // Task posted to |task_runner_| to notify the caller that it may be stopped.
45 base::Closure stop_task_; 45 base::OnceClosure stop_task_;
46 46
47 // The wrapped task runner. 47 // The wrapped task runner.
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
49 49
50 DISALLOW_COPY_AND_ASSIGN(AutoThreadTaskRunner); 50 DISALLOW_COPY_AND_ASSIGN(AutoThreadTaskRunner);
51 }; 51 };
52 52
53 } // namespace remoting 53 } // namespace remoting
54 54
55 #endif // REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_ 55 #endif // REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « net/quic/chromium/test_task_runner.cc ('k') | remoting/base/auto_thread_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698