Chromium Code Reviews| 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 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "net/base/address_list.h" | 21 #include "net/base/address_list.h" |
| 22 #include "net/base/completion_callback.h" | 22 #include "net/base/completion_callback.h" |
| 23 #include "net/base/host_port_pair.h" | 23 #include "net/base/host_port_pair.h" |
| 24 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
| 25 #include "net/cert/cert_database.h" | 25 #include "net/cert/cert_database.h" |
| 26 #include "net/http/http_server_properties.h" | 26 #include "net/http/http_server_properties.h" |
| 27 #include "net/log/net_log.h" | 27 #include "net/log/net_log.h" |
| 28 #include "net/net_features.h" | |
| 28 #include "net/proxy/proxy_server.h" | 29 #include "net/proxy/proxy_server.h" |
| 29 #include "net/quic/network_connection.h" | 30 #include "net/quic/network_connection.h" |
| 30 #include "net/quic/quic_chromium_client_session.h" | 31 #include "net/quic/quic_chromium_client_session.h" |
| 31 #include "net/quic/quic_client_push_promise_index.h" | 32 #include "net/quic/quic_client_push_promise_index.h" |
| 32 #include "net/quic/quic_config.h" | 33 #include "net/quic/quic_config.h" |
| 33 #include "net/quic/quic_crypto_stream.h" | 34 #include "net/quic/quic_crypto_stream.h" |
| 34 #include "net/quic/quic_http_stream.h" | 35 #include "net/quic/quic_http_stream.h" |
| 35 #include "net/quic/quic_protocol.h" | 36 #include "net/quic/quic_protocol.h" |
| 36 #include "net/ssl/ssl_config_service.h" | 37 #include "net/ssl/ssl_config_service.h" |
| 37 | 38 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 48 class QuicChromiumClientSession; | 49 class QuicChromiumClientSession; |
| 49 class QuicChromiumConnectionHelper; | 50 class QuicChromiumConnectionHelper; |
| 50 class QuicCryptoClientStreamFactory; | 51 class QuicCryptoClientStreamFactory; |
| 51 class QuicRandom; | 52 class QuicRandom; |
| 52 class QuicServerId; | 53 class QuicServerId; |
| 53 class QuicServerInfo; | 54 class QuicServerInfo; |
| 54 class QuicServerInfoFactory; | 55 class QuicServerInfoFactory; |
| 55 class QuicStreamFactory; | 56 class QuicStreamFactory; |
| 56 class SocketPerformanceWatcherFactory; | 57 class SocketPerformanceWatcherFactory; |
| 57 class TransportSecurityState; | 58 class TransportSecurityState; |
| 59 class BidirectionalStreamJob; | |
| 58 | 60 |
| 59 namespace test { | 61 namespace test { |
| 60 class QuicStreamFactoryPeer; | 62 class QuicStreamFactoryPeer; |
| 61 } // namespace test | 63 } // namespace test |
| 62 | 64 |
| 63 // When a connection is idle for 30 seconds it will be closed. | 65 // When a connection is idle for 30 seconds it will be closed. |
| 64 const int kIdleConnectionTimeoutSeconds = 30; | 66 const int kIdleConnectionTimeoutSeconds = 30; |
| 65 | 67 |
| 66 // Encapsulates a pending request for a QuicHttpStream. | 68 // Encapsulates a pending request for a QuicHttpStream. |
| 67 // If the request is still pending when it is destroyed, it will | 69 // If the request is still pending when it is destroyed, it will |
| 68 // cancel the request with the factory. | 70 // cancel the request with the factory. |
| 69 class NET_EXPORT_PRIVATE QuicStreamRequest { | 71 class NET_EXPORT_PRIVATE QuicStreamRequest { |
| 70 public: | 72 public: |
| 71 explicit QuicStreamRequest(QuicStreamFactory* factory); | 73 explicit QuicStreamRequest(QuicStreamFactory* factory); |
| 72 ~QuicStreamRequest(); | 74 ~QuicStreamRequest(); |
| 73 | 75 |
| 74 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is | 76 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is |
| 75 // passed to CertVerifier::Verify. | 77 // passed to CertVerifier::Verify. |
| 76 int Request(const HostPortPair& host_port_pair, | 78 int Request(const HostPortPair& host_port_pair, |
| 77 PrivacyMode privacy_mode, | 79 PrivacyMode privacy_mode, |
| 78 int cert_verify_flags, | 80 int cert_verify_flags, |
| 79 const GURL& url, | 81 const GURL& url, |
| 80 base::StringPiece method, | 82 base::StringPiece method, |
| 81 const BoundNetLog& net_log, | 83 const BoundNetLog& net_log, |
| 82 const CompletionCallback& callback); | 84 const CompletionCallback& callback, |
| 85 bool for_bidirectional); | |
|
Ryan Hamilton
2016/03/03 04:14:58
Ditto about using the enum instead of the boolean.
xunjieli
2016/03/03 16:54:19
Done.
| |
| 83 | 86 |
| 84 void OnRequestComplete(int rv); | 87 void OnRequestComplete(int rv); |
| 85 | 88 |
| 86 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It | 89 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It |
| 87 // returns the amount of time waiting job should be delayed. | 90 // returns the amount of time waiting job should be delayed. |
| 88 base::TimeDelta GetTimeDelayForWaitingJob() const; | 91 base::TimeDelta GetTimeDelayForWaitingJob() const; |
| 89 | 92 |
| 90 scoped_ptr<QuicHttpStream> ReleaseStream(); | 93 scoped_ptr<QuicHttpStream> ReleaseStream(); |
| 91 | 94 |
| 92 void set_stream(scoped_ptr<QuicHttpStream> stream); | 95 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
| 96 scoped_ptr<BidirectionalStreamJob> ReleaseBidirectionalStreamJob(); | |
| 97 #endif | |
| 98 | |
| 99 // Initializes |stream_| or |bidirectional_stream_job_| from |session|. | |
| 100 void InitializeStreamFromSession(QuicChromiumClientSession* session); | |
| 93 | 101 |
| 94 const std::string& origin_host() const { return origin_host_; } | 102 const std::string& origin_host() const { return origin_host_; } |
| 95 | 103 |
| 96 PrivacyMode privacy_mode() const { return privacy_mode_; } | 104 PrivacyMode privacy_mode() const { return privacy_mode_; } |
| 97 | 105 |
| 98 const BoundNetLog& net_log() const { return net_log_; } | 106 const BoundNetLog& net_log() const { return net_log_; } |
| 99 | 107 |
| 100 private: | 108 private: |
| 101 QuicStreamFactory* factory_; | 109 QuicStreamFactory* factory_; |
| 102 HostPortPair host_port_pair_; | 110 HostPortPair host_port_pair_; |
| 103 std::string origin_host_; | 111 std::string origin_host_; |
| 104 string url_; | 112 string url_; |
| 105 PrivacyMode privacy_mode_; | 113 PrivacyMode privacy_mode_; |
| 106 BoundNetLog net_log_; | 114 BoundNetLog net_log_; |
| 107 CompletionCallback callback_; | 115 CompletionCallback callback_; |
| 108 scoped_ptr<QuicHttpStream> stream_; | 116 scoped_ptr<QuicHttpStream> stream_; |
| 109 | 117 |
| 118 bool for_bidirectional_; | |
|
Ryan Hamilton
2016/03/03 04:14:58
Should this be inside this #ifdef?
xunjieli
2016/03/03 16:54:19
Done.
| |
| 119 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) | |
| 120 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_job_; | |
| 121 #endif | |
| 122 | |
| 110 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); | 123 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); |
| 111 }; | 124 }; |
| 112 | 125 |
| 113 // A factory for creating new QuicHttpStreams on top of a pool of | 126 // A factory for creating new QuicHttpStreams on top of a pool of |
| 114 // QuicChromiumClientSessions. | 127 // QuicChromiumClientSessions. |
| 115 class NET_EXPORT_PRIVATE QuicStreamFactory | 128 class NET_EXPORT_PRIVATE QuicStreamFactory |
| 116 : public NetworkChangeNotifier::IPAddressObserver, | 129 : public NetworkChangeNotifier::IPAddressObserver, |
| 117 public NetworkChangeNotifier::NetworkObserver, | 130 public NetworkChangeNotifier::NetworkObserver, |
| 118 public SSLConfigService::Observer, | 131 public SSLConfigService::Observer, |
| 119 public CertDatabase::Observer { | 132 public CertDatabase::Observer { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 base::TaskRunner* task_runner_; | 549 base::TaskRunner* task_runner_; |
| 537 | 550 |
| 538 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 551 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
| 539 | 552 |
| 540 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 553 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
| 541 }; | 554 }; |
| 542 | 555 |
| 543 } // namespace net | 556 } // namespace net |
| 544 | 557 |
| 545 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 558 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| OLD | NEW |