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

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
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/quic/quic_server_id.h" 19 #include "net/quic/quic_server_id.h"
18 #include "net/spdy/spdy_http_stream.h" 20 #include "net/spdy/spdy_http_stream.h"
19 #include "url/gurl.h" 21 #include "url/gurl.h"
20 22
21 #if defined(ENABLE_BIDIRECTIONAL_STREAM) 23 #if defined(ENABLE_BIDIRECTIONAL_STREAM)
22 #include "net/spdy/bidirectional_stream_spdy_job.h" 24 #include "net/spdy/bidirectional_stream_spdy_job.h"
23 #endif 25 #endif
24 26
25 namespace net { 27 namespace net {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 280
279 // Check whether there's an existing session to use for this QUIC Alt-Svc. 281 // Check whether there's an existing session to use for this QUIC Alt-Svc.
280 HostPortPair destination = alternative_service.host_port_pair(); 282 HostPortPair destination = alternative_service.host_port_pair();
281 std::string origin_host = 283 std::string origin_host =
282 ApplyHostMappingRules(request_info.url, &destination).host(); 284 ApplyHostMappingRules(request_info.url, &destination).host();
283 QuicServerId server_id(destination, request_info.privacy_mode); 285 QuicServerId server_id(destination, request_info.privacy_mode);
284 if (session_->quic_stream_factory()->CanUseExistingSession( 286 if (session_->quic_stream_factory()->CanUseExistingSession(
285 server_id, request_info.privacy_mode, origin_host)) 287 server_id, request_info.privacy_mode, origin_host))
286 return alternative_service; 288 return alternative_service;
287 289
290 if (!IsQuicWhitelistedForHost(destination.host()))
291 continue;
292
288 // Cache this entry if we don't have a non-broken Alt-Svc yet. 293 // Cache this entry if we don't have a non-broken Alt-Svc yet.
289 if (first_alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) 294 if (first_alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
290 first_alternative_service = alternative_service; 295 first_alternative_service = alternative_service;
291 } 296 }
292 297
293 // Ask delegate to mark QUIC as broken for the origin. 298 // Ask delegate to mark QUIC as broken for the origin.
294 if (quic_advertised && quic_all_broken && delegate != nullptr) 299 if (quic_advertised && quic_all_broken && delegate != nullptr)
295 delegate->OnQuicBroken(); 300 delegate->OnQuicBroken();
296 301
297 return first_alternative_service; 302 return first_alternative_service;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 orphaned_job_set_.erase(job); 363 orphaned_job_set_.erase(job);
359 delete job; 364 delete job;
360 } 365 }
361 366
362 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { 367 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
363 preconnect_job_set_.erase(job); 368 preconnect_job_set_.erase(job);
364 delete job; 369 delete job;
365 OnPreconnectsCompleteInternal(); 370 OnPreconnectsCompleteInternal();
366 } 371 }
367 372
373 bool HttpStreamFactoryImpl::IsQuicWhitelistedForHost(const std::string& host) {
374 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) {
375 return true;
376 }
Ryan Sleevi 2016/01/11 23:54:26 nit: This file uses no braces for single-line cond
Ryan Hamilton 2016/01/12 00:22:46 Indeed! I had a LOG(INFO) there and when I removed
377
378 for (const std::string& white : session_->params().quic_host_whitelist) {
Ryan Sleevi 2016/01/11 23:54:27 s/white/whitelisted_host/ Just the color name doe
Ryan Hamilton 2016/01/12 00:22:46 Agreed. (though this code is now gone.)
379 if (host == white)
Ryan Sleevi 2016/01/11 23:54:27 Is |host| guaranteed to be normalized? What about
Ryan Hamilton 2016/01/12 00:22:46 Hopefully, this will always be empty, but if it's
380 return true;
381 }
382
383 return base::EndsWith(host, ".snapchat.com",
Ryan Sleevi 2016/01/11 23:54:27 What about trailing dots? (.snapchat.com.) - do th
Ryan Hamilton 2016/01/12 00:22:46 they don't matter in this case.
384 base::CompareCase::INSENSITIVE_ASCII);
Ryan Sleevi 2016/01/11 23:54:27 If it's normalized (line 379), then you should be
Ryan Hamilton 2016/01/12 00:22:46 Done.
385 }
386
368 } // namespace net 387 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698