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

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

Issue 2814633003: Extract Proxy Resolution out of HttpStreamFactoryImpl::Job (Closed)
Patch Set: fix remaining tests Created 3 years, 7 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_CHROMIUM_QUIC_STREAM_FACTORY_H_ 5 #ifndef NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_
6 #define NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_ 6 #define NET_QUIC_CHROMIUM_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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 MIGRATION_STATUS_DISABLED, 101 MIGRATION_STATUS_DISABLED,
102 MIGRATION_STATUS_NO_ALTERNATE_NETWORK, 102 MIGRATION_STATUS_NO_ALTERNATE_NETWORK,
103 MIGRATION_STATUS_MAX 103 MIGRATION_STATUS_MAX
104 }; 104 };
105 105
106 // Encapsulates a pending request for a QuicHttpStream. 106 // Encapsulates a pending request for a QuicHttpStream.
107 // If the request is still pending when it is destroyed, it will 107 // If the request is still pending when it is destroyed, it will
108 // cancel the request with the factory. 108 // cancel the request with the factory.
109 class NET_EXPORT_PRIVATE QuicStreamRequest { 109 class NET_EXPORT_PRIVATE QuicStreamRequest {
110 public: 110 public:
111 explicit QuicStreamRequest(QuicStreamFactory* factory, 111 QuicStreamRequest(QuicStreamFactory* factory,
112 HttpServerProperties* http_server_properties); 112 HttpServerProperties* http_server_properties);
113 ~QuicStreamRequest(); 113 ~QuicStreamRequest();
114 114
115 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is 115 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is
116 // passed to CertVerifier::Verify. 116 // passed to CertVerifier::Verify.
117 // |destination| will be resolved and resulting IPEndPoint used to open a 117 // |destination| will be resolved and resulting IPEndPoint used to open a
118 // QuicConnection. This can be different than HostPortPair::FromURL(url). 118 // QuicConnection. This can be different than HostPortPair::FromURL(url).
119 int Request(const HostPortPair& destination, 119 virtual int Request(const HostPortPair& destination,
120 PrivacyMode privacy_mode, 120 PrivacyMode privacy_mode,
121 int cert_verify_flags, 121 int cert_verify_flags,
122 const GURL& url, 122 const GURL& url,
123 QuicStringPiece method, 123 QuicStringPiece method,
124 const NetLogWithSource& net_log, 124 const NetLogWithSource& net_log,
125 const CompletionCallback& callback); 125 const CompletionCallback& callback);
126 126
127 void OnRequestComplete(int rv); 127 void OnRequestComplete(int rv);
128 128
129 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It 129 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It
130 // returns the amount of time waiting job should be delayed. 130 // returns the amount of time waiting job should be delayed.
131 base::TimeDelta GetTimeDelayForWaitingJob() const; 131 base::TimeDelta GetTimeDelayForWaitingJob() const;
132 132
133 std::unique_ptr<QuicHttpStream> CreateStream(); 133 virtual std::unique_ptr<HttpStream> CreateStream();
134 134
135 std::unique_ptr<BidirectionalStreamImpl> CreateBidirectionalStreamImpl(); 135 virtual std::unique_ptr<BidirectionalStreamImpl>
136 CreateBidirectionalStreamImpl();
136 137
137 // Sets |session_|. 138 // Sets |session_|.
138 void SetSession(QuicChromiumClientSession* session); 139 void SetSession(QuicChromiumClientSession* session);
139 140
140 const QuicServerId& server_id() const { return server_id_; } 141 const QuicServerId& server_id() const { return server_id_; }
141 142
142 const NetLogWithSource& net_log() const { return net_log_; } 143 const NetLogWithSource& net_log() const { return net_log_; }
143 144
144 private: 145 private:
145 QuicStreamFactory* factory_; 146 QuicStreamFactory* factory_;
146 HttpServerProperties* http_server_properties_; 147 HttpServerProperties* http_server_properties_;
147 QuicServerId server_id_; 148 QuicServerId server_id_;
148 NetLogWithSource net_log_; 149 NetLogWithSource net_log_;
149 CompletionCallback callback_; 150 CompletionCallback callback_;
150 base::WeakPtr<QuicChromiumClientSession> session_; 151 base::WeakPtr<QuicChromiumClientSession> session_;
151 152
152 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); 153 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
153 }; 154 };
154 155
156 // A default factory for creating QuicStreamRequest. Subclassed for testing
157 // purpose.
158 class NET_EXPORT_PRIVATE QuicStreamRequestFactory {
159 public:
160 QuicStreamRequestFactory();
161 ~QuicStreamRequestFactory();
162
163 virtual std::unique_ptr<QuicStreamRequest> CreateRequest(
164 QuicStreamFactory* factory,
165 HttpServerProperties* http_server_properties);
166 };
167
155 // A factory for creating new QuicHttpStreams on top of a pool of 168 // A factory for creating new QuicHttpStreams on top of a pool of
156 // QuicChromiumClientSessions. 169 // QuicChromiumClientSessions.
157 class NET_EXPORT_PRIVATE QuicStreamFactory 170 class NET_EXPORT_PRIVATE QuicStreamFactory
158 : public NetworkChangeNotifier::IPAddressObserver, 171 : public NetworkChangeNotifier::IPAddressObserver,
159 public NetworkChangeNotifier::NetworkObserver, 172 public NetworkChangeNotifier::NetworkObserver,
160 public SSLConfigService::Observer, 173 public SSLConfigService::Observer,
161 public CertDatabase::Observer { 174 public CertDatabase::Observer {
162 public: 175 public:
163 // This class encompasses |destination| and |server_id|. 176 // This class encompasses |destination| and |server_id|.
164 // |destination| is a HostPortPair which is resolved 177 // |destination| is a HostPortPair which is resolved
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const QuicTagVector& connection_options, 236 const QuicTagVector& connection_options,
224 bool enable_token_binding); 237 bool enable_token_binding);
225 ~QuicStreamFactory() override; 238 ~QuicStreamFactory() override;
226 239
227 // Returns true if there is an existing session for |server_id| or if the 240 // Returns true if there is an existing session for |server_id| or if the
228 // request can be pooled to an existing session to the IP address of 241 // request can be pooled to an existing session to the IP address of
229 // |destination|. 242 // |destination|.
230 bool CanUseExistingSession(const QuicServerId& server_id, 243 bool CanUseExistingSession(const QuicServerId& server_id,
231 const HostPortPair& destination); 244 const HostPortPair& destination);
232 245
246 std::unique_ptr<QuicStreamRequest> CreateStreamRequest();
247
233 // Creates a new QuicHttpStream to |host_port_pair| which will be 248 // Creates a new QuicHttpStream to |host_port_pair| which will be
234 // owned by |request|. 249 // owned by |request|.
235 // If a matching session already exists, this method will return OK. If no 250 // If a matching session already exists, this method will return OK. If no
236 // matching session exists, this will return ERR_IO_PENDING and will invoke 251 // matching session exists, this will return ERR_IO_PENDING and will invoke
237 // OnRequestComplete asynchronously. 252 // OnRequestComplete asynchronously.
238 int Create(const QuicServerId& server_id, 253 int Create(const QuicServerId& server_id,
239 const HostPortPair& destination, 254 const HostPortPair& destination,
240 int cert_verify_flags, 255 int cert_verify_flags,
241 const GURL& url, 256 const GURL& url,
242 QuicStringPiece method, 257 QuicStringPiece method,
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // is created for every QUIC connection. 501 // is created for every QUIC connection.
487 // |socket_performance_watcher_factory_| may be null. 502 // |socket_performance_watcher_factory_| may be null.
488 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; 503 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
489 504
490 // The helper used for all connections. 505 // The helper used for all connections.
491 std::unique_ptr<QuicChromiumConnectionHelper> helper_; 506 std::unique_ptr<QuicChromiumConnectionHelper> helper_;
492 507
493 // The alarm factory used for all connections. 508 // The alarm factory used for all connections.
494 std::unique_ptr<QuicAlarmFactory> alarm_factory_; 509 std::unique_ptr<QuicAlarmFactory> alarm_factory_;
495 510
511 std::unique_ptr<QuicStreamRequestFactory> stream_request_factory_;
512
496 // Contains owning pointers to all sessions that currently exist. 513 // Contains owning pointers to all sessions that currently exist.
497 SessionIdMap all_sessions_; 514 SessionIdMap all_sessions_;
498 // Contains non-owning pointers to currently active session 515 // Contains non-owning pointers to currently active session
499 // (not going away session, once they're implemented). 516 // (not going away session, once they're implemented).
500 SessionMap active_sessions_; 517 SessionMap active_sessions_;
501 // Map from session to set of aliases that this session is known by. 518 // Map from session to set of aliases that this session is known by.
502 SessionAliasMap session_aliases_; 519 SessionAliasMap session_aliases_;
503 // Map from IP address to sessions which are connected to this address. 520 // Map from IP address to sessions which are connected to this address.
504 IPAliasMap ip_aliases_; 521 IPAliasMap ip_aliases_;
505 // Map from session to its original peer IP address. 522 // Map from session to its original peer IP address.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 const scoped_refptr<SSLConfigService> ssl_config_service_; 596 const scoped_refptr<SSLConfigService> ssl_config_service_;
580 597
581 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; 598 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
582 599
583 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); 600 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
584 }; 601 };
585 602
586 } // namespace net 603 } // namespace net
587 604
588 #endif // NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_ 605 #endif // NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698