| 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, supported_versions, QuicConfig(), |
| 43 proof_verifier), |
| 42 server_address_(server_address), | 44 server_address_(server_address), |
| 43 local_port_(0), | 45 local_port_(0), |
| 44 helper_(CreateQuicConnectionHelper()), | 46 helper_(CreateQuicConnectionHelper()), |
| 45 initialized_(false), | 47 initialized_(false), |
| 46 packet_reader_started_(false), | 48 packet_reader_started_(false), |
| 47 weak_factory_(this) {} | 49 weak_factory_(this) {} |
| 48 | 50 |
| 49 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, | 51 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, |
| 50 const QuicServerId& server_id, | 52 const QuicServerId& server_id, |
| 51 const QuicVersionVector& supported_versions, | 53 const QuicVersionVector& supported_versions, |
| 52 const QuicConfig& config) | 54 const QuicConfig& config, |
| 53 : QuicClientBase(server_id, supported_versions, config), | 55 ProofVerifier* proof_verifier) |
| 56 : QuicClientBase(server_id, supported_versions, config, proof_verifier), |
| 54 server_address_(server_address), | 57 server_address_(server_address), |
| 55 local_port_(0), | 58 local_port_(0), |
| 56 helper_(CreateQuicConnectionHelper()), | 59 helper_(CreateQuicConnectionHelper()), |
| 57 initialized_(false), | 60 initialized_(false), |
| 58 packet_reader_started_(false), | 61 packet_reader_started_(false), |
| 59 weak_factory_(this) {} | 62 weak_factory_(this) {} |
| 60 | 63 |
| 61 QuicSimpleClient::~QuicSimpleClient() { | 64 QuicSimpleClient::~QuicSimpleClient() { |
| 62 if (connected()) { | 65 if (connected()) { |
| 63 session()->connection()->SendConnectionClosePacket( | 66 session()->connection()->SendConnectionClosePacket( |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // be resent on the next successful connection. | 211 // be resent on the next successful connection. |
| 209 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe | 212 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe |
| 210 // we should just maintain one queue? | 213 // we should just maintain one queue? |
| 211 DCHECK(data_to_resend_on_connect_.empty()); | 214 DCHECK(data_to_resend_on_connect_.empty()); |
| 212 data_to_resend_on_connect_.swap(data_sent_before_handshake_); | 215 data_to_resend_on_connect_.swap(data_sent_before_handshake_); |
| 213 } | 216 } |
| 214 } | 217 } |
| 215 | 218 |
| 216 CreateQuicClientSession(new QuicConnection( | 219 CreateQuicClientSession(new QuicConnection( |
| 217 GetNextConnectionId(), server_address_, helper_.get(), factory, | 220 GetNextConnectionId(), server_address_, helper_.get(), factory, |
| 218 /* owns_writer= */ false, Perspective::IS_CLIENT, server_id().is_https(), | 221 /* owns_writer= */ false, Perspective::IS_CLIENT, supported_versions())); |
| 219 supported_versions())); | |
| 220 | 222 |
| 221 session()->Initialize(); | 223 session()->Initialize(); |
| 222 session()->CryptoConnect(); | 224 session()->CryptoConnect(); |
| 223 set_connected_or_attempting_connect(true); | 225 set_connected_or_attempting_connect(true); |
| 224 } | 226 } |
| 225 | 227 |
| 226 void QuicSimpleClient::Disconnect() { | 228 void QuicSimpleClient::Disconnect() { |
| 227 DCHECK(initialized_); | 229 DCHECK(initialized_); |
| 228 | 230 |
| 229 if (connected()) { | 231 if (connected()) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 packet); | 395 packet); |
| 394 if (!session()->connection()->connected()) { | 396 if (!session()->connection()->connected()) { |
| 395 return false; | 397 return false; |
| 396 } | 398 } |
| 397 | 399 |
| 398 return true; | 400 return true; |
| 399 } | 401 } |
| 400 | 402 |
| 401 } // namespace tools | 403 } // namespace tools |
| 402 } // namespace net | 404 } // namespace net |
| OLD | NEW |