Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 base class for the toy client, which connects to a specified port and sends | 5 // A base class for the toy client, which connects to a specified port and sends |
| 6 // QUIC request to that endpoint. | 6 // QUIC request to that endpoint. |
| 7 | 7 |
| 8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_BASE_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_BASE_H_ |
| 9 #define NET_TOOLS_QUIC_QUIC_CLIENT_BASE_H_ | 9 #define NET_TOOLS_QUIC_QUIC_CLIENT_BASE_H_ |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 class ProofVerifier; | 30 class ProofVerifier; |
| 31 class QuicServerId; | 31 class QuicServerId; |
| 32 | 32 |
| 33 class QuicClientBase { | 33 class QuicClientBase { |
| 34 public: | 34 public: |
| 35 QuicClientBase(const QuicServerId& server_id, | 35 QuicClientBase(const QuicServerId& server_id, |
| 36 const QuicVersionVector& supported_versions, | 36 const QuicVersionVector& supported_versions, |
| 37 const QuicConfig& config, | 37 const QuicConfig& config, |
| 38 QuicConnectionHelperInterface* helper, | 38 QuicConnectionHelperInterface* helper, |
| 39 QuicAlarmFactory* alarm_factory, | |
| 39 ProofVerifier* proof_verifier); | 40 ProofVerifier* proof_verifier); |
| 40 | 41 |
| 41 ~QuicClientBase(); | 42 ~QuicClientBase(); |
| 42 | 43 |
| 43 // Initializes the client to create a connection. Should be called exactly | 44 // Initializes the client to create a connection. Should be called exactly |
| 44 // once before calling StartConnect or Connect. Returns true if the | 45 // once before calling StartConnect or Connect. Returns true if the |
| 45 // initialization succeeds, false otherwise. | 46 // initialization succeeds, false otherwise. |
| 46 virtual bool Initialize(); | 47 virtual bool Initialize(); |
| 47 | 48 |
| 48 // Returns true if the crypto handshake has yet to establish encryption. | 49 // Returns true if the crypto handshake has yet to establish encryption. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 // Returns the next server-designated ConnectionId from the cached config for | 175 // Returns the next server-designated ConnectionId from the cached config for |
| 175 // |server_id_|, if it exists. Otherwise, returns 0. | 176 // |server_id_|, if it exists. Otherwise, returns 0. |
| 176 QuicConnectionId GetNextServerDesignatedConnectionId(); | 177 QuicConnectionId GetNextServerDesignatedConnectionId(); |
| 177 | 178 |
| 178 // Generates a new, random connection ID (as opposed to a server-designated | 179 // Generates a new, random connection ID (as opposed to a server-designated |
| 179 // connection ID). | 180 // connection ID). |
| 180 virtual QuicConnectionId GenerateNewConnectionId(); | 181 virtual QuicConnectionId GenerateNewConnectionId(); |
| 181 | 182 |
| 182 QuicConnectionHelperInterface* helper() { return helper_.get(); } | 183 QuicConnectionHelperInterface* helper() { return helper_.get(); } |
| 183 | 184 |
| 185 QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); } | |
| 186 | |
| 184 void set_num_sent_client_hellos(int num_sent_client_hellos) { | 187 void set_num_sent_client_hellos(int num_sent_client_hellos) { |
| 185 num_sent_client_hellos_ = num_sent_client_hellos; | 188 num_sent_client_hellos_ = num_sent_client_hellos; |
| 186 } | 189 } |
| 187 | 190 |
| 188 void set_num_stateless_rejects_received(int num_stateless_rejects_received) { | 191 void set_num_stateless_rejects_received(int num_stateless_rejects_received) { |
| 189 num_stateless_rejects_received_ = num_stateless_rejects_received; | 192 num_stateless_rejects_received_ = num_stateless_rejects_received; |
| 190 } | 193 } |
| 191 | 194 |
| 192 private: | 195 private: |
| 193 // |server_id_| is a tuple (hostname, port, is_https) of the server. | 196 // |server_id_| is a tuple (hostname, port, is_https) of the server. |
| 194 QuicServerId server_id_; | 197 QuicServerId server_id_; |
| 195 | 198 |
| 196 // config_ and crypto_config_ contain configuration and cached state about | 199 // config_ and crypto_config_ contain configuration and cached state about |
| 197 // servers. | 200 // servers. |
| 198 QuicConfig config_; | 201 QuicConfig config_; |
| 199 QuicCryptoClientConfig crypto_config_; | 202 QuicCryptoClientConfig crypto_config_; |
| 200 | 203 |
| 201 // Helper to be used by created connections. Needs to outlive |session_|. | 204 // Helper to be used by created connections. Needs to outlive |session_|. |
| 202 scoped_ptr<QuicConnectionHelperInterface> helper_; | 205 scoped_ptr<QuicConnectionHelperInterface> helper_; |
| 203 | 206 |
| 207 // Alarm factory used for alarm creation. Needs to outlive |session_|. | |
| 208 scoped_ptr<QuicAlarmFactory> alarm_factory_; | |
|
Ryan Hamilton
2016/04/18 22:10:54
nit:unique_ptr
| |
| 209 | |
| 204 // Writer used to actually send packets to the wire. Needs to outlive | 210 // Writer used to actually send packets to the wire. Needs to outlive |
| 205 // |session_|. | 211 // |session_|. |
| 206 scoped_ptr<QuicPacketWriter> writer_; | 212 scoped_ptr<QuicPacketWriter> writer_; |
| 207 | 213 |
| 208 // Session which manages streams. | 214 // Session which manages streams. |
| 209 scoped_ptr<QuicClientSession> session_; | 215 scoped_ptr<QuicClientSession> session_; |
| 210 | 216 |
| 211 // This vector contains QUIC versions which we currently support. | 217 // This vector contains QUIC versions which we currently support. |
| 212 // This should be ordered such that the highest supported version is the first | 218 // This should be ordered such that the highest supported version is the first |
| 213 // element, with subsequent elements in descending order (versions can be | 219 // element, with subsequent elements in descending order (versions can be |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 241 bool connected_or_attempting_connect_; | 247 bool connected_or_attempting_connect_; |
| 242 | 248 |
| 243 QuicClientPushPromiseIndex push_promise_index_; | 249 QuicClientPushPromiseIndex push_promise_index_; |
| 244 | 250 |
| 245 DISALLOW_COPY_AND_ASSIGN(QuicClientBase); | 251 DISALLOW_COPY_AND_ASSIGN(QuicClientBase); |
| 246 }; | 252 }; |
| 247 | 253 |
| 248 } // namespace net | 254 } // namespace net |
| 249 | 255 |
| 250 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_BASE_H_ | 256 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_BASE_H_ |
| OLD | NEW |