Chromium Code Reviews| 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_TIMER_ALARM_TIMER_H_ | 5 #ifndef COMPONENTS_TIMER_ALARM_TIMER_H_ |
| 6 #define COMPONENTS_TIMER_ALARM_TIMER_H_ | 6 #define COMPONENTS_TIMER_ALARM_TIMER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 void Stop() override; | 65 void Stop() override; |
| 66 void Reset() override; | 66 void Reset() override; |
| 67 | 67 |
| 68 // MessageLoop::DestructionObserver overrides. | 68 // MessageLoop::DestructionObserver overrides. |
| 69 void WillDestroyCurrentMessageLoop() override; | 69 void WillDestroyCurrentMessageLoop() override; |
| 70 | 70 |
| 71 // Must be called by the delegate to indicate that the timer has fired and | 71 // Must be called by the delegate to indicate that the timer has fired and |
| 72 // that the user task should be run. | 72 // that the user task should be run. |
| 73 void OnTimerFired(); | 73 void OnTimerFired(); |
| 74 | 74 |
| 75 bool can_wake_from_suspend() { return can_wake_from_suspend_; } | |
|
Daniel Erat
2014/10/30 02:51:21
nit: i think that inline methods usually come righ
Chirantan Ekbote
2014/10/30 20:41:37
Done.
| |
| 76 | |
| 75 private: | 77 private: |
| 76 // Initializes the timer with the appropriate delegate. | 78 // Initializes the timer with the appropriate delegate. |
| 77 void Init(); | 79 void Init(); |
| 78 | 80 |
| 79 // Delegate that will manage actually setting the timer. | 81 // Delegate that will manage actually setting the timer. |
| 80 scoped_refptr<Delegate> delegate_; | 82 scoped_refptr<Delegate> delegate_; |
| 81 | 83 |
| 82 // Keeps track of the user task we want to run. A new one is constructed | 84 // Keeps track of the user task we want to run. A new one is constructed |
| 83 // every time Reset() is called. | 85 // every time Reset() is called. |
| 84 scoped_ptr<base::PendingTask> pending_task_; | 86 scoped_ptr<base::PendingTask> pending_task_; |
| 85 | 87 |
| 86 // Tracks whether the timer has the ability to wake the system up from | 88 // Tracks whether the timer has the ability to wake the system up from |
| 87 // suspend. This is a runtime check because we won't know if the system | 89 // suspend. This is a runtime check because we won't know if the system |
| 88 // supports being woken up from suspend until the delegate actually tries to | 90 // supports being woken up from suspend until the delegate actually tries to |
| 89 // set it up. | 91 // set it up. |
| 90 bool can_wake_from_suspend_; | 92 bool can_wake_from_suspend_; |
| 91 | 93 |
| 92 // Pointer to the message loop that started the timer. Used to track the | 94 // Pointer to the message loop that started the timer. Used to track the |
| 93 // destruction of that message loop. | 95 // destruction of that message loop. |
| 94 base::MessageLoop* origin_message_loop_; | 96 base::MessageLoop* origin_message_loop_; |
| 95 | 97 |
| 96 base::WeakPtrFactory<AlarmTimer> weak_factory_; | 98 base::WeakPtrFactory<AlarmTimer> weak_factory_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(AlarmTimer); | 100 DISALLOW_COPY_AND_ASSIGN(AlarmTimer); |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 } // namespace timers | 103 } // namespace timers |
| 102 | 104 |
| 103 #endif // COMPONENTS_TIMER_ALARM_TIMER_H_ | 105 #endif // COMPONENTS_TIMER_ALARM_TIMER_H_ |
| OLD | NEW |