OLD | NEW |
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 // A toy client, which connects to a specified port and sends QUIC | 5 // A toy client, which connects to a specified port and sends QUIC |
6 // request to that endpoint. | 6 // request to that endpoint. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ |
9 #define NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ | 9 #define NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 class UDPClientSocket; | 33 class UDPClientSocket; |
34 | 34 |
35 | 35 |
36 namespace test { | 36 namespace test { |
37 class QuicClientPeer; | 37 class QuicClientPeer; |
38 } // namespace test | 38 } // namespace test |
39 | 39 |
40 class QuicSimpleClient : public QuicClientBase, | 40 class QuicSimpleClient : public QuicClientBase, |
41 public QuicChromiumPacketReader::Visitor { | 41 public QuicChromiumPacketReader::Visitor { |
42 public: | 42 public: |
43 // Create a quic client, which will have events managed by an externally owned | 43 // Create a quic client, which will have events managed by the message loop. |
44 // EpollServer. | 44 QuicSimpleClient(QuicSocketAddress server_address, |
45 QuicSimpleClient(IPEndPoint server_address, | |
46 const QuicServerId& server_id, | 45 const QuicServerId& server_id, |
47 const QuicVersionVector& supported_versions, | 46 const QuicVersionVector& supported_versions, |
48 std::unique_ptr<ProofVerifier> proof_verifier); | 47 std::unique_ptr<ProofVerifier> proof_verifier); |
49 QuicSimpleClient(IPEndPoint server_address, | |
50 const QuicServerId& server_id, | |
51 const QuicVersionVector& supported_versions, | |
52 const QuicConfig& config, | |
53 std::unique_ptr<ProofVerifier> proof_verifier); | |
54 | 48 |
55 ~QuicSimpleClient() override; | 49 ~QuicSimpleClient() override; |
56 | 50 |
57 // QuicChromiumPacketReader::Visitor | 51 // QuicChromiumPacketReader::Visitor |
58 void OnReadError(int result, const DatagramClientSocket* socket) override; | 52 void OnReadError(int result, const DatagramClientSocket* socket) override; |
59 bool OnPacket(const QuicReceivedPacket& packet, | 53 bool OnPacket(const QuicReceivedPacket& packet, |
60 IPEndPoint local_address, | 54 IPEndPoint local_address, |
61 IPEndPoint peer_address) override; | 55 IPEndPoint peer_address) override; |
62 | 56 |
63 // From QuicClientBase | 57 // From QuicClientBase |
(...skipping 16 matching lines...) Expand all Loading... |
80 | 74 |
81 // Read a UDP packet and hand it to the framer. | 75 // Read a UDP packet and hand it to the framer. |
82 bool ReadAndProcessPacket(); | 76 bool ReadAndProcessPacket(); |
83 | 77 |
84 void StartPacketReaderIfNotStarted(); | 78 void StartPacketReaderIfNotStarted(); |
85 | 79 |
86 // Used by |helper_| to time alarms. | 80 // Used by |helper_| to time alarms. |
87 QuicChromiumClock clock_; | 81 QuicChromiumClock clock_; |
88 | 82 |
89 // Address of the client if the client is connected to the server. | 83 // Address of the client if the client is connected to the server. |
90 IPEndPoint client_address_; | 84 QuicSocketAddress client_address_; |
91 | 85 |
92 // UDP socket connected to the server. | 86 // UDP socket connected to the server. |
93 std::unique_ptr<UDPClientSocket> socket_; | 87 std::unique_ptr<UDPClientSocket> socket_; |
94 | 88 |
95 // Tracks if the client is initialized to connect. | 89 // Tracks if the client is initialized to connect. |
96 bool initialized_; | 90 bool initialized_; |
97 | 91 |
98 // The log used for the sockets. | 92 // The log used for the sockets. |
99 NetLog net_log_; | 93 NetLog net_log_; |
100 | 94 |
101 std::unique_ptr<QuicChromiumPacketReader> packet_reader_; | 95 std::unique_ptr<QuicChromiumPacketReader> packet_reader_; |
102 | 96 |
103 bool packet_reader_started_; | 97 bool packet_reader_started_; |
104 | 98 |
105 base::WeakPtrFactory<QuicSimpleClient> weak_factory_; | 99 base::WeakPtrFactory<QuicSimpleClient> weak_factory_; |
106 | 100 |
107 DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); | 101 DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); |
108 }; | 102 }; |
109 | 103 |
110 } // namespace net | 104 } // namespace net |
111 | 105 |
112 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ | 106 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ |
OLD | NEW |