OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_TIMERS_ALARM_TIMER_CHROMEOS_H_ | 5 #ifndef COMPONENTS_TIMERS_ALARM_TIMER_CHROMEOS_H_ |
6 #define COMPONENTS_TIMERS_ALARM_TIMER_CHROMEOS_H_ | 6 #define COMPONENTS_TIMERS_ALARM_TIMER_CHROMEOS_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/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class MessageLoop; | 18 class MessageLoop; |
18 struct PendingTask; | 19 struct PendingTask; |
19 } | 20 } |
20 | 21 |
21 namespace timers { | 22 namespace timers { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 // Called when |origin_message_loop_| will be destroyed. | 63 // Called when |origin_message_loop_| will be destroyed. |
63 void WillDestroyCurrentMessageLoop(); | 64 void WillDestroyCurrentMessageLoop(); |
64 | 65 |
65 // Delegate that will manage actually setting the timer. | 66 // Delegate that will manage actually setting the timer. |
66 class Delegate; | 67 class Delegate; |
67 scoped_refptr<Delegate> delegate_; | 68 scoped_refptr<Delegate> delegate_; |
68 | 69 |
69 // Keeps track of the user task we want to run. A new one is constructed | 70 // Keeps track of the user task we want to run. A new one is constructed |
70 // every time Reset() is called. | 71 // every time Reset() is called. |
71 scoped_ptr<base::PendingTask> pending_task_; | 72 std::unique_ptr<base::PendingTask> pending_task_; |
72 | 73 |
73 // Tracks whether the timer has the ability to wake the system up from | 74 // Tracks whether the timer has the ability to wake the system up from |
74 // suspend. This is a runtime check because we won't know if the system | 75 // suspend. This is a runtime check because we won't know if the system |
75 // supports being woken up from suspend until the delegate actually tries to | 76 // supports being woken up from suspend until the delegate actually tries to |
76 // set it up. | 77 // set it up. |
77 bool can_wake_from_suspend_; | 78 bool can_wake_from_suspend_; |
78 | 79 |
79 // Pointer to the message loop that started the timer. Used to track the | 80 // Pointer to the message loop that started the timer. Used to track the |
80 // destruction of that message loop. | 81 // destruction of that message loop. |
81 base::MessageLoop* origin_message_loop_; | 82 base::MessageLoop* origin_message_loop_; |
82 | 83 |
83 // Observes |origin_message_loop_| and informs this class if it will be | 84 // Observes |origin_message_loop_| and informs this class if it will be |
84 // destroyed. | 85 // destroyed. |
85 class MessageLoopObserver; | 86 class MessageLoopObserver; |
86 scoped_ptr<MessageLoopObserver> message_loop_observer_; | 87 std::unique_ptr<MessageLoopObserver> message_loop_observer_; |
87 | 88 |
88 base::WeakPtrFactory<AlarmTimer> weak_factory_; | 89 base::WeakPtrFactory<AlarmTimer> weak_factory_; |
89 | 90 |
90 DISALLOW_COPY_AND_ASSIGN(AlarmTimer); | 91 DISALLOW_COPY_AND_ASSIGN(AlarmTimer); |
91 }; | 92 }; |
92 | 93 |
93 // As its name suggests, a OneShotAlarmTimer runs a given task once. It does | 94 // As its name suggests, a OneShotAlarmTimer runs a given task once. It does |
94 // not remember the task that was given to it after it has fired and does not | 95 // not remember the task that was given to it after it has fired and does not |
95 // repeat. Useful for fire-and-forget tasks. | 96 // repeat. Useful for fire-and-forget tasks. |
96 class OneShotAlarmTimer : public AlarmTimer { | 97 class OneShotAlarmTimer : public AlarmTimer { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 SimpleAlarmTimer(const tracked_objects::Location& posted_from, | 139 SimpleAlarmTimer(const tracked_objects::Location& posted_from, |
139 base::TimeDelta delay, | 140 base::TimeDelta delay, |
140 const base::Closure& user_task); | 141 const base::Closure& user_task); |
141 | 142 |
142 ~SimpleAlarmTimer() override; | 143 ~SimpleAlarmTimer() override; |
143 }; | 144 }; |
144 | 145 |
145 } // namespace timers | 146 } // namespace timers |
146 | 147 |
147 #endif // COMPONENTS_TIMERS_ALARM_TIMER_CHROMEOS_H_ | 148 #endif // COMPONENTS_TIMERS_ALARM_TIMER_CHROMEOS_H_ |
OLD | NEW |