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_connection.h" | 14 #include "net/quic/quic_connection.h" |
15 #include "net/quic/quic_connection_helper.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_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
19 #include "net/quic/quic_server_id.h" | 19 #include "net/quic/quic_server_id.h" |
20 #include "net/quic/spdy_utils.h" | 20 #include "net/quic/spdy_utils.h" |
21 #include "net/spdy/spdy_http_utils.h" | 21 #include "net/spdy/spdy_http_utils.h" |
22 #include "net/udp/udp_client_socket.h" | 22 #include "net/udp/udp_client_socket.h" |
23 | 23 |
24 using std::string; | 24 using std::string; |
25 using std::vector; | 25 using std::vector; |
26 | 26 |
27 namespace net { | 27 namespace net { |
| 28 |
| 29 class SocketPerformanceWatcher; |
| 30 |
28 namespace tools { | 31 namespace tools { |
29 | 32 |
30 void QuicSimpleClient::ClientQuicDataToResend::Resend() { | 33 void QuicSimpleClient::ClientQuicDataToResend::Resend() { |
31 client_->SendRequest(*headers_, body_, fin_); | 34 client_->SendRequest(*headers_, body_, fin_); |
32 delete headers_; | 35 delete headers_; |
33 headers_ = nullptr; | 36 headers_ = nullptr; |
34 } | 37 } |
35 | 38 |
36 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, | 39 QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, |
37 const QuicServerId& server_id, | 40 const QuicServerId& server_id, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe | 208 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe |
206 // we should just maintain one queue? | 209 // we should just maintain one queue? |
207 DCHECK(data_to_resend_on_connect_.empty()); | 210 DCHECK(data_to_resend_on_connect_.empty()); |
208 data_to_resend_on_connect_.swap(data_sent_before_handshake_); | 211 data_to_resend_on_connect_.swap(data_sent_before_handshake_); |
209 } | 212 } |
210 } | 213 } |
211 | 214 |
212 CreateQuicClientSession(new QuicConnection( | 215 CreateQuicClientSession(new QuicConnection( |
213 GetNextConnectionId(), server_address_, helper_.get(), factory, | 216 GetNextConnectionId(), server_address_, helper_.get(), factory, |
214 /* owns_writer= */ false, Perspective::IS_CLIENT, server_id().is_https(), | 217 /* owns_writer= */ false, Perspective::IS_CLIENT, server_id().is_https(), |
215 supported_versions())); | 218 supported_versions(), scoped_ptr<SocketPerformanceWatcher>())); |
216 | 219 |
217 session()->Initialize(); | 220 session()->Initialize(); |
218 session()->CryptoConnect(); | 221 session()->CryptoConnect(); |
219 set_connected_or_attempting_connect(true); | 222 set_connected_or_attempting_connect(true); |
220 } | 223 } |
221 | 224 |
222 void QuicSimpleClient::Disconnect() { | 225 void QuicSimpleClient::Disconnect() { |
223 DCHECK(initialized_); | 226 DCHECK(initialized_); |
224 | 227 |
225 if (connected()) { | 228 if (connected()) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 packet); | 396 packet); |
394 if (!session()->connection()->connected()) { | 397 if (!session()->connection()->connected()) { |
395 return false; | 398 return false; |
396 } | 399 } |
397 | 400 |
398 return true; | 401 return true; |
399 } | 402 } |
400 | 403 |
401 } // namespace tools | 404 } // namespace tools |
402 } // namespace net | 405 } // namespace net |
OLD | NEW |