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.
5 #ifndef NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_
6 #define NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_
8 #include "base/basictypes.h"
9 #include "net/base/ip_endpoint.h"
10 #include "net/quic/quic_connection_stats.h"
11 #include "net/quic/quic_protocol.h"
16 struct QuicPacketHeader
;
19 class QuicConnectionHelperInterface
;
20 class QuicConnectionVisitorInterface
;
21 class QuicEncryptedPacket
;
24 class QuicPacketCreator
;
25 class QuicPacketGenerator
;
26 class QuicPacketWriter
;
27 class QuicReceivedPacketManager
;
28 class QuicSentPacketManager
;
29 class ReceiveAlgorithmInterface
;
30 class SendAlgorithmInterface
;
34 // Peer to make public a number of otherwise private QuicConnection methods.
35 class QuicConnectionPeer
{
37 static void SendAck(QuicConnection
* connection
);
39 static void SetReceiveAlgorithm(QuicConnection
* connection
,
40 ReceiveAlgorithmInterface
* receive_algorithm
);
42 static void SetSendAlgorithm(QuicConnection
* connection
,
43 SendAlgorithmInterface
* send_algorithm
);
45 static QuicAckFrame
* CreateAckFrame(QuicConnection
* connection
);
47 static QuicStopWaitingFrame
* CreateStopWaitingFrame(
48 QuicConnection
* connection
);
50 static QuicConnectionVisitorInterface
* GetVisitor(
51 QuicConnection
* connection
);
53 static QuicPacketCreator
* GetPacketCreator(QuicConnection
* connection
);
55 static QuicPacketGenerator
* GetPacketGenerator(QuicConnection
* connection
);
57 static QuicSentPacketManager
* GetSentPacketManager(
58 QuicConnection
* connection
);
60 static QuicReceivedPacketManager
* GetReceivedPacketManager(
61 QuicConnection
* connection
);
63 static QuicTime::Delta
GetNetworkTimeout(QuicConnection
* connection
);
65 static bool IsSavedForRetransmission(
66 QuicConnection
* connection
,
67 QuicPacketSequenceNumber sequence_number
);
69 static bool IsRetransmission(QuicConnection
* connection
,
70 QuicPacketSequenceNumber sequence_number
);
72 static QuicPacketEntropyHash
GetSentEntropyHash(
73 QuicConnection
* connection
,
74 QuicPacketSequenceNumber sequence_number
);
76 static QuicPacketEntropyHash
PacketEntropy(
77 QuicConnection
* connection
,
78 QuicPacketSequenceNumber sequence_number
);
80 static QuicPacketEntropyHash
ReceivedEntropyHash(
81 QuicConnection
* connection
,
82 QuicPacketSequenceNumber sequence_number
);
84 static bool IsServer(QuicConnection
* connection
);
86 static void SetIsServer(QuicConnection
* connection
, bool is_server
);
88 static void SetSelfAddress(QuicConnection
* connection
,
89 const IPEndPoint
& self_address
);
91 static void SetPeerAddress(QuicConnection
* connection
,
92 const IPEndPoint
& peer_address
);
94 static void SwapCrypters(QuicConnection
* connection
, QuicFramer
* framer
);
96 static QuicConnectionHelperInterface
* GetHelper(QuicConnection
* connection
);
98 static QuicFramer
* GetFramer(QuicConnection
* connection
);
100 // Set last_header_->fec_group = fec_group and return connection->GetFecGroup
101 static QuicFecGroup
* GetFecGroup(QuicConnection
* connection
, int fec_group
);
103 static QuicAlarm
* GetAckAlarm(QuicConnection
* connection
);
104 static QuicAlarm
* GetPingAlarm(QuicConnection
* connection
);
105 static QuicAlarm
* GetResumeWritesAlarm(QuicConnection
* connection
);
106 static QuicAlarm
* GetRetransmissionAlarm(QuicConnection
* connection
);
107 static QuicAlarm
* GetSendAlarm(QuicConnection
* connection
);
108 static QuicAlarm
* GetTimeoutAlarm(QuicConnection
* connection
);
110 static QuicPacketWriter
* GetWriter(QuicConnection
* connection
);
111 // If |owns_writer| is true, takes ownership of |writer|.
112 static void SetWriter(QuicConnection
* connection
,
113 QuicPacketWriter
* writer
,
115 static void CloseConnection(QuicConnection
* connection
);
116 static QuicEncryptedPacket
* GetConnectionClosePacket(
117 QuicConnection
* connection
);
119 static void SetSupportedVersions(QuicConnection
* connection
,
120 QuicVersionVector versions
);
123 DISALLOW_COPY_AND_ASSIGN(QuicConnectionPeer
);
130 #endif // NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_