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

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

Issue 1692253004: QUIC - chromium server push support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial for-review version Created 4 years, 10 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
(...skipping 20 matching lines...) Expand all
31 #include "net/quic/crypto/channel_id_chromium.h" 31 #include "net/quic/crypto/channel_id_chromium.h"
32 #include "net/quic/crypto/proof_verifier_chromium.h" 32 #include "net/quic/crypto/proof_verifier_chromium.h"
33 #include "net/quic/crypto/properties_based_quic_server_info.h" 33 #include "net/quic/crypto/properties_based_quic_server_info.h"
34 #include "net/quic/crypto/quic_random.h" 34 #include "net/quic/crypto/quic_random.h"
35 #include "net/quic/crypto/quic_server_info.h" 35 #include "net/quic/crypto/quic_server_info.h"
36 #include "net/quic/port_suggester.h" 36 #include "net/quic/port_suggester.h"
37 #include "net/quic/quic_chromium_client_session.h" 37 #include "net/quic/quic_chromium_client_session.h"
38 #include "net/quic/quic_chromium_connection_helper.h" 38 #include "net/quic/quic_chromium_connection_helper.h"
39 #include "net/quic/quic_chromium_packet_reader.h" 39 #include "net/quic/quic_chromium_packet_reader.h"
40 #include "net/quic/quic_chromium_packet_writer.h" 40 #include "net/quic/quic_chromium_packet_writer.h"
41 #include "net/quic/quic_client_promised_info.h"
41 #include "net/quic/quic_clock.h" 42 #include "net/quic/quic_clock.h"
42 #include "net/quic/quic_connection.h" 43 #include "net/quic/quic_connection.h"
43 #include "net/quic/quic_crypto_client_stream_factory.h" 44 #include "net/quic/quic_crypto_client_stream_factory.h"
44 #include "net/quic/quic_flags.h" 45 #include "net/quic/quic_flags.h"
45 #include "net/quic/quic_http_stream.h" 46 #include "net/quic/quic_http_stream.h"
46 #include "net/quic/quic_protocol.h" 47 #include "net/quic/quic_protocol.h"
47 #include "net/quic/quic_server_id.h" 48 #include "net/quic/quic_server_id.h"
48 #include "net/socket/client_socket_factory.h" 49 #include "net/socket/client_socket_factory.h"
49 #include "net/udp/udp_client_socket.h" 50 #include "net/udp/udp_client_socket.h"
50 51
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 QuicStreamRequest::~QuicStreamRequest() { 502 QuicStreamRequest::~QuicStreamRequest() {
502 if (factory_ && !callback_.is_null()) 503 if (factory_ && !callback_.is_null())
503 factory_->CancelRequest(this); 504 factory_->CancelRequest(this);
504 } 505 }
505 506
506 int QuicStreamRequest::Request(const HostPortPair& host_port_pair, 507 int QuicStreamRequest::Request(const HostPortPair& host_port_pair,
507 PrivacyMode privacy_mode, 508 PrivacyMode privacy_mode,
508 int cert_verify_flags, 509 int cert_verify_flags,
509 base::StringPiece origin_host, 510 base::StringPiece origin_host,
510 base::StringPiece method, 511 base::StringPiece method,
512 const string& url,
511 const BoundNetLog& net_log, 513 const BoundNetLog& net_log,
512 const CompletionCallback& callback) { 514 const CompletionCallback& callback) {
513 DCHECK(!stream_); 515 DCHECK(!stream_);
514 DCHECK(callback_.is_null()); 516 DCHECK(callback_.is_null());
515 DCHECK(factory_); 517 DCHECK(factory_);
516 origin_host_ = origin_host.as_string(); 518 origin_host_ = origin_host.as_string();
517 privacy_mode_ = privacy_mode; 519 privacy_mode_ = privacy_mode;
518 int rv = factory_->Create(host_port_pair, privacy_mode, cert_verify_flags, 520 int rv = factory_->Create(host_port_pair, privacy_mode, cert_verify_flags,
519 origin_host, method, net_log, this); 521 origin_host, method, url, net_log, this);
520 if (rv == ERR_IO_PENDING) { 522 if (rv == ERR_IO_PENDING) {
521 host_port_pair_ = host_port_pair; 523 host_port_pair_ = host_port_pair;
522 net_log_ = net_log; 524 net_log_ = net_log;
523 callback_ = callback; 525 callback_ = callback;
524 } else { 526 } else {
525 factory_ = nullptr; 527 factory_ = nullptr;
526 } 528 }
527 if (rv == OK) 529 if (rv == OK)
528 DCHECK(stream_); 530 DCHECK(stream_);
529 return rv; 531 return rv;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 kQuicYieldAfterDurationMilliseconds)), 637 kQuicYieldAfterDurationMilliseconds)),
636 close_sessions_on_ip_change_(close_sessions_on_ip_change), 638 close_sessions_on_ip_change_(close_sessions_on_ip_change),
637 migrate_sessions_on_network_change_( 639 migrate_sessions_on_network_change_(
638 migrate_sessions_on_network_change && 640 migrate_sessions_on_network_change &&
639 NetworkChangeNotifier::AreNetworkHandlesSupported()), 641 NetworkChangeNotifier::AreNetworkHandlesSupported()),
640 migrate_sessions_early_(migrate_sessions_early && 642 migrate_sessions_early_(migrate_sessions_early &&
641 migrate_sessions_on_network_change_), 643 migrate_sessions_on_network_change_),
642 port_seed_(random_generator_->RandUint64()), 644 port_seed_(random_generator_->RandUint64()),
643 check_persisted_supports_quic_(true), 645 check_persisted_supports_quic_(true),
644 has_initialized_data_(false), 646 has_initialized_data_(false),
647 num_push_streams_created_(0),
645 task_runner_(nullptr), 648 task_runner_(nullptr),
646 weak_factory_(this) { 649 weak_factory_(this) {
647 if (disable_quic_on_timeout_with_open_streams) 650 if (disable_quic_on_timeout_with_open_streams)
648 threshold_timeouts_with_open_streams_ = 1; 651 threshold_timeouts_with_open_streams_ = 1;
649 DCHECK(transport_security_state_); 652 DCHECK(transport_security_state_);
650 DCHECK(http_server_properties_); 653 DCHECK(http_server_properties_);
651 crypto_config_.set_user_agent_id(user_agent_id); 654 crypto_config_.set_user_agent_id(user_agent_id);
652 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); 655 crypto_config_.AddCanonicalSuffix(".c.youtube.com");
653 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); 656 crypto_config_.AddCanonicalSuffix(".googlevideo.com");
654 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); 657 crypto_config_.AddCanonicalSuffix(".googleusercontent.com");
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 return false; 758 return false;
756 QuicChromiumClientSession* session = it->second; 759 QuicChromiumClientSession* session = it->second;
757 return session->CanPool(origin_host.as_string(), privacy_mode); 760 return session->CanPool(origin_host.as_string(), privacy_mode);
758 } 761 }
759 762
760 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, 763 int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
761 PrivacyMode privacy_mode, 764 PrivacyMode privacy_mode,
762 int cert_verify_flags, 765 int cert_verify_flags,
763 base::StringPiece origin_host, 766 base::StringPiece origin_host,
764 base::StringPiece method, 767 base::StringPiece method,
768 const std::string& url,
765 const BoundNetLog& net_log, 769 const BoundNetLog& net_log,
766 QuicStreamRequest* request) { 770 QuicStreamRequest* request) {
771 // Enforce session affinity for promised streams.
772 QuicClientPromisedInfo* promised = push_promise_index_.GetPromised(url);
773 if (promised) {
774 QuicChromiumClientSession* session =
775 static_cast<QuicChromiumClientSession*>(promised->session());
776 DCHECK(session);
777 if (session->server_id().privacy_mode() == privacy_mode) {
778 request->set_stream(CreateFromSession(session));
779 ++num_push_streams_created_;
780 return OK;
781 }
782 // This should happen extremely rarely (if ever), but if somehow a
783 // request comes in with a mismatched privacy mode, consider the
784 // promise borked.
785 promised->Cancel();
Ryan Hamilton 2016/02/24 00:34:00 This suggests that privacy_mode should be part of
Buck 2016/02/26 23:54:17 It could but I think it would lead to some extra m
Ryan Hamilton 2016/02/29 17:49:40 I thought that privacy_mode was a field of HttpReq
Buck 2016/02/29 19:03:01 Yep, I was mistaken about privacy_mode availabilty
786 }
787
767 QuicServerId server_id(host_port_pair, privacy_mode); 788 QuicServerId server_id(host_port_pair, privacy_mode);
768 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. 789 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks.
769 if (!active_sessions_.empty()) { 790 if (!active_sessions_.empty()) {
770 SessionMap::iterator it = active_sessions_.find(server_id); 791 SessionMap::iterator it = active_sessions_.find(server_id);
771 if (it != active_sessions_.end()) { 792 if (it != active_sessions_.end()) {
772 QuicChromiumClientSession* session = it->second; 793 QuicChromiumClientSession* session = it->second;
773 if (!session->CanPool(origin_host.as_string(), privacy_mode)) 794 if (!session->CanPool(origin_host.as_string(), privacy_mode))
774 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; 795 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
775 request->set_stream(CreateFromSession(session)); 796 request->set_stream(CreateFromSession(session));
776 return OK; 797 return OK;
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 // Since the session was active, there's no longer an 1666 // Since the session was active, there's no longer an
1646 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1667 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1647 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1668 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1648 // it as recently broken, which means that 0-RTT will be disabled but we'll 1669 // it as recently broken, which means that 0-RTT will be disabled but we'll
1649 // still race. 1670 // still race.
1650 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1671 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1651 alternative_service); 1672 alternative_service);
1652 } 1673 }
1653 1674
1654 } // namespace net 1675 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698