| 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" |
| 11 #include "net/http/http_request_info.h" | 11 #include "net/http/http_request_info.h" |
| 12 #include "net/http/http_response_info.h" | 12 #include "net/http/http_response_info.h" |
| 13 #include "net/quic/crypto/quic_random.h" | 13 #include "net/quic/crypto/quic_random.h" |
| 14 #include "net/quic/quic_chromium_connection_helper.h" |
| 14 #include "net/quic/quic_connection.h" | 15 #include "net/quic/quic_connection.h" |
| 15 #include "net/quic/quic_connection_helper.h" | |
| 16 #include "net/quic/quic_default_packet_writer.h" | 16 #include "net/quic/quic_default_packet_writer.h" |
| 17 #include "net/quic/quic_flags.h" | 17 #include "net/quic/quic_flags.h" |
| 18 #include "net/quic/quic_packet_reader.h" | 18 #include "net/quic/quic_packet_reader.h" |
| 19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
| 20 #include "net/quic/quic_server_id.h" | 20 #include "net/quic/quic_server_id.h" |
| 21 #include "net/quic/spdy_utils.h" | 21 #include "net/quic/spdy_utils.h" |
| 22 #include "net/spdy/spdy_header_block.h" | 22 #include "net/spdy/spdy_header_block.h" |
| 23 #include "net/spdy/spdy_http_utils.h" | 23 #include "net/spdy/spdy_http_utils.h" |
| 24 #include "net/udp/udp_client_socket.h" | 24 #include "net/udp/udp_client_socket.h" |
| 25 | 25 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 const string& QuicSimpleClient::latest_response_body() const { | 371 const string& QuicSimpleClient::latest_response_body() const { |
| 372 LOG_IF(DFATAL, !store_response_) << "Response not stored!"; | 372 LOG_IF(DFATAL, !store_response_) << "Response not stored!"; |
| 373 return latest_response_body_; | 373 return latest_response_body_; |
| 374 } | 374 } |
| 375 | 375 |
| 376 QuicConnectionId QuicSimpleClient::GenerateNewConnectionId() { | 376 QuicConnectionId QuicSimpleClient::GenerateNewConnectionId() { |
| 377 return helper()->GetRandomGenerator()->RandUint64(); | 377 return helper()->GetRandomGenerator()->RandUint64(); |
| 378 } | 378 } |
| 379 | 379 |
| 380 QuicConnectionHelper* QuicSimpleClient::CreateQuicConnectionHelper() { | 380 QuicChromiumConnectionHelper* QuicSimpleClient::CreateQuicConnectionHelper() { |
| 381 return new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), | 381 return new QuicChromiumConnectionHelper( |
| 382 &clock_, QuicRandom::GetInstance()); | 382 base::ThreadTaskRunnerHandle::Get().get(), &clock_, |
| 383 QuicRandom::GetInstance()); |
| 383 } | 384 } |
| 384 | 385 |
| 385 QuicPacketWriter* QuicSimpleClient::CreateQuicPacketWriter() { | 386 QuicPacketWriter* QuicSimpleClient::CreateQuicPacketWriter() { |
| 386 return new QuicDefaultPacketWriter(socket_.get()); | 387 return new QuicDefaultPacketWriter(socket_.get()); |
| 387 } | 388 } |
| 388 | 389 |
| 389 void QuicSimpleClient::OnReadError(int result, | 390 void QuicSimpleClient::OnReadError(int result, |
| 390 const DatagramClientSocket* socket) { | 391 const DatagramClientSocket* socket) { |
| 391 LOG(ERROR) << "QuicSimpleClient read failed: " << ErrorToShortString(result); | 392 LOG(ERROR) << "QuicSimpleClient read failed: " << ErrorToShortString(result); |
| 392 Disconnect(); | 393 Disconnect(); |
| 393 } | 394 } |
| 394 | 395 |
| 395 bool QuicSimpleClient::OnPacket(const QuicEncryptedPacket& packet, | 396 bool QuicSimpleClient::OnPacket(const QuicEncryptedPacket& packet, |
| 396 IPEndPoint local_address, | 397 IPEndPoint local_address, |
| 397 IPEndPoint peer_address) { | 398 IPEndPoint peer_address) { |
| 398 session()->connection()->ProcessUdpPacket(local_address, peer_address, | 399 session()->connection()->ProcessUdpPacket(local_address, peer_address, |
| 399 packet); | 400 packet); |
| 400 if (!session()->connection()->connected()) { | 401 if (!session()->connection()->connected()) { |
| 401 return false; | 402 return false; |
| 402 } | 403 } |
| 403 | 404 |
| 404 return true; | 405 return true; |
| 405 } | 406 } |
| 406 | 407 |
| 407 } // namespace tools | 408 } // namespace tools |
| 408 } // namespace net | 409 } // namespace net |
| OLD | NEW |