Chromium Code Reviews| 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::CanPool(QuicServerId server_id, | |
| 710 PrivacyMode privacy_mode, | |
| 711 StringPiece origin_host) { | |
| 712 if (active_sessions_.empty()) | |
| 713 return false; | |
|
Ryan Hamilton
2015/12/18 22:56:29
I think you can remove these two lines...
Zhongyi Shi
2015/12/19 01:23:02
We have to leave it there. If we remove that, on A
| |
| 714 SessionMap::iterator it = active_sessions_.find(server_id); | |
| 715 if (it == active_sessions_.end()) | |
| 716 return false; | |
| 717 QuicChromiumClientSession* session = it->second; | |
| 718 return session->CanPool(origin_host.as_string(), privacy_mode); | |
| 719 } | |
| 720 | |
| 710 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, | 721 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, |
| 711 PrivacyMode privacy_mode, | 722 PrivacyMode privacy_mode, |
| 712 int cert_verify_flags, | 723 int cert_verify_flags, |
| 713 base::StringPiece origin_host, | 724 base::StringPiece origin_host, |
| 714 base::StringPiece method, | 725 base::StringPiece method, |
| 715 const BoundNetLog& net_log, | 726 const BoundNetLog& net_log, |
| 716 QuicStreamRequest* request) { | 727 QuicStreamRequest* request) { |
| 717 QuicServerId server_id(host_port_pair, privacy_mode); | 728 QuicServerId server_id(host_port_pair, privacy_mode); |
| 718 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. | 729 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. |
| 719 if (!active_sessions_.empty()) { | 730 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 | 1468 // Since the session was active, there's no longer an |
| 1458 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1469 // 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 | 1470 // 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 | 1471 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1461 // still race. | 1472 // still race. |
| 1462 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1473 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1463 alternative_service); | 1474 alternative_service); |
| 1464 } | 1475 } |
| 1465 | 1476 |
| 1466 } // namespace net | 1477 } // namespace net |
| OLD | NEW |