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

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

Issue 12545035: Refactor QuicClientSession so that it owns the underlying socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The Chrome-specific helper for QuicConnection which uses 5 // The Chrome-specific helper for QuicConnection which uses
6 // a TaskRunner for alarms, and uses a DatagramClientSocket for writing data. 6 // a TaskRunner for alarms, and uses a DatagramClientSocket for writing data.
7 7
8 #ifndef NET_QUIC_QUIC_CONNECTION_HELPER_H_ 8 #ifndef NET_QUIC_QUIC_CONNECTION_HELPER_H_
9 #define NET_QUIC_QUIC_CONNECTION_HELPER_H_ 9 #define NET_QUIC_QUIC_CONNECTION_HELPER_H_
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 virtual int WritePacketToWire(const QuicEncryptedPacket& packet, 48 virtual int WritePacketToWire(const QuicEncryptedPacket& packet,
49 int* error) OVERRIDE; 49 int* error) OVERRIDE;
50 virtual void SetRetransmissionAlarm(QuicTime::Delta delay) OVERRIDE; 50 virtual void SetRetransmissionAlarm(QuicTime::Delta delay) OVERRIDE;
51 virtual void SetSendAlarm(QuicTime::Delta delay) OVERRIDE; 51 virtual void SetSendAlarm(QuicTime::Delta delay) OVERRIDE;
52 virtual void SetTimeoutAlarm(QuicTime::Delta delay) OVERRIDE; 52 virtual void SetTimeoutAlarm(QuicTime::Delta delay) OVERRIDE;
53 virtual bool IsSendAlarmSet() OVERRIDE; 53 virtual bool IsSendAlarmSet() OVERRIDE;
54 virtual void UnregisterSendAlarmIfRegistered() OVERRIDE; 54 virtual void UnregisterSendAlarmIfRegistered() OVERRIDE;
55 virtual void SetAckAlarm(QuicTime::Delta delay) OVERRIDE; 55 virtual void SetAckAlarm(QuicTime::Delta delay) OVERRIDE;
56 virtual void ClearAckAlarm() OVERRIDE; 56 virtual void ClearAckAlarm() OVERRIDE;
57 57
58 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
59 // TODO(wtc): these two methods should be able to report a failure.
60 void GetLocalAddress(IPEndPoint* local_address);
61 void GetPeerAddress(IPEndPoint* peer_address);
62
63 private: 58 private:
64 friend class test::QuicConnectionHelperPeer; 59 friend class test::QuicConnectionHelperPeer;
65 60
66 // An alarm is scheduled for each data-bearing packet as it is sent out. 61 // An alarm is scheduled for each data-bearing packet as it is sent out.
67 // When the alarm goes off, the connection checks to see if the packet has 62 // When the alarm goes off, the connection checks to see if the packet has
68 // been acked, and retransmits if it has not. 63 // been acked, and retransmits if it has not.
69 void OnRetransmissionAlarm(); 64 void OnRetransmissionAlarm();
70 // An alarm that is scheduled when the sent scheduler requires a 65 // An alarm that is scheduled when the sent scheduler requires a
71 // a delay before sending packets and fires when the packet may be sent. 66 // a delay before sending packets and fires when the packet may be sent.
72 void OnSendAlarm(); 67 void OnSendAlarm();
73 // An alarm which fires when the connection may have timed out. 68 // An alarm which fires when the connection may have timed out.
74 void OnTimeoutAlarm(); 69 void OnTimeoutAlarm();
75 // A completion callback invoked when a write completes. 70 // A completion callback invoked when a write completes.
76 void OnWriteComplete(int result); 71 void OnWriteComplete(int result);
77 // An alarm which fires if we've hit a timeout on sending an ack. 72 // An alarm which fires if we've hit a timeout on sending an ack.
78 void OnAckAlarm(); 73 void OnAckAlarm();
79 74
80 base::WeakPtrFactory<QuicConnectionHelper> weak_factory_; 75 base::WeakPtrFactory<QuicConnectionHelper> weak_factory_;
81 base::TaskRunner* task_runner_; 76 base::TaskRunner* task_runner_;
82 scoped_ptr<DatagramClientSocket> socket_; 77 DatagramClientSocket* socket_;
83 QuicConnection* connection_; 78 QuicConnection* connection_;
84 const QuicClock* clock_; 79 const QuicClock* clock_;
85 QuicRandom* random_generator_; 80 QuicRandom* random_generator_;
86 bool send_alarm_registered_; 81 bool send_alarm_registered_;
87 bool timeout_alarm_registered_; 82 bool timeout_alarm_registered_;
88 bool retransmission_alarm_registered_; 83 bool retransmission_alarm_registered_;
89 bool retransmission_alarm_running_; 84 bool retransmission_alarm_running_;
90 bool ack_alarm_registered_; 85 bool ack_alarm_registered_;
91 QuicTime ack_alarm_time_; 86 QuicTime ack_alarm_time_;
92 // Times that packets should be retransmitted. 87 // Times that packets should be retransmitted.
93 std::map<QuicPacketSequenceNumber, QuicTime> retransmission_times_; 88 std::map<QuicPacketSequenceNumber, QuicTime> retransmission_times_;
94 89
95 DISALLOW_COPY_AND_ASSIGN(QuicConnectionHelper); 90 DISALLOW_COPY_AND_ASSIGN(QuicConnectionHelper);
96 }; 91 };
97 92
98 } // namespace net 93 } // namespace net
99 94
100 #endif // NET_QUIC_QUIC_CONNECTION_HELPER_H_ 95 #endif // NET_QUIC_QUIC_CONNECTION_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698