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

Side by Side Diff: net/http/http_stream_factory_impl.cc

Issue 1580583002: Add a whitelist for QUIC hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/transport_security_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/transport_security_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698