| 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/quic/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <openssl/aead.h> | 7 #include <openssl/aead.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "crypto/openssl_util.h" | 27 #include "crypto/openssl_util.h" |
| 28 #include "net/base/ip_address.h" | 28 #include "net/base/ip_address.h" |
| 29 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 30 #include "net/cert/cert_verifier.h" | 30 #include "net/cert/cert_verifier.h" |
| 31 #include "net/cert/ct_verifier.h" | 31 #include "net/cert/ct_verifier.h" |
| 32 #include "net/dns/host_resolver.h" | 32 #include "net/dns/host_resolver.h" |
| 33 #include "net/dns/single_request_host_resolver.h" | |
| 34 #include "net/http/bidirectional_stream_impl.h" | 33 #include "net/http/bidirectional_stream_impl.h" |
| 35 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" | 34 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
| 36 #include "net/quic/chromium/crypto/channel_id_chromium.h" | 35 #include "net/quic/chromium/crypto/channel_id_chromium.h" |
| 37 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" | 36 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" |
| 38 #include "net/quic/chromium/port_suggester.h" | 37 #include "net/quic/chromium/port_suggester.h" |
| 39 #include "net/quic/chromium/quic_chromium_alarm_factory.h" | 38 #include "net/quic/chromium/quic_chromium_alarm_factory.h" |
| 40 #include "net/quic/chromium/quic_chromium_connection_helper.h" | 39 #include "net/quic/chromium/quic_chromium_connection_helper.h" |
| 41 #include "net/quic/chromium/quic_chromium_packet_reader.h" | 40 #include "net/quic/chromium/quic_chromium_packet_reader.h" |
| 42 #include "net/quic/chromium/quic_chromium_packet_writer.h" | 41 #include "net/quic/chromium/quic_chromium_packet_writer.h" |
| 43 #include "net/quic/core/crypto/proof_verifier.h" | 42 #include "net/quic/core/crypto/proof_verifier.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 STATE_RESOLVE_HOST_COMPLETE, | 325 STATE_RESOLVE_HOST_COMPLETE, |
| 327 STATE_LOAD_SERVER_INFO, | 326 STATE_LOAD_SERVER_INFO, |
| 328 STATE_LOAD_SERVER_INFO_COMPLETE, | 327 STATE_LOAD_SERVER_INFO_COMPLETE, |
| 329 STATE_CONNECT, | 328 STATE_CONNECT, |
| 330 STATE_RESUME_CONNECT, | 329 STATE_RESUME_CONNECT, |
| 331 STATE_CONNECT_COMPLETE, | 330 STATE_CONNECT_COMPLETE, |
| 332 }; | 331 }; |
| 333 IoState io_state_; | 332 IoState io_state_; |
| 334 | 333 |
| 335 QuicStreamFactory* factory_; | 334 QuicStreamFactory* factory_; |
| 336 SingleRequestHostResolver host_resolver_; | 335 HostResolver* host_resolver_; |
| 336 std::unique_ptr<HostResolver::Request> request_; |
| 337 QuicSessionKey key_; | 337 QuicSessionKey key_; |
| 338 int cert_verify_flags_; | 338 int cert_verify_flags_; |
| 339 bool was_alternative_service_recently_broken_; | 339 bool was_alternative_service_recently_broken_; |
| 340 std::unique_ptr<QuicServerInfo> server_info_; | 340 std::unique_ptr<QuicServerInfo> server_info_; |
| 341 bool started_another_job_; | 341 bool started_another_job_; |
| 342 const BoundNetLog net_log_; | 342 const BoundNetLog net_log_; |
| 343 int num_sent_client_hellos_; | 343 int num_sent_client_hellos_; |
| 344 QuicChromiumClientSession* session_; | 344 QuicChromiumClientSession* session_; |
| 345 CompletionCallback callback_; | 345 CompletionCallback callback_; |
| 346 AddressList address_list_; | 346 AddressList address_list_; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 OnIOComplete(OK); | 470 OnIOComplete(OK); |
| 471 } | 471 } |
| 472 | 472 |
| 473 int QuicStreamFactory::Job::DoResolveHost() { | 473 int QuicStreamFactory::Job::DoResolveHost() { |
| 474 // Start loading the data now, and wait for it after we resolve the host. | 474 // Start loading the data now, and wait for it after we resolve the host. |
| 475 if (server_info_) | 475 if (server_info_) |
| 476 server_info_->Start(); | 476 server_info_->Start(); |
| 477 | 477 |
| 478 io_state_ = STATE_RESOLVE_HOST_COMPLETE; | 478 io_state_ = STATE_RESOLVE_HOST_COMPLETE; |
| 479 dns_resolution_start_time_ = base::TimeTicks::Now(); | 479 dns_resolution_start_time_ = base::TimeTicks::Now(); |
| 480 return host_resolver_.Resolve( | 480 return host_resolver_->Resolve( |
| 481 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, | 481 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, |
| 482 &address_list_, | 482 &address_list_, |
| 483 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), | 483 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), |
| 484 net_log_); | 484 &request_, net_log_); |
| 485 } | 485 } |
| 486 | 486 |
| 487 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { | 487 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { |
| 488 dns_resolution_end_time_ = base::TimeTicks::Now(); | 488 dns_resolution_end_time_ = base::TimeTicks::Now(); |
| 489 UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolutionTime", | 489 UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolutionTime", |
| 490 dns_resolution_end_time_ - dns_resolution_start_time_); | 490 dns_resolution_end_time_ - dns_resolution_start_time_); |
| 491 if (rv != OK) | 491 if (rv != OK) |
| 492 return rv; | 492 return rv; |
| 493 | 493 |
| 494 DCHECK(!factory_->HasActiveSession(key_.server_id())); | 494 DCHECK(!factory_->HasActiveSession(key_.server_id())); |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 // Since the session was active, there's no longer an | 2038 // Since the session was active, there's no longer an |
| 2039 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 2039 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 2040 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 2040 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 2041 // it as recently broken, which means that 0-RTT will be disabled but we'll | 2041 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 2042 // still race. | 2042 // still race. |
| 2043 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 2043 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 2044 alternative_service); | 2044 alternative_service); |
| 2045 } | 2045 } |
| 2046 | 2046 |
| 2047 } // namespace net | 2047 } // namespace net |
| OLD | NEW |