Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: net/quic/quic_alarm.h

Issue 1572353002: QuicAlarms are now allocated out of an arena in QuicConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge recent changes. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/net.gypi ('k') | net/quic/quic_alarm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_time.h" 12 #include "net/quic/quic_time.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 // 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
16 // scheduled time, and execute the |OnAlarm| method of the delegate. 17 // scheduled time, and execute the |OnAlarm| method of the delegate.
17 // 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
18 // removed from the underlying scheduling system, but in either case 19 // removed from the underlying scheduling system, but in either case
19 // the task will not be executed. 20 // the task will not be executed.
20 class NET_EXPORT_PRIVATE QuicAlarm { 21 class NET_EXPORT_PRIVATE QuicAlarm {
21 public: 22 public:
22 class NET_EXPORT_PRIVATE Delegate { 23 class NET_EXPORT_PRIVATE Delegate {
23 public: 24 public:
24 virtual ~Delegate() {} 25 virtual ~Delegate() {}
25 26
26 // Invoked when the alarm fires. If the return value is not 27 // Invoked when the alarm fires. If the return value is not
27 // infinite, then the alarm will be rescheduled at the 28 // infinite, then the alarm will be rescheduled at the
28 // specified time. 29 // specified time.
29 virtual QuicTime OnAlarm() = 0; 30 virtual QuicTime OnAlarm() = 0;
30 }; 31 };
31 32
32 explicit QuicAlarm(Delegate* delegate); 33 explicit QuicAlarm(QuicArenaScopedPtr<Delegate> delegate);
33 virtual ~QuicAlarm(); 34 virtual ~QuicAlarm();
34 35
35 // Sets the alarm to fire at |deadline|. Must not be called while 36 // Sets the alarm to fire at |deadline|. Must not be called while
36 // the alarm is set. To reschedule an alarm, call Cancel() first, 37 // the alarm is set. To reschedule an alarm, call Cancel() first,
37 // then Set(). 38 // then Set().
38 void Set(QuicTime deadline); 39 void Set(QuicTime deadline);
39 40
40 // Cancels the alarm. May be called repeatedly. Does not 41 // Cancels the alarm. May be called repeatedly. Does not
41 // guarantee that the underlying scheduling system will remove 42 // guarantee that the underlying scheduling system will remove
42 // the alarm's associated task, but guarantees that the 43 // the alarm's associated task, but guarantees that the
(...skipping 22 matching lines...) Expand all
65 // Called by subclasses when the alarm fires. Invokes the 66 // Called by subclasses when the alarm fires. Invokes the
66 // delegates |OnAlarm| if a delegate is set, and if the deadline 67 // delegates |OnAlarm| if a delegate is set, and if the deadline
67 // has been exceeded. Implementations which do not remove the 68 // has been exceeded. Implementations which do not remove the
68 // alarm from the underlying scheduler on Cancel() may need to handle 69 // alarm from the underlying scheduler on Cancel() may need to handle
69 // the situation where the task executes before the deadline has been 70 // the situation where the task executes before the deadline has been
70 // reached, in which case they need to reschedule the task and must not 71 // reached, in which case they need to reschedule the task and must not
71 // call invoke this method. 72 // call invoke this method.
72 void Fire(); 73 void Fire();
73 74
74 private: 75 private:
75 scoped_ptr<Delegate> delegate_; 76 QuicArenaScopedPtr<Delegate> delegate_;
76 QuicTime deadline_; 77 QuicTime deadline_;
77 78
78 DISALLOW_COPY_AND_ASSIGN(QuicAlarm); 79 DISALLOW_COPY_AND_ASSIGN(QuicAlarm);
79 }; 80 };
80 81
81 } // namespace net 82 } // namespace net
82 83
83 #endif // NET_QUIC_QUIC_ALARM_H_ 84 #endif // NET_QUIC_QUIC_ALARM_H_
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/quic/quic_alarm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698