OLD | NEW |
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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 | 13 |
14 class MessageLoop; | |
15 | |
16 namespace remoting { | 14 namespace remoting { |
17 | 15 |
18 // A wrapper around |SingleThreadTaskRunner| that provides automatic lifetime | 16 // A wrapper around |SingleThreadTaskRunner| that provides automatic lifetime |
19 // management, by posting a caller-supplied task to the underlying task runner | 17 // management, by posting a caller-supplied task to the underlying task runner |
20 // when no more references remain. | 18 // when no more references remain. |
21 class AutoThreadTaskRunner : public base::SingleThreadTaskRunner { | 19 class AutoThreadTaskRunner : public base::SingleThreadTaskRunner { |
22 public: | 20 public: |
23 // Constructs an instance of |AutoThreadTaskRunner| wrapping |task_runner|. | 21 // Constructs an instance of |AutoThreadTaskRunner| wrapping |task_runner|. |
24 // |stop_task| is posted to |task_runner| when the last reference to | 22 // |stop_task| is posted to |task_runner| when the last reference to |
25 // the AutoThreadTaskRunner is dropped. | 23 // the AutoThreadTaskRunner is dropped. |
(...skipping 19 matching lines...) Expand all Loading... |
45 | 43 |
46 // The wrapped task runner. | 44 // The wrapped task runner. |
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 45 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
48 | 46 |
49 DISALLOW_COPY_AND_ASSIGN(AutoThreadTaskRunner); | 47 DISALLOW_COPY_AND_ASSIGN(AutoThreadTaskRunner); |
50 }; | 48 }; |
51 | 49 |
52 } // namespace remoting | 50 } // namespace remoting |
53 | 51 |
54 #endif // REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_ | 52 #endif // REMOTING_BASE_AUTO_THREAD_TASK_RUNNER_H_ |
OLD | NEW |