Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: net/quic/quic_stream_factory.cc

Issue 1540463003: Change the interface of GetAlternativeServicesFor, always return the best Alt-Svc entry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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): crbug.com/498823 - delete active_sessions_.empty() checks.
Ryan Hamilton 2016/01/05 23:51:58 Can you say more about this?
Zhongyi Shi 2016/01/06 02:31:40 I talked to raman earlier about that bug, this is
716 if (active_sessions_.empty())
717 return false;
718 SessionMap::iterator it = active_sessions_.find(server_id);
719 if (it == active_sessions_.end())
720 return false;
721 QuicChromiumClientSession* session = it->second;
722 return session->CanPool(origin_host.as_string(), privacy_mode);
723 }
724
713 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, 725 int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
714 PrivacyMode privacy_mode, 726 PrivacyMode privacy_mode,
715 int cert_verify_flags, 727 int cert_verify_flags,
716 base::StringPiece origin_host, 728 base::StringPiece origin_host,
717 base::StringPiece method, 729 base::StringPiece method,
718 const BoundNetLog& net_log, 730 const BoundNetLog& net_log,
719 QuicStreamRequest* request) { 731 QuicStreamRequest* request) {
720 QuicServerId server_id(host_port_pair, privacy_mode); 732 QuicServerId server_id(host_port_pair, privacy_mode);
721 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. 733 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks.
722 if (!active_sessions_.empty()) { 734 if (!active_sessions_.empty()) {
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 // Since the session was active, there's no longer an 1468 // Since the session was active, there's no longer an
1457 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1469 // 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 1470 // 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 1471 // it as recently broken, which means that 0-RTT will be disabled but we'll
1460 // still race. 1472 // still race.
1461 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1473 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1462 alternative_service); 1474 alternative_service);
1463 } 1475 }
1464 1476
1465 } // namespace net 1477 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698