| 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 #include "net/tools/quic/quic_simple_client.h" | 5 #include "net/tools/quic/quic_simple_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 namespace tools { | 30 namespace tools { |
| 31 | 31 |
| 32 void QuicSimpleClient::ClientQuicDataToResend::Resend() { | 32 void QuicSimpleClient::ClientQuicDataToResend::Resend() { |
| 33 client_->SendRequest(*headers_, body_, fin_); | 33 client_->SendRequest(*headers_, body_, fin_); |
| 34 delete headers_; | 34 delete headers_; |
| 35 headers_ = nullptr; | 35 headers_ = nullptr; |
| 36 } | 36 } |
| 37 | 37 |
| 38 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, | 38 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, |
| 39 const QuicServerId& server_id, | 39 const QuicServerId& server_id, |
| 40 const QuicVersionVector& supported_versions) | 40 const QuicVersionVector& supported_versions, |
| 41 : QuicClientBase(server_id, supported_versions, QuicConfig()), | 41 ProofVerifier* proof_verifier) |
| 42 : QuicClientBase(server_id, |
| 43 supported_versions, |
| 44 QuicConfig(), |
| 45 proof_verifier), |
| 42 server_address_(server_address), | 46 server_address_(server_address), |
| 43 local_port_(0), | 47 local_port_(0), |
| 44 helper_(CreateQuicConnectionHelper()), | 48 helper_(CreateQuicConnectionHelper()), |
| 45 initialized_(false), | 49 initialized_(false), |
| 46 packet_reader_started_(false), | 50 packet_reader_started_(false), |
| 47 weak_factory_(this) {} | 51 weak_factory_(this) {} |
| 48 | 52 |
| 49 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, | 53 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, |
| 50 const QuicServerId& server_id, | 54 const QuicServerId& server_id, |
| 51 const QuicVersionVector& supported_versions, | 55 const QuicVersionVector& supported_versions, |
| 52 const QuicConfig& config) | 56 const QuicConfig& config, |
| 53 : QuicClientBase(server_id, supported_versions, config), | 57 ProofVerifier* proof_verifier) |
| 58 : QuicClientBase(server_id, supported_versions, config, proof_verifier), |
| 54 server_address_(server_address), | 59 server_address_(server_address), |
| 55 local_port_(0), | 60 local_port_(0), |
| 56 helper_(CreateQuicConnectionHelper()), | 61 helper_(CreateQuicConnectionHelper()), |
| 57 initialized_(false), | 62 initialized_(false), |
| 58 packet_reader_started_(false), | 63 packet_reader_started_(false), |
| 59 weak_factory_(this) {} | 64 weak_factory_(this) {} |
| 60 | 65 |
| 61 QuicSimpleClient::~QuicSimpleClient() { | 66 QuicSimpleClient::~QuicSimpleClient() { |
| 62 if (connected()) { | 67 if (connected()) { |
| 63 session()->connection()->SendConnectionClosePacket( | 68 session()->connection()->SendConnectionClosePacket( |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // be resent on the next successful connection. | 213 // be resent on the next successful connection. |
| 209 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe | 214 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe |
| 210 // we should just maintain one queue? | 215 // we should just maintain one queue? |
| 211 DCHECK(data_to_resend_on_connect_.empty()); | 216 DCHECK(data_to_resend_on_connect_.empty()); |
| 212 data_to_resend_on_connect_.swap(data_sent_before_handshake_); | 217 data_to_resend_on_connect_.swap(data_sent_before_handshake_); |
| 213 } | 218 } |
| 214 } | 219 } |
| 215 | 220 |
| 216 CreateQuicClientSession(new QuicConnection( | 221 CreateQuicClientSession(new QuicConnection( |
| 217 GetNextConnectionId(), server_address_, helper_.get(), factory, | 222 GetNextConnectionId(), server_address_, helper_.get(), factory, |
| 218 /* owns_writer= */ false, Perspective::IS_CLIENT, server_id().is_https(), | 223 /* owns_writer= */ false, Perspective::IS_CLIENT, supported_versions())); |
| 219 supported_versions())); | |
| 220 | 224 |
| 221 session()->Initialize(); | 225 session()->Initialize(); |
| 222 session()->CryptoConnect(); | 226 session()->CryptoConnect(); |
| 223 set_connected_or_attempting_connect(true); | 227 set_connected_or_attempting_connect(true); |
| 224 } | 228 } |
| 225 | 229 |
| 226 void QuicSimpleClient::Disconnect() { | 230 void QuicSimpleClient::Disconnect() { |
| 227 DCHECK(initialized_); | 231 DCHECK(initialized_); |
| 228 | 232 |
| 229 if (connected()) { | 233 if (connected()) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 packet); | 401 packet); |
| 398 if (!session()->connection()->connected()) { | 402 if (!session()->connection()->connected()) { |
| 399 return false; | 403 return false; |
| 400 } | 404 } |
| 401 | 405 |
| 402 return true; | 406 return true; |
| 403 } | 407 } |
| 404 | 408 |
| 405 } // namespace tools | 409 } // namespace tools |
| 406 } // namespace net | 410 } // namespace net |
| OLD | NEW |