| 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/test_tools/quic_test_client.h" | 5 #include "net/tools/quic/test_tools/quic_test_client.h" |
| 6 | 6 |
| 7 #include "net/base/completion_callback.h" | 7 #include "net/base/completion_callback.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/cert/cert_verify_result.h" | 9 #include "net/cert/cert_verify_result.h" |
| 10 #include "net/cert/x509_certificate.h" | 10 #include "net/cert/x509_certificate.h" |
| 11 #include "net/quic/crypto/proof_verifier.h" | 11 #include "net/quic/crypto/proof_verifier.h" |
| 12 #include "net/tools/flip_server/balsa_headers.h" | 12 #include "net/tools/flip_server/balsa_headers.h" |
| 13 #include "net/tools/quic/quic_epoll_connection_helper.h" | 13 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 14 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 14 #include "net/tools/quic/test_tools/http_message_test_utils.h" | 15 #include "net/tools/quic/test_tools/http_message_test_utils.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 using std::string; | 18 using std::string; |
| 18 using std::vector; | 19 using std::vector; |
| 19 using base::StringPiece; | 20 using base::StringPiece; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // RecordingProofVerifier accepts any certificate chain and records the common | 24 // RecordingProofVerifier accepts any certificate chain and records the common |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 : client_(new QuicEpollClient(address, hostname, config, version)) { | 152 : client_(new QuicEpollClient(address, hostname, config, version)) { |
| 152 Initialize(address, hostname, secure); | 153 Initialize(address, hostname, secure); |
| 153 } | 154 } |
| 154 | 155 |
| 155 void QuicTestClient::Initialize(IPEndPoint address, | 156 void QuicTestClient::Initialize(IPEndPoint address, |
| 156 const string& hostname, | 157 const string& hostname, |
| 157 bool secure) { | 158 bool secure) { |
| 158 server_address_ = address; | 159 server_address_ = address; |
| 159 stream_ = NULL; | 160 stream_ = NULL; |
| 160 stream_error_ = QUIC_STREAM_NO_ERROR; | 161 stream_error_ = QUIC_STREAM_NO_ERROR; |
| 162 priority_ = 3; |
| 161 bytes_read_ = 0; | 163 bytes_read_ = 0; |
| 162 bytes_written_= 0; | 164 bytes_written_= 0; |
| 163 never_connected_ = true; | 165 never_connected_ = true; |
| 164 secure_ = secure; | 166 secure_ = secure; |
| 165 auto_reconnect_ = false; | 167 auto_reconnect_ = false; |
| 166 proof_verifier_ = NULL; | 168 proof_verifier_ = NULL; |
| 167 ExpectCertificates(secure_); | 169 ExpectCertificates(secure_); |
| 168 } | 170 } |
| 169 | 171 |
| 170 QuicTestClient::~QuicTestClient() { | 172 QuicTestClient::~QuicTestClient() { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 if (never_connected_ == true || auto_reconnect_) { | 239 if (never_connected_ == true || auto_reconnect_) { |
| 238 if (!connected()) { | 240 if (!connected()) { |
| 239 Connect(); | 241 Connect(); |
| 240 } | 242 } |
| 241 if (!connected()) { | 243 if (!connected()) { |
| 242 return NULL; | 244 return NULL; |
| 243 } | 245 } |
| 244 } | 246 } |
| 245 if (!stream_) { | 247 if (!stream_) { |
| 246 stream_ = client_->CreateReliableClientStream(); | 248 stream_ = client_->CreateReliableClientStream(); |
| 247 if (stream_ != NULL) { | 249 if (stream_ == NULL) { |
| 248 stream_->set_visitor(this); | 250 return NULL; |
| 249 } | 251 } |
| 252 stream_->set_visitor(this); |
| 253 reinterpret_cast<QuicSpdyClientStream*>(stream_)->set_priority(priority_); |
| 250 } | 254 } |
| 255 |
| 251 return stream_; | 256 return stream_; |
| 252 } | 257 } |
| 253 | 258 |
| 254 const string& QuicTestClient::cert_common_name() const { | 259 const string& QuicTestClient::cert_common_name() const { |
| 255 return reinterpret_cast<RecordingProofVerifier*>(proof_verifier_) | 260 return reinterpret_cast<RecordingProofVerifier*>(proof_verifier_) |
| 256 ->common_name(); | 261 ->common_name(); |
| 257 } | 262 } |
| 258 | 263 |
| 259 bool QuicTestClient::connected() const { | 264 bool QuicTestClient::connected() const { |
| 260 return client_->connected(); | 265 return client_->connected(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 338 } |
| 334 | 339 |
| 335 void QuicTestClient::UseWriter(QuicTestWriter* writer) { | 340 void QuicTestClient::UseWriter(QuicTestWriter* writer) { |
| 336 DCHECK(!connected()); | 341 DCHECK(!connected()); |
| 337 reinterpret_cast<QuicEpollClient*>(client_.get())->UseWriter(writer); | 342 reinterpret_cast<QuicEpollClient*>(client_.get())->UseWriter(writer); |
| 338 } | 343 } |
| 339 | 344 |
| 340 } // namespace test | 345 } // namespace test |
| 341 } // namespace tools | 346 } // namespace tools |
| 342 } // namespace net | 347 } // namespace net |
| OLD | NEW |