Move pending tile priorities to active on tree activation
[chromium-blink-merge.git] / net / quic / quic_connection_helper.h
blob22585ae78bd9dbf3c762662bf70b705273383b7b
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
3 // found in the LICENSE file.
4 //
5 // The Chrome-specific helper for QuicConnection which uses
6 // a TaskRunner for alarms, and uses a DatagramClientSocket for writing data.
8 #ifndef NET_QUIC_QUIC_CONNECTION_HELPER_H_
9 #define NET_QUIC_QUIC_CONNECTION_HELPER_H_
11 #include "net/quic/quic_connection.h"
13 #include <set>
15 #include "base/memory/weak_ptr.h"
16 #include "net/base/ip_endpoint.h"
17 #include "net/quic/quic_protocol.h"
18 #include "net/quic/quic_time.h"
19 #include "net/udp/datagram_client_socket.h"
21 namespace base {
22 class TaskRunner;
23 } // namespace base
25 namespace net {
27 class QuicClock;
28 class QuicRandom;
30 namespace test {
31 class QuicConnectionHelperPeer;
32 } // namespace test
34 class NET_EXPORT_PRIVATE QuicConnectionHelper
35 : public QuicConnectionHelperInterface {
36 public:
37 QuicConnectionHelper(base::TaskRunner* task_runner,
38 const QuicClock* clock,
39 QuicRandom* random_generator,
40 DatagramClientSocket* socket);
42 virtual ~QuicConnectionHelper();
44 // QuicConnectionHelperInterface
45 virtual void SetConnection(QuicConnection* connection) OVERRIDE;
46 virtual const QuicClock* GetClock() const OVERRIDE;
47 virtual QuicRandom* GetRandomGenerator() OVERRIDE;
48 virtual int WritePacketToWire(const QuicEncryptedPacket& packet,
49 int* error) OVERRIDE;
50 virtual void SetResendAlarm(QuicPacketSequenceNumber sequence_number,
51 QuicTime::Delta delay) OVERRIDE;
52 virtual void SetSendAlarm(QuicTime::Delta delay) OVERRIDE;
53 virtual void SetTimeoutAlarm(QuicTime::Delta delay) OVERRIDE;
54 virtual bool IsSendAlarmSet() OVERRIDE;
55 virtual void UnregisterSendAlarmIfRegistered() OVERRIDE;
57 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
58 // TODO(wtc): these two methods should be able to report a failure.
59 void GetLocalAddress(IPEndPoint* local_address);
60 void GetPeerAddress(IPEndPoint* peer_address);
62 private:
63 friend class test::QuicConnectionHelperPeer;
65 // An alarm is scheduled for each data-bearing packet as it is sent out.
66 // When the alarm goes off, the connection checks to see if the packet has
67 // been acked, and resends if it has not.
68 void OnResendAlarm(QuicPacketSequenceNumber sequence_number);
69 // An alarm that is scheduled when the sent scheduler requires a
70 // a delay before sending packets and fires when the packet may be sent.
71 void OnSendAlarm();
72 // An alarm which fires when the connection may have timed out.
73 void OnTimeoutAlarm();
74 // A completion callback invoked when a write completes.
75 void OnWriteComplete(int result);
77 base::WeakPtrFactory<QuicConnectionHelper> weak_factory_;
78 base::TaskRunner* task_runner_;
79 scoped_ptr<DatagramClientSocket> socket_;
80 QuicConnection* connection_;
81 const QuicClock* clock_;
82 QuicRandom* random_generator_;
83 bool send_alarm_registered_;
84 bool timeout_alarm_registered_;
86 DISALLOW_COPY_AND_ASSIGN(QuicConnectionHelper);
89 } // namespace net
91 #endif // NET_QUIC_QUIC_CONNECTION_HELPER_H_