| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 UI_MESSAGE_CENTER_POPUP_TIMER_H_ | 5 #ifndef UI_MESSAGE_CENTER_POPUP_TIMER_H_ |
| 6 #define UI_MESSAGE_CENTER_POPUP_TIMER_H_ | 6 #define UI_MESSAGE_CENTER_POPUP_TIMER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 ~PopupTimer(); | 34 ~PopupTimer(); |
| 35 | 35 |
| 36 // Starts running the timer. Barring a Pause or Reset call, the timer will | 36 // Starts running the timer. Barring a Pause or Reset call, the timer will |
| 37 // call back to |delegate| after |timeout| seconds. | 37 // call back to |delegate| after |timeout| seconds. |
| 38 void Start(); | 38 void Start(); |
| 39 | 39 |
| 40 // Stops the timer, and retains the amount of time that has passed so that on | 40 // Stops the timer, and retains the amount of time that has passed so that on |
| 41 // subsequent calls to Start the timer will continue where it left off. | 41 // subsequent calls to Start the timer will continue where it left off. |
| 42 void Pause(); | 42 void Pause(); |
| 43 | 43 |
| 44 // Returns whether the underlying timer is running or not. |
| 45 bool IsRunning() { return timer_->IsRunning(); } |
| 46 |
| 44 private: | 47 private: |
| 45 // Notification ID for which this timer applies. | 48 // Notification ID for which this timer applies. |
| 46 const std::string id_; | 49 const std::string id_; |
| 47 | 50 |
| 48 // Total time that should pass while active before calling TimerFinished. | 51 // Total time that should pass while active before calling TimerFinished. |
| 49 base::TimeDelta timeout_; | 52 base::TimeDelta timeout_; |
| 50 | 53 |
| 51 // If paused, the amount of time that passed before pause. | 54 // If paused, the amount of time that passed before pause. |
| 52 base::TimeDelta passed_; | 55 base::TimeDelta passed_; |
| 53 | 56 |
| 54 // The time that the timer was last started. | 57 // The time that the timer was last started. |
| 55 base::Time start_time_; | 58 base::Time start_time_; |
| 56 | 59 |
| 57 // Callback recipient. | 60 // Callback recipient. |
| 58 base::WeakPtr<Delegate> timer_delegate_; | 61 base::WeakPtr<Delegate> timer_delegate_; |
| 59 | 62 |
| 60 // The actual timer. | 63 // The actual timer. |
| 61 std::unique_ptr<base::OneShotTimer> timer_; | 64 std::unique_ptr<base::OneShotTimer> timer_; |
| 62 | 65 |
| 63 DISALLOW_COPY_AND_ASSIGN(PopupTimer); | 66 DISALLOW_COPY_AND_ASSIGN(PopupTimer); |
| 64 }; | 67 }; |
| 65 | 68 |
| 66 } // namespace message_center | 69 } // namespace message_center |
| 67 | 70 |
| 68 #endif // UI_MESSAGE_CENTER_POPUP_TIMER_H_ | 71 #endif // UI_MESSAGE_CENTER_POPUP_TIMER_H_ |
| OLD | NEW |