| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/strings/string_util.h" |
| 11 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 12 #include "net/http/http_network_session.h" | 13 #include "net/http/http_network_session.h" |
| 13 #include "net/http/http_server_properties.h" | 14 #include "net/http/http_server_properties.h" |
| 14 #include "net/http/http_stream_factory_impl_job.h" | 15 #include "net/http/http_stream_factory_impl_job.h" |
| 15 #include "net/http/http_stream_factory_impl_request.h" | 16 #include "net/http/http_stream_factory_impl_request.h" |
| 17 #include "net/http/transport_security_state.h" |
| 16 #include "net/log/net_log.h" | 18 #include "net/log/net_log.h" |
| 17 #include "net/net_features.h" | 19 #include "net/net_features.h" |
| 18 #include "net/quic/quic_server_id.h" | 20 #include "net/quic/quic_server_id.h" |
| 19 #include "net/spdy/spdy_http_stream.h" | 21 #include "net/spdy/spdy_http_stream.h" |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 21 | 23 |
| 22 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) | 24 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
| 23 #include "net/spdy/bidirectional_stream_spdy_job.h" | 25 #include "net/spdy/bidirectional_stream_spdy_job.h" |
| 24 #endif | 26 #endif |
| 25 | 27 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 281 |
| 280 // Check whether there's an existing session to use for this QUIC Alt-Svc. | 282 // Check whether there's an existing session to use for this QUIC Alt-Svc. |
| 281 HostPortPair destination = alternative_service.host_port_pair(); | 283 HostPortPair destination = alternative_service.host_port_pair(); |
| 282 std::string origin_host = | 284 std::string origin_host = |
| 283 ApplyHostMappingRules(request_info.url, &destination).host(); | 285 ApplyHostMappingRules(request_info.url, &destination).host(); |
| 284 QuicServerId server_id(destination, request_info.privacy_mode); | 286 QuicServerId server_id(destination, request_info.privacy_mode); |
| 285 if (session_->quic_stream_factory()->CanUseExistingSession( | 287 if (session_->quic_stream_factory()->CanUseExistingSession( |
| 286 server_id, request_info.privacy_mode, origin_host)) | 288 server_id, request_info.privacy_mode, origin_host)) |
| 287 return alternative_service; | 289 return alternative_service; |
| 288 | 290 |
| 291 if (!IsQuicWhitelistedForHost(destination.host())) |
| 292 continue; |
| 293 |
| 289 // Cache this entry if we don't have a non-broken Alt-Svc yet. | 294 // Cache this entry if we don't have a non-broken Alt-Svc yet. |
| 290 if (first_alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) | 295 if (first_alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 291 first_alternative_service = alternative_service; | 296 first_alternative_service = alternative_service; |
| 292 } | 297 } |
| 293 | 298 |
| 294 // Ask delegate to mark QUIC as broken for the origin. | 299 // Ask delegate to mark QUIC as broken for the origin. |
| 295 if (quic_advertised && quic_all_broken && delegate != nullptr) | 300 if (quic_advertised && quic_all_broken && delegate != nullptr) |
| 296 delegate->OnQuicBroken(); | 301 delegate->OnQuicBroken(); |
| 297 | 302 |
| 298 return first_alternative_service; | 303 return first_alternative_service; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 orphaned_job_set_.erase(job); | 364 orphaned_job_set_.erase(job); |
| 360 delete job; | 365 delete job; |
| 361 } | 366 } |
| 362 | 367 |
| 363 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 368 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
| 364 preconnect_job_set_.erase(job); | 369 preconnect_job_set_.erase(job); |
| 365 delete job; | 370 delete job; |
| 366 OnPreconnectsCompleteInternal(); | 371 OnPreconnectsCompleteInternal(); |
| 367 } | 372 } |
| 368 | 373 |
| 374 bool HttpStreamFactoryImpl::IsQuicWhitelistedForHost(const std::string& host) { |
| 375 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) |
| 376 return true; |
| 377 |
| 378 std::string lower_host = base::ToLowerASCII(host); |
| 379 if (ContainsKey(session_->params().quic_host_whitelist, lower_host)) |
| 380 return true; |
| 381 |
| 382 return base::EndsWith(lower_host, ".snapchat.com", |
| 383 base::CompareCase::SENSITIVE); |
| 384 } |
| 385 |
| 369 } // namespace net | 386 } // namespace net |
| OLD | NEW |