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