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

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

Issue 2120703003: QUIC - Race Cert Verification with host resolution if certs are (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor optimization, when verifying certs only skip policy checks. Created 4 years, 5 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 #ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_ 5 #ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_
6 #define NET_QUIC_QUIC_STREAM_FACTORY_H_ 6 #define NET_QUIC_QUIC_STREAM_FACTORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 int threshold_timeouts_with_streams_open, 179 int threshold_timeouts_with_streams_open,
180 int threshold_public_resets_post_handshake, 180 int threshold_public_resets_post_handshake,
181 int socket_receive_buffer_size, 181 int socket_receive_buffer_size,
182 bool delay_tcp_race, 182 bool delay_tcp_race,
183 int max_server_configs_stored_in_properties, 183 int max_server_configs_stored_in_properties,
184 bool close_sessions_on_ip_change, 184 bool close_sessions_on_ip_change,
185 bool disable_quic_on_timeout_with_open_streams, 185 bool disable_quic_on_timeout_with_open_streams,
186 int idle_connection_timeout_seconds, 186 int idle_connection_timeout_seconds,
187 bool migrate_sessions_on_network_change, 187 bool migrate_sessions_on_network_change,
188 bool migrate_sessions_early, 188 bool migrate_sessions_early,
189 bool race_cert_verification,
189 const QuicTagVector& connection_options, 190 const QuicTagVector& connection_options,
190 bool enable_token_binding); 191 bool enable_token_binding);
191 ~QuicStreamFactory() override; 192 ~QuicStreamFactory() override;
192 193
193 // Returns true if there is an existing session for |server_id| or if the 194 // Returns true if there is an existing session for |server_id| or if the
194 // request can be pooled to an existing session to the IP address of 195 // request can be pooled to an existing session to the IP address of
195 // |destination|. 196 // |destination|.
196 bool CanUseExistingSession(const QuicServerId& server_id, 197 bool CanUseExistingSession(const QuicServerId& server_id,
197 const HostPortPair& destination); 198 const HostPortPair& destination);
198 199
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void set_enable_connection_racing(bool enable_connection_racing) { 346 void set_enable_connection_racing(bool enable_connection_racing) {
346 enable_connection_racing_ = enable_connection_racing; 347 enable_connection_racing_ = enable_connection_racing;
347 } 348 }
348 349
349 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } 350 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; }
350 351
351 bool delay_tcp_race() const { return delay_tcp_race_; } 352 bool delay_tcp_race() const { return delay_tcp_race_; }
352 353
353 private: 354 private:
354 class Job; 355 class Job;
356 class CertVerifierJob;
355 friend class test::QuicStreamFactoryPeer; 357 friend class test::QuicStreamFactoryPeer;
356 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); 358 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad);
357 359
358 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; 360 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap;
359 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; 361 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap;
360 typedef std::set<QuicSessionKey> AliasSet; 362 typedef std::set<QuicSessionKey> AliasSet;
361 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; 363 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap;
362 typedef std::set<QuicChromiumClientSession*> SessionSet; 364 typedef std::set<QuicChromiumClientSession*> SessionSet;
363 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; 365 typedef std::map<IPEndPoint, SessionSet> IPAliasMap;
364 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; 366 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap;
365 typedef std::set<Job*> JobSet; 367 typedef std::set<Job*> JobSet;
366 typedef std::map<QuicServerId, JobSet> JobMap; 368 typedef std::map<QuicServerId, JobSet> JobMap;
367 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; 369 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap;
368 typedef std::set<QuicStreamRequest*> RequestSet; 370 typedef std::set<QuicStreamRequest*> RequestSet;
369 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; 371 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
370 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> 372 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason>
371 DisabledReasonsQueue; 373 DisabledReasonsQueue;
374 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>>
375 CertVerifierJobMap;
372 376
373 enum FactoryStatus { 377 enum FactoryStatus {
374 OPEN, // New streams may be created. 378 OPEN, // New streams may be created.
375 CLOSED, // No new streams may be created temporarily. 379 CLOSED, // No new streams may be created temporarily.
376 DISABLED // No more streams may be created until the network changes. 380 DISABLED // No more streams may be created until the network changes.
377 }; 381 };
378 382
379 // Creates a job which doesn't wait for server config to be loaded from the 383 // Creates a job which doesn't wait for server config to be loaded from the
380 // disk cache. This job is started via a PostTask. 384 // disk cache. This job is started via a PostTask.
381 void CreateAuxilaryJob(const QuicSessionKey& key, 385 void CreateAuxilaryJob(const QuicSessionKey& key,
382 int cert_verify_flags, 386 int cert_verify_flags,
383 const BoundNetLog& net_log); 387 const BoundNetLog& net_log);
384 388
385 // Returns a newly created QuicHttpStream owned by the caller. 389 // Returns a newly created QuicHttpStream owned by the caller.
386 std::unique_ptr<QuicHttpStream> CreateFromSession( 390 std::unique_ptr<QuicHttpStream> CreateFromSession(
387 QuicChromiumClientSession* session); 391 QuicChromiumClientSession* session);
388 392
389 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); 393 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list);
390 void OnJobComplete(Job* job, int rv); 394 void OnJobComplete(Job* job, int rv);
395 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv);
391 bool HasActiveSession(const QuicServerId& server_id) const; 396 bool HasActiveSession(const QuicServerId& server_id) const;
392 bool HasActiveJob(const QuicServerId& server_id) const; 397 bool HasActiveJob(const QuicServerId& server_id) const;
398 bool HasActiveCertVerifierJob(const QuicServerId& server_id) const;
393 int CreateSession(const QuicSessionKey& key, 399 int CreateSession(const QuicSessionKey& key,
394 int cert_verify_flags, 400 int cert_verify_flags,
395 std::unique_ptr<QuicServerInfo> quic_server_info, 401 std::unique_ptr<QuicServerInfo> quic_server_info,
396 const AddressList& address_list, 402 const AddressList& address_list,
397 base::TimeTicks dns_resolution_end_time, 403 base::TimeTicks dns_resolution_end_time,
398 const BoundNetLog& net_log, 404 const BoundNetLog& net_log,
399 QuicChromiumClientSession** session); 405 QuicChromiumClientSession** session);
400 void ActivateSession(const QuicSessionKey& key, 406 void ActivateSession(const QuicSessionKey& key,
401 QuicChromiumClientSession* session); 407 QuicChromiumClientSession* session);
402 408
403 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there 409 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
404 // is no |http_server_properties_| or if |http_server_properties_| doesn't 410 // is no |http_server_properties_| or if |http_server_properties_| doesn't
405 // have ServerNetworkStats for the given |server_id|. 411 // have ServerNetworkStats for the given |server_id|.
406 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( 412 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds(
407 const QuicServerId& server_id) const; 413 const QuicServerId& server_id) const;
408 414
409 // Helper methods. 415 // Helper methods.
410 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; 416 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const;
411 417
412 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); 418 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id);
413 419
420 // Starts an asynchronous job for cert verification if
421 // |race_cert_verification_| is enabled and if there are cached certs for the
422 // given |server_id|.
423 void StartCertVerifyJob(const QuicServerId& server_id,
424 int cert_verify_flags,
425 const BoundNetLog& net_log);
426
414 // Initializes the cached state associated with |server_id| in 427 // Initializes the cached state associated with |server_id| in
415 // |crypto_config_| with the information in |server_info|. Populates 428 // |crypto_config_| with the information in |server_info|. Populates
416 // |connection_id| with the next server designated connection id, 429 // |connection_id| with the next server designated connection id,
417 // if any, and otherwise leaves it unchanged. 430 // if any, and otherwise leaves it unchanged.
418 void InitializeCachedStateInCryptoConfig( 431 void InitializeCachedStateInCryptoConfig(
419 const QuicServerId& server_id, 432 const QuicServerId& server_id,
420 const std::unique_ptr<QuicServerInfo>& server_info, 433 const std::unique_ptr<QuicServerInfo>& server_info,
421 QuicConnectionId* connection_id); 434 QuicConnectionId* connection_id);
422 435
423 // Initialize |quic_supported_servers_at_startup_| with the list of servers 436 // Initialize |quic_supported_servers_at_startup_| with the list of servers
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 // Origins which have gone away recently. 484 // Origins which have gone away recently.
472 AliasSet gone_away_aliases_; 485 AliasSet gone_away_aliases_;
473 486
474 const QuicConfig config_; 487 const QuicConfig config_;
475 QuicCryptoClientConfig crypto_config_; 488 QuicCryptoClientConfig crypto_config_;
476 489
477 JobMap active_jobs_; 490 JobMap active_jobs_;
478 ServerIDRequestsMap job_requests_map_; 491 ServerIDRequestsMap job_requests_map_;
479 RequestMap active_requests_; 492 RequestMap active_requests_;
480 493
494 CertVerifierJobMap active_cert_verifier_jobs_;
495
481 QuicVersionVector supported_versions_; 496 QuicVersionVector supported_versions_;
482 497
483 // Determine if we should consistently select a client UDP port. If false, 498 // Determine if we should consistently select a client UDP port. If false,
484 // then we will just let the OS select a random client port for each new 499 // then we will just let the OS select a random client port for each new
485 // connection. 500 // connection.
486 bool enable_port_selection_; 501 bool enable_port_selection_;
487 502
488 // Set if we always require handshake confirmation. If true, this will 503 // Set if we always require handshake confirmation. If true, this will
489 // introduce at least one RTT for the handshake before the client sends data. 504 // introduce at least one RTT for the handshake before the client sends data.
490 bool always_require_handshake_confirmation_; 505 bool always_require_handshake_confirmation_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 const bool close_sessions_on_ip_change_; 568 const bool close_sessions_on_ip_change_;
554 569
555 // Set if migration should be attempted on active sessions when primary 570 // Set if migration should be attempted on active sessions when primary
556 // interface changes. 571 // interface changes.
557 const bool migrate_sessions_on_network_change_; 572 const bool migrate_sessions_on_network_change_;
558 573
559 // Set if early migration should be attempted when the connection 574 // Set if early migration should be attempted when the connection
560 // experiences poor connectivity. 575 // experiences poor connectivity.
561 const bool migrate_sessions_early_; 576 const bool migrate_sessions_early_;
562 577
578 // Set if cert verification is to be raced with host resolution.
579 bool race_cert_verification_;
580
563 // Each profile will (probably) have a unique port_seed_ value. This value 581 // Each profile will (probably) have a unique port_seed_ value. This value
564 // is used to help seed a pseudo-random number generator (PortSuggester) so 582 // is used to help seed a pseudo-random number generator (PortSuggester) so
565 // that we consistently (within this profile) suggest the same ephemeral 583 // that we consistently (within this profile) suggest the same ephemeral
566 // port when we re-connect to any given server/port. The differences between 584 // port when we re-connect to any given server/port. The differences between
567 // profiles (probablistically) prevent two profiles from colliding in their 585 // profiles (probablistically) prevent two profiles from colliding in their
568 // ephemeral port requests. 586 // ephemeral port requests.
569 uint64_t port_seed_; 587 uint64_t port_seed_;
570 588
571 // Local address of socket that was created in CreateSession. 589 // Local address of socket that was created in CreateSession.
572 IPEndPoint local_address_; 590 IPEndPoint local_address_;
(...skipping 15 matching lines...) Expand all
588 const scoped_refptr<SSLConfigService> ssl_config_service_; 606 const scoped_refptr<SSLConfigService> ssl_config_service_;
589 607
590 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; 608 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
591 609
592 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); 610 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
593 }; 611 };
594 612
595 } // namespace net 613 } // namespace net
596 614
597 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ 615 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698