OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 JINGLE_NOTIFIER_BASE_TASK_PUMP_H_ | 5 #ifndef JINGLE_NOTIFIER_BASE_TASK_PUMP_H_ |
6 #define JINGLE_NOTIFIER_BASE_TASK_PUMP_H_ | 6 #define JINGLE_NOTIFIER_BASE_TASK_PUMP_H_ |
7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
8 #include "base/task.h" | 9 #include "base/task.h" |
9 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
10 #include "talk/base/taskrunner.h" | 11 #include "talk/base/taskrunner.h" |
11 | 12 |
12 namespace notifier { | 13 namespace notifier { |
13 | 14 |
14 class TaskPump : public talk_base::TaskRunner { | 15 class TaskPump : public talk_base::TaskRunner { |
15 public: | 16 public: |
16 TaskPump(); | 17 TaskPump(); |
17 | 18 |
18 virtual ~TaskPump(); | 19 virtual ~TaskPump(); |
19 | 20 |
20 // talk_base::TaskRunner implementation. | 21 // talk_base::TaskRunner implementation. |
21 virtual void WakeTasks(); | 22 virtual void WakeTasks(); |
22 virtual int64 CurrentTime(); | 23 virtual int64 CurrentTime(); |
23 | 24 |
24 // No tasks will be processed after this is called, even if | 25 // No tasks will be processed after this is called, even if |
25 // WakeTasks() is called. | 26 // WakeTasks() is called. |
26 void Stop(); | 27 void Stop(); |
27 | 28 |
28 private: | 29 private: |
29 void CheckAndRunTasks(); | 30 void CheckAndRunTasks(); |
30 | 31 |
31 base::NonThreadSafe non_thread_safe_; | 32 base::NonThreadSafe non_thread_safe_; |
32 ScopedRunnableMethodFactory<TaskPump> scoped_runnable_method_factory_; | 33 base::WeakPtrFactory<TaskPump> weak_factory_; |
33 bool posted_wake_; | 34 bool posted_wake_; |
34 bool stopped_; | 35 bool stopped_; |
35 | 36 |
36 DISALLOW_COPY_AND_ASSIGN(TaskPump); | 37 DISALLOW_COPY_AND_ASSIGN(TaskPump); |
37 }; | 38 }; |
38 | 39 |
39 } // namespace notifier | 40 } // namespace notifier |
40 | 41 |
41 #endif // JINGLE_NOTIFIER_BASE_TASK_PUMP_H_ | 42 #endif // JINGLE_NOTIFIER_BASE_TASK_PUMP_H_ |
OLD | NEW |