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 // Stops the timer, and resets the amount of time that has passed so that | |
45 // calling Start results in a timeout equal to the initial timeout setting. | |
46 void Reset(); | |
47 | |
48 base::TimeDelta get_timeout() const { return timeout_; } | |
49 | |
50 private: | 44 private: |
51 // Notification ID for which this timer applies. | 45 // Notification ID for which this timer applies. |
52 const std::string id_; | 46 const std::string id_; |
53 | 47 |
54 // Total time that should pass while active before calling TimerFinished. | 48 // Total time that should pass while active before calling TimerFinished. |
55 base::TimeDelta timeout_; | 49 base::TimeDelta timeout_; |
56 | 50 |
57 // If paused, the amount of time that passed before pause. | 51 // If paused, the amount of time that passed before pause. |
58 base::TimeDelta passed_; | 52 base::TimeDelta passed_; |
59 | 53 |
60 // The time that the timer was last started. | 54 // The time that the timer was last started. |
61 base::Time start_time_; | 55 base::Time start_time_; |
62 | 56 |
63 // Callback recipient. | 57 // Callback recipient. |
64 base::WeakPtr<Delegate> timer_delegate_; | 58 base::WeakPtr<Delegate> timer_delegate_; |
65 | 59 |
66 // The actual timer. | 60 // The actual timer. |
67 std::unique_ptr<base::OneShotTimer> timer_; | 61 std::unique_ptr<base::OneShotTimer> timer_; |
68 | 62 |
69 DISALLOW_COPY_AND_ASSIGN(PopupTimer); | 63 DISALLOW_COPY_AND_ASSIGN(PopupTimer); |
70 }; | 64 }; |
71 | 65 |
72 } // namespace message_center | 66 } // namespace message_center |
73 | 67 |
74 #endif // UI_MESSAGE_CENTER_POPUP_TIMER_H_ | 68 #endif // UI_MESSAGE_CENTER_POPUP_TIMER_H_ |
OLD | NEW |