OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 NET_QUIC_QUIC_ALARM_H_ | 5 #ifndef NET_QUIC_QUIC_ALARM_H_ |
6 #define NET_QUIC_QUIC_ALARM_H_ | 6 #define NET_QUIC_QUIC_ALARM_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
10 #include "net/quic/quic_time.h" | 10 #include "net/quic/quic_time.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // the alarm is set. To reschedule an alarm, call Cancel() first, | 35 // the alarm is set. To reschedule an alarm, call Cancel() first, |
36 // then Set(). | 36 // then Set(). |
37 void Set(QuicTime deadline); | 37 void Set(QuicTime deadline); |
38 | 38 |
39 // Cancels the alarm. May be called repeatedly. Does not | 39 // Cancels the alarm. May be called repeatedly. Does not |
40 // guarantee that the underlying scheduling system will remove | 40 // guarantee that the underlying scheduling system will remove |
41 // the alarm's associated task, but guarantees that the | 41 // the alarm's associated task, but guarantees that the |
42 // delegates OnAlarm method will not be called. | 42 // delegates OnAlarm method will not be called. |
43 void Cancel(); | 43 void Cancel(); |
44 | 44 |
| 45 // Cancels and sets the alarm if the |deadline| is farther from the current |
| 46 // deadline than |granularity|, and otherwise does nothing. If |deadline| is |
| 47 // not initialized, the alarm is cancelled. |
| 48 void Update(QuicTime deadline, QuicTime::Delta granularity); |
| 49 |
45 bool IsSet() const; | 50 bool IsSet() const; |
46 | 51 |
47 QuicTime deadline() const { return deadline_; } | 52 QuicTime deadline() const { return deadline_; } |
48 | 53 |
49 protected: | 54 protected: |
50 // Subclasses implement this method to perform the platform-specific | 55 // Subclasses implement this method to perform the platform-specific |
51 // scheduling of the alarm. Is called from Set() or Fire(), after the | 56 // scheduling of the alarm. Is called from Set() or Fire(), after the |
52 // deadline has been updated. | 57 // deadline has been updated. |
53 virtual void SetImpl() = 0; | 58 virtual void SetImpl() = 0; |
54 | 59 |
(...skipping 13 matching lines...) Expand all Loading... |
68 private: | 73 private: |
69 scoped_ptr<Delegate> delegate_; | 74 scoped_ptr<Delegate> delegate_; |
70 QuicTime deadline_; | 75 QuicTime deadline_; |
71 | 76 |
72 DISALLOW_COPY_AND_ASSIGN(QuicAlarm); | 77 DISALLOW_COPY_AND_ASSIGN(QuicAlarm); |
73 }; | 78 }; |
74 | 79 |
75 } // namespace net | 80 } // namespace net |
76 | 81 |
77 #endif // NET_QUIC_QUIC_ALARM_H_ | 82 #endif // NET_QUIC_QUIC_ALARM_H_ |
OLD | NEW |