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