Home | History | Annotate | Download | only in test_tools
      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 #ifndef NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_
      6 #define NET_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_
      7 
      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"
     12 
     13 namespace net {
     14 
     15 struct QuicAckFrame;
     16 struct QuicPacketHeader;
     17 class QuicAlarm;
     18 class QuicConnection;
     19 class QuicConnectionHelperInterface;
     20 class QuicConnectionVisitorInterface;
     21 class QuicFecGroup;
     22 class QuicFramer;
     23 class QuicPacketCreator;
     24 class QuicPacketWriter;
     25 class QuicReceivedPacketManager;
     26 class ReceiveAlgorithmInterface;
     27 class SendAlgorithmInterface;
     28 
     29 namespace test {
     30 
     31 class QuicTestWriter;
     32 
     33 // Peer to make public a number of otherwise private QuicConnection methods.
     34 class QuicConnectionPeer {
     35  public:
     36   static void SendAck(QuicConnection* connection);
     37 
     38   static void SetReceiveAlgorithm(QuicConnection* connection,
     39                                   ReceiveAlgorithmInterface* receive_algorithm);
     40 
     41   static void SetSendAlgorithm(QuicConnection* connection,
     42                                SendAlgorithmInterface* send_algorithm);
     43 
     44   static QuicAckFrame* CreateAckFrame(QuicConnection* connection);
     45 
     46   static QuicConnectionVisitorInterface* GetVisitor(
     47       QuicConnection* connection);
     48 
     49   static QuicPacketCreator* GetPacketCreator(QuicConnection* connection);
     50 
     51   static QuicReceivedPacketManager* GetReceivedPacketManager(
     52       QuicConnection* connection);
     53 
     54   static QuicTime::Delta GetNetworkTimeout(QuicConnection* connection);
     55 
     56   static bool IsSavedForRetransmission(
     57       QuicConnection* connection,
     58       QuicPacketSequenceNumber sequence_number);
     59 
     60   static bool IsRetransmission(QuicConnection* connection,
     61                                QuicPacketSequenceNumber sequence_number);
     62 
     63   static QuicPacketEntropyHash GetSentEntropyHash(
     64       QuicConnection* connection,
     65       QuicPacketSequenceNumber sequence_number);
     66 
     67   static bool IsValidEntropy(QuicConnection* connection,
     68                              QuicPacketSequenceNumber largest_observed,
     69                              const SequenceNumberSet& missing_packets,
     70                              QuicPacketEntropyHash entropy_hash);
     71 
     72   static QuicPacketEntropyHash ReceivedEntropyHash(
     73       QuicConnection* connection,
     74       QuicPacketSequenceNumber sequence_number);
     75 
     76   static bool IsWriteBlocked(QuicConnection* connection);
     77 
     78   static void SetIsWriteBlocked(QuicConnection* connection, bool write_blocked);
     79 
     80   static bool IsServer(QuicConnection* connection);
     81 
     82   static void SetIsServer(QuicConnection* connection, bool is_server);
     83 
     84   static void SetSelfAddress(QuicConnection* connection,
     85                              const IPEndPoint& self_address);
     86 
     87   static void SetPeerAddress(QuicConnection* connection,
     88                              const IPEndPoint& peer_address);
     89 
     90   static void SwapCrypters(QuicConnection* connection, QuicFramer* framer);
     91 
     92   static QuicConnectionHelperInterface* GetHelper(QuicConnection* connection);
     93 
     94   static QuicFramer* GetFramer(QuicConnection* connection);
     95 
     96   // Set last_header_->fec_group = fec_group and return connection->GetFecGroup
     97   static QuicFecGroup* GetFecGroup(QuicConnection* connection, int fec_group);
     98 
     99   static QuicAlarm* GetAckAlarm(QuicConnection* connection);
    100   static QuicAlarm* GetRetransmissionAlarm(QuicConnection* connection);
    101   static QuicAlarm* GetSendAlarm(QuicConnection* connection);
    102   static QuicAlarm* GetResumeWritesAlarm(QuicConnection* connection);
    103   static QuicAlarm* GetTimeoutAlarm(QuicConnection* connection);
    104 
    105   static QuicPacketWriter* GetWriter(QuicConnection* connection);
    106   static void SetWriter(QuicConnection* connection, QuicTestWriter* writer);
    107 
    108  private:
    109   DISALLOW_COPY_AND_ASSIGN(QuicConnectionPeer);
    110 };
    111 
    112 }  // namespace test
    113 }  // namespace net
    114 
    115 #endif  // NET_QUIC_TEST_TOOLS_QUIC_TEST_PEER_H_
    116