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 SendAlgorithmInterface
;
33 // Peer to make public a number of otherwise private QuicConnection methods.
34 class QuicConnectionPeer
{
36 static void SendAck(QuicConnection
* connection
);
38 static void SetSendAlgorithm(QuicConnection
* connection
,
39 SendAlgorithmInterface
* send_algorithm
);
41 static void PopulateAckFrame(QuicConnection
* connection
, QuicAckFrame
* ack
);
43 static void PopulateStopWaitingFrame(QuicConnection
* connection
,
44 QuicStopWaitingFrame
* stop_waiting
);
46 static QuicConnectionVisitorInterface
* GetVisitor(
47 QuicConnection
* connection
);
49 static QuicPacketCreator
* GetPacketCreator(QuicConnection
* connection
);
51 static QuicPacketGenerator
* GetPacketGenerator(QuicConnection
* connection
);
53 static QuicSentPacketManager
* GetSentPacketManager(
54 QuicConnection
* connection
);
56 static QuicTime::Delta
GetNetworkTimeout(QuicConnection
* connection
);
58 static QuicPacketEntropyHash
GetSentEntropyHash(
59 QuicConnection
* connection
,
60 QuicPacketSequenceNumber sequence_number
);
62 static QuicPacketEntropyHash
PacketEntropy(
63 QuicConnection
* connection
,
64 QuicPacketSequenceNumber sequence_number
);
66 static QuicPacketEntropyHash
ReceivedEntropyHash(
67 QuicConnection
* connection
,
68 QuicPacketSequenceNumber sequence_number
);
70 static void SetPerspective(QuicConnection
* connection
,
71 Perspective perspective
);
73 static void SetSelfAddress(QuicConnection
* connection
,
74 const IPEndPoint
& self_address
);
76 static void SetPeerAddress(QuicConnection
* connection
,
77 const IPEndPoint
& peer_address
);
79 static bool IsSilentCloseEnabled(QuicConnection
* connection
);
81 static void SwapCrypters(QuicConnection
* connection
, QuicFramer
* framer
);
83 static QuicConnectionHelperInterface
* GetHelper(QuicConnection
* connection
);
85 static QuicFramer
* GetFramer(QuicConnection
* connection
);
87 // Set last_header_->fec_group = fec_group and return connection->GetFecGroup
88 static QuicFecGroup
* GetFecGroup(QuicConnection
* connection
, int fec_group
);
90 static QuicAlarm
* GetAckAlarm(QuicConnection
* connection
);
91 static QuicAlarm
* GetPingAlarm(QuicConnection
* connection
);
92 static QuicAlarm
* GetFecAlarm(QuicConnection
* connection
);
93 static QuicAlarm
* GetResumeWritesAlarm(QuicConnection
* connection
);
94 static QuicAlarm
* GetRetransmissionAlarm(QuicConnection
* connection
);
95 static QuicAlarm
* GetSendAlarm(QuicConnection
* connection
);
96 static QuicAlarm
* GetTimeoutAlarm(QuicConnection
* connection
);
98 static QuicPacketWriter
* GetWriter(QuicConnection
* connection
);
99 // If |owns_writer| is true, takes ownership of |writer|.
100 static void SetWriter(QuicConnection
* connection
,
101 QuicPacketWriter
* writer
,
103 static void CloseConnection(QuicConnection
* connection
);
104 static QuicEncryptedPacket
* GetConnectionClosePacket(
105 QuicConnection
* connection
);
107 static QuicPacketHeader
* GetLastHeader(QuicConnection
* connection
);
109 static void SetSequenceNumberOfLastSentPacket(
110 QuicConnection
* connection
, QuicPacketSequenceNumber number
);
112 static QuicConnectionStats
* GetStats(QuicConnection
* connection
);
115 DISALLOW_COPY_AND_ASSIGN(QuicConnectionPeer
);
122 #endif // NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_