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