| 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/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <set> | 8 #include <set> | 
| 9 | 9 | 
| 10 #include "base/location.h" | 10 #include "base/location.h" | 
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" | 
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" | 
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" | 
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" | 
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" | 
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" | 
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" | 
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" | 
| 19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" | 
| 20 #include "base/values.h" | 20 #include "base/values.h" | 
| 21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" | 
| 22 #include "net/base/socket_performance_watcher.h" | 22 #include "net/base/socket_performance_watcher.h" | 
| 23 #include "net/base/socket_performance_watcher_factory.h" | 23 #include "net/base/socket_performance_watcher_factory.h" | 
| 24 #include "net/cert/cert_verifier.h" | 24 #include "net/cert/cert_verifier.h" | 
| 25 #include "net/cert/ct_verifier.h" | 25 #include "net/cert/ct_verifier.h" | 
| 26 #include "net/dns/host_resolver.h" | 26 #include "net/dns/host_resolver.h" | 
| 27 #include "net/dns/single_request_host_resolver.h" | 27 #include "net/dns/single_request_host_resolver.h" | 
| 28 #include "net/http/http_server_properties.h" |  | 
| 29 #include "net/quic/crypto/channel_id_chromium.h" | 28 #include "net/quic/crypto/channel_id_chromium.h" | 
| 30 #include "net/quic/crypto/proof_verifier_chromium.h" | 29 #include "net/quic/crypto/proof_verifier_chromium.h" | 
| 31 #include "net/quic/crypto/properties_based_quic_server_info.h" | 30 #include "net/quic/crypto/properties_based_quic_server_info.h" | 
| 32 #include "net/quic/crypto/quic_random.h" | 31 #include "net/quic/crypto/quic_random.h" | 
| 33 #include "net/quic/crypto/quic_server_info.h" | 32 #include "net/quic/crypto/quic_server_info.h" | 
| 34 #include "net/quic/port_suggester.h" | 33 #include "net/quic/port_suggester.h" | 
| 35 #include "net/quic/quic_chromium_client_session.h" | 34 #include "net/quic/quic_chromium_client_session.h" | 
| 36 #include "net/quic/quic_clock.h" | 35 #include "net/quic/quic_clock.h" | 
| 37 #include "net/quic/quic_connection.h" | 36 #include "net/quic/quic_connection.h" | 
| 38 #include "net/quic/quic_connection_helper.h" | 37 #include "net/quic/quic_connection_helper.h" | 
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 700   if (!srtt) | 699   if (!srtt) | 
| 701     srtt = kDefaultRTT; | 700     srtt = kDefaultRTT; | 
| 702   return base::TimeDelta::FromMicroseconds(srtt); | 701   return base::TimeDelta::FromMicroseconds(srtt); | 
| 703 } | 702 } | 
| 704 | 703 | 
| 705 void QuicStreamFactory::set_quic_server_info_factory( | 704 void QuicStreamFactory::set_quic_server_info_factory( | 
| 706     QuicServerInfoFactory* quic_server_info_factory) { | 705     QuicServerInfoFactory* quic_server_info_factory) { | 
| 707   quic_server_info_factory_.reset(quic_server_info_factory); | 706   quic_server_info_factory_.reset(quic_server_info_factory); | 
| 708 } | 707 } | 
| 709 | 708 | 
|  | 709 bool QuicStreamFactory::CanUseExistingSession(QuicServerId server_id, | 
|  | 710                                               PrivacyMode privacy_mode, | 
|  | 711                                               StringPiece origin_host) { | 
|  | 712   // TODO(zhongyi): crbug.com/498823 - delete active_sessions_.empty() checks. | 
|  | 713   if (active_sessions_.empty()) | 
|  | 714     return false; | 
|  | 715   SessionMap::iterator it = active_sessions_.find(server_id); | 
|  | 716   if (it == active_sessions_.end()) | 
|  | 717     return false; | 
|  | 718   QuicChromiumClientSession* session = it->second; | 
|  | 719   return session->CanPool(origin_host.as_string(), privacy_mode); | 
|  | 720 } | 
|  | 721 | 
| 710 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, | 722 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, | 
| 711                               PrivacyMode privacy_mode, | 723                               PrivacyMode privacy_mode, | 
| 712                               int cert_verify_flags, | 724                               int cert_verify_flags, | 
| 713                               base::StringPiece origin_host, | 725                               base::StringPiece origin_host, | 
| 714                               base::StringPiece method, | 726                               base::StringPiece method, | 
| 715                               const BoundNetLog& net_log, | 727                               const BoundNetLog& net_log, | 
| 716                               QuicStreamRequest* request) { | 728                               QuicStreamRequest* request) { | 
| 717   QuicServerId server_id(host_port_pair, privacy_mode); | 729   QuicServerId server_id(host_port_pair, privacy_mode); | 
| 718   // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. | 730   // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. | 
| 719   if (!active_sessions_.empty()) { | 731   if (!active_sessions_.empty()) { | 
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1457   // Since the session was active, there's no longer an | 1469   // Since the session was active, there's no longer an | 
| 1458   // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1470   // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 
| 1459   // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1471   // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 
| 1460   // it as recently broken, which means that 0-RTT will be disabled but we'll | 1472   // it as recently broken, which means that 0-RTT will be disabled but we'll | 
| 1461   // still race. | 1473   // still race. | 
| 1462   http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1474   http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 
| 1463       alternative_service); | 1475       alternative_service); | 
| 1464 } | 1476 } | 
| 1465 | 1477 | 
| 1466 }  // namespace net | 1478 }  // namespace net | 
| OLD | NEW | 
|---|