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 #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 Loading... |
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 Loading... |
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, CertVerifierJob*> CertVerifierJobMap; |
372 | 375 |
373 enum FactoryStatus { | 376 enum FactoryStatus { |
374 OPEN, // New streams may be created. | 377 OPEN, // New streams may be created. |
375 CLOSED, // No new streams may be created temporarily. | 378 CLOSED, // No new streams may be created temporarily. |
376 DISABLED // No more streams may be created until the network changes. | 379 DISABLED // No more streams may be created until the network changes. |
377 }; | 380 }; |
378 | 381 |
379 // Creates a job which doesn't wait for server config to be loaded from the | 382 // 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. | 383 // disk cache. This job is started via a PostTask. |
381 void CreateAuxilaryJob(const QuicSessionKey& key, | 384 void CreateAuxilaryJob(const QuicSessionKey& key, |
382 int cert_verify_flags, | 385 int cert_verify_flags, |
383 const BoundNetLog& net_log); | 386 const BoundNetLog& net_log); |
384 | 387 |
385 // Returns a newly created QuicHttpStream owned by the caller. | 388 // Returns a newly created QuicHttpStream owned by the caller. |
386 std::unique_ptr<QuicHttpStream> CreateFromSession( | 389 std::unique_ptr<QuicHttpStream> CreateFromSession( |
387 QuicChromiumClientSession* session); | 390 QuicChromiumClientSession* session); |
388 | 391 |
389 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); | 392 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); |
390 void OnJobComplete(Job* job, int rv); | 393 void OnJobComplete(Job* job, int rv); |
| 394 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv); |
391 bool HasActiveSession(const QuicServerId& server_id) const; | 395 bool HasActiveSession(const QuicServerId& server_id) const; |
392 bool HasActiveJob(const QuicServerId& server_id) const; | 396 bool HasActiveJob(const QuicServerId& server_id) const; |
| 397 bool HasActiveCertVerifierJob(const QuicServerId& server_id) const; |
393 int CreateSession(const QuicSessionKey& key, | 398 int CreateSession(const QuicSessionKey& key, |
394 int cert_verify_flags, | 399 int cert_verify_flags, |
395 std::unique_ptr<QuicServerInfo> quic_server_info, | 400 std::unique_ptr<QuicServerInfo> quic_server_info, |
396 const AddressList& address_list, | 401 const AddressList& address_list, |
397 base::TimeTicks dns_resolution_end_time, | 402 base::TimeTicks dns_resolution_end_time, |
398 const BoundNetLog& net_log, | 403 const BoundNetLog& net_log, |
399 QuicChromiumClientSession** session); | 404 QuicChromiumClientSession** session); |
400 void ActivateSession(const QuicSessionKey& key, | 405 void ActivateSession(const QuicSessionKey& key, |
401 QuicChromiumClientSession* session); | 406 QuicChromiumClientSession* session); |
402 | 407 |
403 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there | 408 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there |
404 // is no |http_server_properties_| or if |http_server_properties_| doesn't | 409 // is no |http_server_properties_| or if |http_server_properties_| doesn't |
405 // have ServerNetworkStats for the given |server_id|. | 410 // have ServerNetworkStats for the given |server_id|. |
406 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( | 411 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( |
407 const QuicServerId& server_id) const; | 412 const QuicServerId& server_id) const; |
408 | 413 |
409 // Helper methods. | 414 // Helper methods. |
410 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; | 415 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; |
411 | 416 |
412 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); | 417 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); |
413 | 418 |
| 419 // Starts an asynchronous job for cert verification if |
| 420 // |race_cert_verification_| is enabled and if there are cached certs for the |
| 421 // given |server_id|. |
| 422 void StartCertVerifyJob(const QuicServerId& server_id, |
| 423 int cert_verify_flags, |
| 424 const BoundNetLog& net_log); |
| 425 |
414 // Initializes the cached state associated with |server_id| in | 426 // Initializes the cached state associated with |server_id| in |
415 // |crypto_config_| with the information in |server_info|. Populates | 427 // |crypto_config_| with the information in |server_info|. Populates |
416 // |connection_id| with the next server designated connection id, | 428 // |connection_id| with the next server designated connection id, |
417 // if any, and otherwise leaves it unchanged. | 429 // if any, and otherwise leaves it unchanged. |
418 void InitializeCachedStateInCryptoConfig( | 430 void InitializeCachedStateInCryptoConfig( |
419 const QuicServerId& server_id, | 431 const QuicServerId& server_id, |
420 const std::unique_ptr<QuicServerInfo>& server_info, | 432 const std::unique_ptr<QuicServerInfo>& server_info, |
421 QuicConnectionId* connection_id); | 433 QuicConnectionId* connection_id); |
422 | 434 |
423 // Initialize |quic_supported_servers_at_startup_| with the list of servers | 435 // Initialize |quic_supported_servers_at_startup_| with the list of servers |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 // Origins which have gone away recently. | 483 // Origins which have gone away recently. |
472 AliasSet gone_away_aliases_; | 484 AliasSet gone_away_aliases_; |
473 | 485 |
474 const QuicConfig config_; | 486 const QuicConfig config_; |
475 QuicCryptoClientConfig crypto_config_; | 487 QuicCryptoClientConfig crypto_config_; |
476 | 488 |
477 JobMap active_jobs_; | 489 JobMap active_jobs_; |
478 ServerIDRequestsMap job_requests_map_; | 490 ServerIDRequestsMap job_requests_map_; |
479 RequestMap active_requests_; | 491 RequestMap active_requests_; |
480 | 492 |
| 493 CertVerifierJobMap active_cert_verifier_jobs_; |
| 494 |
481 QuicVersionVector supported_versions_; | 495 QuicVersionVector supported_versions_; |
482 | 496 |
483 // Determine if we should consistently select a client UDP port. If false, | 497 // 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 | 498 // then we will just let the OS select a random client port for each new |
485 // connection. | 499 // connection. |
486 bool enable_port_selection_; | 500 bool enable_port_selection_; |
487 | 501 |
488 // Set if we always require handshake confirmation. If true, this will | 502 // 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. | 503 // introduce at least one RTT for the handshake before the client sends data. |
490 bool always_require_handshake_confirmation_; | 504 bool always_require_handshake_confirmation_; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 const bool close_sessions_on_ip_change_; | 567 const bool close_sessions_on_ip_change_; |
554 | 568 |
555 // Set if migration should be attempted on active sessions when primary | 569 // Set if migration should be attempted on active sessions when primary |
556 // interface changes. | 570 // interface changes. |
557 const bool migrate_sessions_on_network_change_; | 571 const bool migrate_sessions_on_network_change_; |
558 | 572 |
559 // Set if early migration should be attempted when the connection | 573 // Set if early migration should be attempted when the connection |
560 // experiences poor connectivity. | 574 // experiences poor connectivity. |
561 const bool migrate_sessions_early_; | 575 const bool migrate_sessions_early_; |
562 | 576 |
| 577 // Set if cert verification is to be raced with host resolution. |
| 578 bool race_cert_verification_; |
| 579 |
563 // Each profile will (probably) have a unique port_seed_ value. This value | 580 // 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 | 581 // is used to help seed a pseudo-random number generator (PortSuggester) so |
565 // that we consistently (within this profile) suggest the same ephemeral | 582 // that we consistently (within this profile) suggest the same ephemeral |
566 // port when we re-connect to any given server/port. The differences between | 583 // port when we re-connect to any given server/port. The differences between |
567 // profiles (probablistically) prevent two profiles from colliding in their | 584 // profiles (probablistically) prevent two profiles from colliding in their |
568 // ephemeral port requests. | 585 // ephemeral port requests. |
569 uint64_t port_seed_; | 586 uint64_t port_seed_; |
570 | 587 |
571 // Local address of socket that was created in CreateSession. | 588 // Local address of socket that was created in CreateSession. |
572 IPEndPoint local_address_; | 589 IPEndPoint local_address_; |
(...skipping 15 matching lines...) Expand all Loading... |
588 const scoped_refptr<SSLConfigService> ssl_config_service_; | 605 const scoped_refptr<SSLConfigService> ssl_config_service_; |
589 | 606 |
590 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 607 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
591 | 608 |
592 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 609 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
593 }; | 610 }; |
594 | 611 |
595 } // namespace net | 612 } // namespace net |
596 | 613 |
597 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 614 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |