| 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/macros.h" | 8 #include "base/macros.h" | 
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" | 
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" | 
| 11 #include "net/quic/quic_arena_scoped_ptr.h" | 11 #include "net/quic/quic_arena_scoped_ptr.h" | 
| 12 #include "net/quic/quic_time.h" | 12 #include "net/quic/quic_time.h" | 
| 13 | 13 | 
| 14 namespace net { | 14 namespace net { | 
| 15 | 15 | 
| 16 // Abstract class which represents an alarm which will go off at a | 16 // Abstract class which represents an alarm which will go off at a | 
| 17 // scheduled time, and execute the |OnAlarm| method of the delegate. | 17 // scheduled time, and execute the |OnAlarm| method of the delegate. | 
| 18 // An alarm may be cancelled, in which case it may or may not be | 18 // An alarm may be cancelled, in which case it may or may not be | 
| 19 // removed from the underlying scheduling system, but in either case | 19 // removed from the underlying scheduling system, but in either case | 
| 20 // the task will not be executed. | 20 // the task will not be executed. | 
| 21 class NET_EXPORT_PRIVATE QuicAlarm { | 21 class NET_EXPORT_PRIVATE QuicAlarm { | 
| 22  public: | 22  public: | 
| 23   class NET_EXPORT_PRIVATE Delegate { | 23   class NET_EXPORT_PRIVATE Delegate { | 
| 24    public: | 24    public: | 
| 25     virtual ~Delegate() {} | 25     virtual ~Delegate() {} | 
| 26 | 26 | 
| 27     // Invoked when the alarm fires.  If the return value is not | 27     // Invoked when the alarm fires. | 
| 28     // infinite, then the alarm will be rescheduled at the | 28     virtual void OnAlarm() = 0; | 
| 29     // specified time. |  | 
| 30     virtual QuicTime OnAlarm() = 0; |  | 
| 31   }; | 29   }; | 
| 32 | 30 | 
| 33   explicit QuicAlarm(QuicArenaScopedPtr<Delegate> delegate); | 31   explicit QuicAlarm(QuicArenaScopedPtr<Delegate> delegate); | 
| 34   virtual ~QuicAlarm(); | 32   virtual ~QuicAlarm(); | 
| 35 | 33 | 
| 36   // Sets the alarm to fire at |deadline|.  Must not be called while | 34   // Sets the alarm to fire at |deadline|.  Must not be called while | 
| 37   // the alarm is set.  To reschedule an alarm, call Cancel() first, | 35   // the alarm is set.  To reschedule an alarm, call Cancel() first, | 
| 38   // then Set(). | 36   // then Set(). | 
| 39   void Set(QuicTime new_deadline); | 37   void Set(QuicTime new_deadline); | 
| 40 | 38 | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 76  private: | 74  private: | 
| 77   QuicArenaScopedPtr<Delegate> delegate_; | 75   QuicArenaScopedPtr<Delegate> delegate_; | 
| 78   QuicTime deadline_; | 76   QuicTime deadline_; | 
| 79 | 77 | 
| 80   DISALLOW_COPY_AND_ASSIGN(QuicAlarm); | 78   DISALLOW_COPY_AND_ASSIGN(QuicAlarm); | 
| 81 }; | 79 }; | 
| 82 | 80 | 
| 83 }  // namespace net | 81 }  // namespace net | 
| 84 | 82 | 
| 85 #endif  // NET_QUIC_QUIC_ALARM_H_ | 83 #endif  // NET_QUIC_QUIC_ALARM_H_ | 
| OLD | NEW | 
|---|