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

Side by Side Diff: net/http/http_stream_factory_impl_job.h

Issue 2814633003: Extract Proxy Resolution out of HttpStreamFactoryImpl::Job (Closed)
Patch Set: unstage unrelated changes 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_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 virtual void OnNeedsProxyAuth(Job* job, 95 virtual void OnNeedsProxyAuth(Job* job,
96 const HttpResponseInfo& proxy_response, 96 const HttpResponseInfo& proxy_response,
97 const SSLConfig& used_ssl_config, 97 const SSLConfig& used_ssl_config,
98 const ProxyInfo& used_proxy_info, 98 const ProxyInfo& used_proxy_info,
99 HttpAuthController* auth_controller) = 0; 99 HttpAuthController* auth_controller) = 0;
100 100
101 // Returns true if the connection initialization to the proxy server 101 // Returns true if the connection initialization to the proxy server
102 // contained in |proxy_info| can be skipped. 102 // contained in |proxy_info| can be skipped.
103 virtual bool OnInitConnection(const ProxyInfo& proxy_info) = 0; 103 virtual bool OnInitConnection(const ProxyInfo& proxy_info) = 0;
104 104
105 // Invoked when |job| has completed proxy resolution. The delegate may
106 // create an alternative proxy server job to fetch the request.
107 virtual void OnResolveProxyComplete(
108 Job* job,
109 const HttpRequestInfo& request_info,
110 RequestPriority priority,
111 const SSLConfig& server_ssl_config,
112 const SSLConfig& proxy_ssl_config,
113 HttpStreamRequest::StreamType stream_type) = 0;
114
115 // Invoked to notify the Request and Factory of the readiness of new 105 // Invoked to notify the Request and Factory of the readiness of new
116 // SPDY session. 106 // SPDY session.
117 virtual void OnNewSpdySessionReady( 107 virtual void OnNewSpdySessionReady(
118 Job* job, 108 Job* job,
119 const base::WeakPtr<SpdySession>& spdy_session, 109 const base::WeakPtr<SpdySession>& spdy_session,
120 bool direct) = 0; 110 bool direct) = 0;
121 111
122 // Invoked when the |job| finishes pre-connecting sockets. 112 // Invoked when the |job| finishes pre-connecting sockets.
123 virtual void OnPreconnectsComplete(Job* job) = 0; 113 virtual void OnPreconnectsComplete(Job* job) = 0;
124 114
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 }; 146 };
157 147
158 // Constructor for non-alternative Job. 148 // Constructor for non-alternative Job.
159 // Job is owned by |delegate|, hence |delegate| is valid for the 149 // Job is owned by |delegate|, hence |delegate| is valid for the
160 // lifetime of the Job. 150 // lifetime of the Job.
161 Job(Delegate* delegate, 151 Job(Delegate* delegate,
162 JobType job_type, 152 JobType job_type,
163 HttpNetworkSession* session, 153 HttpNetworkSession* session,
164 const HttpRequestInfo& request_info, 154 const HttpRequestInfo& request_info,
165 RequestPriority priority, 155 RequestPriority priority,
156 ProxyInfo proxy_info,
tbansal1 2017/05/09 20:38:48 pass as const ref? here and in the ctor below.
xunjieli 2017/05/10 00:26:24 Done.
166 const SSLConfig& server_ssl_config, 157 const SSLConfig& server_ssl_config,
167 const SSLConfig& proxy_ssl_config, 158 const SSLConfig& proxy_ssl_config,
168 HostPortPair destination, 159 HostPortPair destination,
169 GURL origin_url, 160 GURL origin_url,
170 bool enable_ip_based_pooling, 161 bool enable_ip_based_pooling,
171 NetLog* net_log); 162 NetLog* net_log);
172 163
173 // Constructor for the alternative Job. The Job is owned by |delegate|, hence 164 // Constructor for the alternative Job. The Job is owned by |delegate|, hence
174 // |delegate| is valid for the lifetime of the Job. If |alternative_service| 165 // |delegate| is valid for the lifetime of the Job. If |alternative_service|
175 // is initialized, then the Job will use the alternative service. On the 166 // is initialized, then the Job will use the alternative service. On the
176 // other hand, if |alternative_proxy_server| is a valid proxy server, then the 167 // other hand, if |alternative_proxy_server| is a valid proxy server, then the
177 // job will use that instead of using ProxyService for proxy resolution. 168 // job will use that instead of using ProxyService for proxy resolution.
178 // Further, if |alternative_proxy_server| is a valid but bad proxy, then 169 // Further, if |alternative_proxy_server| is a valid but bad proxy, then
179 // fallback proxies are not used. It is illegal to call this with an 170 // fallback proxies are not used. It is illegal to call this with an
180 // initialized |alternative_service|, and a valid |alternative_proxy_server|. 171 // initialized |alternative_service|, and a valid |alternative_proxy_server|.
181 Job(Delegate* delegate, 172 Job(Delegate* delegate,
182 JobType job_type, 173 JobType job_type,
183 HttpNetworkSession* session, 174 HttpNetworkSession* session,
184 const HttpRequestInfo& request_info, 175 const HttpRequestInfo& request_info,
185 RequestPriority priority, 176 RequestPriority priority,
177 ProxyInfo proxy_info,
186 const SSLConfig& server_ssl_config, 178 const SSLConfig& server_ssl_config,
187 const SSLConfig& proxy_ssl_config, 179 const SSLConfig& proxy_ssl_config,
188 HostPortPair destination, 180 HostPortPair destination,
189 GURL origin_url, 181 GURL origin_url,
190 AlternativeService alternative_service, 182 AlternativeService alternative_service,
191 const ProxyServer& alternative_proxy_server, 183 const ProxyServer& alternative_proxy_server,
192 bool enable_ip_based_pooling, 184 bool enable_ip_based_pooling,
193 NetLog* net_log); 185 NetLog* net_log);
194 virtual ~Job(); 186 virtual ~Job();
195 187
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 236 }
245 237
246 const ProxyServer alternative_proxy_server() const { 238 const ProxyServer alternative_proxy_server() const {
247 return alternative_proxy_server_; 239 return alternative_proxy_server_;
248 } 240 }
249 241
250 bool using_existing_quic_session() const { 242 bool using_existing_quic_session() const {
251 return using_existing_quic_session_; 243 return using_existing_quic_session_;
252 } 244 }
253 245
246 bool reconsider_proxy() const { return reconsider_proxy_; }
247
254 // TODO(xunjieli): Added to investigate crbug.com/711721. Remove when no 248 // TODO(xunjieli): Added to investigate crbug.com/711721. Remove when no
255 // longer needed. 249 // longer needed.
256 void LogHistograms() const; 250 void LogHistograms() const;
257 251
258 private: 252 private:
259 friend class HttpStreamFactoryImplJobPeer; 253 friend class HttpStreamFactoryImplJobPeer;
260 254
261 enum State { 255 enum State {
262 STATE_START, 256 STATE_START,
263 STATE_RESOLVE_PROXY,
264 STATE_RESOLVE_PROXY_COMPLETE,
265
266 // The main and alternative jobs are started in parallel. The main job 257 // The main and alternative jobs are started in parallel. The main job
267 // waits after it finishes proxy resolution. The alternative job never 258 // waits after it finishes proxy resolution. The alternative job never
268 // waits. 259 // waits.
269 // 260 //
270 // An HTTP/2 alternative job notifies the JobController in DoInitConnection 261 // An HTTP/2 alternative job notifies the JobController in DoInitConnection
271 // unless it can pool to an existing SpdySession. JobController, in turn, 262 // unless it can pool to an existing SpdySession. JobController, in turn,
272 // resumes the main job. 263 // resumes the main job.
273 // 264 //
274 // A QUIC alternative job notifies the JobController in DoInitConnection 265 // A QUIC alternative job notifies the JobController in DoInitConnection
275 // regardless of whether it pools to an existing QUIC session, but the main 266 // regardless of whether it pools to an existing QUIC session, but the main
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 void RunLoop(int result); 305 void RunLoop(int result);
315 int DoLoop(int result); 306 int DoLoop(int result);
316 int StartInternal(); 307 int StartInternal();
317 int DoInitConnectionImpl(); 308 int DoInitConnectionImpl();
318 309
319 // Each of these methods corresponds to a State value. Those with an input 310 // Each of these methods corresponds to a State value. Those with an input
320 // argument receive the result from the previous state. If a method returns 311 // argument receive the result from the previous state. If a method returns
321 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the 312 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the
322 // next state method as the result arg. 313 // next state method as the result arg.
323 int DoStart(); 314 int DoStart();
324 int DoResolveProxy();
325 int DoResolveProxyComplete(int result);
326 int DoWait(); 315 int DoWait();
327 int DoWaitComplete(int result); 316 int DoWaitComplete(int result);
328 int DoInitConnection(); 317 int DoInitConnection();
329 int DoInitConnectionComplete(int result); 318 int DoInitConnectionComplete(int result);
330 int DoWaitingUserAction(int result); 319 int DoWaitingUserAction(int result);
331 int DoCreateStream(); 320 int DoCreateStream();
332 int DoCreateStreamComplete(int result); 321 int DoCreateStreamComplete(int result);
333 int DoRestartTunnelAuth(); 322 int DoRestartTunnelAuth();
334 int DoRestartTunnelAuthComplete(int result); 323 int DoRestartTunnelAuthComplete(int result);
335 324
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // session is found, and OK otherwise. 387 // session is found, and OK otherwise.
399 static int OnHostResolution(SpdySessionPool* spdy_session_pool, 388 static int OnHostResolution(SpdySessionPool* spdy_session_pool,
400 const SpdySessionKey& spdy_session_key, 389 const SpdySessionKey& spdy_session_key,
401 const GURL& origin_url, 390 const GURL& origin_url,
402 bool enable_ip_based_pooling, 391 bool enable_ip_based_pooling,
403 const AddressList& addresses, 392 const AddressList& addresses,
404 const NetLogWithSource& net_log); 393 const NetLogWithSource& net_log);
405 394
406 const HttpRequestInfo request_info_; 395 const HttpRequestInfo request_info_;
407 RequestPriority priority_; 396 RequestPriority priority_;
408 ProxyInfo proxy_info_; 397 const ProxyInfo proxy_info_;
409 SSLConfig server_ssl_config_; 398 SSLConfig server_ssl_config_;
410 SSLConfig proxy_ssl_config_; 399 SSLConfig proxy_ssl_config_;
411 const NetLogWithSource net_log_; 400 const NetLogWithSource net_log_;
412 401
413 CompletionCallback io_callback_; 402 CompletionCallback io_callback_;
414 std::unique_ptr<ClientSocketHandle> connection_; 403 std::unique_ptr<ClientSocketHandle> connection_;
415 HttpNetworkSession* const session_; 404 HttpNetworkSession* const session_;
416 405
417 // |state_| is only used for LogHistograms(). 406 // |state_| is only used for LogHistograms().
418 State state_; 407 State state_;
419 408
420 State next_state_; 409 State next_state_;
421 ProxyService::PacRequest* pac_request_;
422 SSLInfo ssl_info_; 410 SSLInfo ssl_info_;
423 411
424 // The server we are trying to reach, could be that of the origin or of the 412 // The server we are trying to reach, could be that of the origin or of the
425 // alternative service (after applying host mapping rules). 413 // alternative service (after applying host mapping rules).
426 const HostPortPair destination_; 414 const HostPortPair destination_;
427 415
428 // The origin url we're trying to reach. This url may be different from the 416 // The origin url we're trying to reach. This url may be different from the
429 // original request when host mapping rules are set-up. 417 // original request when host mapping rules are set-up.
430 const GURL origin_url_; 418 const GURL origin_url_;
431 419
(...skipping 14 matching lines...) Expand all
446 const JobType job_type_; 434 const JobType job_type_;
447 435
448 // True if handling a HTTPS request. 436 // True if handling a HTTPS request.
449 const bool using_ssl_; 437 const bool using_ssl_;
450 438
451 // True if this network transaction is using SPDY instead of HTTP. 439 // True if this network transaction is using SPDY instead of HTTP.
452 bool using_spdy_; 440 bool using_spdy_;
453 441
454 // True if this network transaction is using QUIC instead of HTTP. 442 // True if this network transaction is using QUIC instead of HTTP.
455 bool using_quic_; 443 bool using_quic_;
444
445 // True if this job might succeed with a different proxy config.
446 bool reconsider_proxy_;
Ryan Hamilton 2017/05/09 19:22:06 nit: Consider "should_reconsider_proxy_"
xunjieli 2017/05/10 00:26:24 Done.
447
456 QuicStreamRequest quic_request_; 448 QuicStreamRequest quic_request_;
457 449
458 // True if this job used an existing QUIC session. 450 // True if this job used an existing QUIC session.
459 bool using_existing_quic_session_; 451 bool using_existing_quic_session_;
460 452
461 // True when the tunnel is in the process of being established - we can't 453 // True when the tunnel is in the process of being established - we can't
462 // read from the socket until the tunnel is done. 454 // read from the socket until the tunnel is done.
463 bool establishing_tunnel_; 455 bool establishing_tunnel_;
464 456
465 std::unique_ptr<HttpStream> stream_; 457 std::unique_ptr<HttpStream> stream_;
(...skipping 25 matching lines...) Expand all
491 HttpStreamRequest::StreamType stream_type_; 483 HttpStreamRequest::StreamType stream_type_;
492 484
493 base::WeakPtrFactory<Job> ptr_factory_; 485 base::WeakPtrFactory<Job> ptr_factory_;
494 486
495 DISALLOW_COPY_AND_ASSIGN(Job); 487 DISALLOW_COPY_AND_ASSIGN(Job);
496 }; 488 };
497 489
498 // Factory for creating Jobs. 490 // Factory for creating Jobs.
499 class HttpStreamFactoryImpl::JobFactory { 491 class HttpStreamFactoryImpl::JobFactory {
500 public: 492 public:
501 virtual ~JobFactory() {} 493 JobFactory();
502 494
503 // Creates an alternative service Job. 495 virtual ~JobFactory();
496
504 virtual HttpStreamFactoryImpl::Job* CreateJob( 497 virtual HttpStreamFactoryImpl::Job* CreateJob(
Ryan Hamilton 2017/05/09 19:22:06 nit: There are quite a few arguments in each of th
xunjieli 2017/05/10 00:26:24 Done.
505 HttpStreamFactoryImpl::Job::Delegate* delegate, 498 HttpStreamFactoryImpl::Job::Delegate* delegate,
506 HttpStreamFactoryImpl::JobType job_type, 499 HttpStreamFactoryImpl::JobType job_type,
507 HttpNetworkSession* session, 500 HttpNetworkSession* session,
508 const HttpRequestInfo& request_info, 501 const HttpRequestInfo& request_info,
509 RequestPriority priority, 502 RequestPriority priority,
503 ProxyInfo proxy_info,
tbansal1 2017/05/09 20:38:48 nit: pass as const ref? here and below.
xunjieli 2017/05/10 00:26:24 Done.
504 const SSLConfig& server_ssl_config,
505 const SSLConfig& proxy_ssl_config,
506 HostPortPair destination,
507 GURL origin_url,
508 bool enable_ip_based_pooling,
509 NetLog* net_log);
510
511 virtual HttpStreamFactoryImpl::Job* CreateJob(
512 HttpStreamFactoryImpl::Job::Delegate* delegate,
513 HttpStreamFactoryImpl::JobType job_type,
514 HttpNetworkSession* session,
515 const HttpRequestInfo& request_info,
516 RequestPriority priority,
517 ProxyInfo proxy_info,
510 const SSLConfig& server_ssl_config, 518 const SSLConfig& server_ssl_config,
511 const SSLConfig& proxy_ssl_config, 519 const SSLConfig& proxy_ssl_config,
512 HostPortPair destination, 520 HostPortPair destination,
513 GURL origin_url, 521 GURL origin_url,
514 AlternativeService alternative_service, 522 AlternativeService alternative_service,
515 bool enable_ip_based_pooling, 523 bool enable_ip_based_pooling,
516 NetLog* net_log) = 0; 524 NetLog* net_log);
517 525
518 // Creates an alternative proxy server Job.
519 virtual HttpStreamFactoryImpl::Job* CreateJob( 526 virtual HttpStreamFactoryImpl::Job* CreateJob(
520 HttpStreamFactoryImpl::Job::Delegate* delegate, 527 HttpStreamFactoryImpl::Job::Delegate* delegate,
521 HttpStreamFactoryImpl::JobType job_type, 528 HttpStreamFactoryImpl::JobType job_type,
522 HttpNetworkSession* session, 529 HttpNetworkSession* session,
523 const HttpRequestInfo& request_info, 530 const HttpRequestInfo& request_info,
524 RequestPriority priority, 531 RequestPriority priority,
532 ProxyInfo proxy_info,
525 const SSLConfig& server_ssl_config, 533 const SSLConfig& server_ssl_config,
526 const SSLConfig& proxy_ssl_config, 534 const SSLConfig& proxy_ssl_config,
527 HostPortPair destination, 535 HostPortPair destination,
528 GURL origin_url, 536 GURL origin_url,
529 const ProxyServer& alternative_proxy_server, 537 const ProxyServer& alternative_proxy_server,
530 bool enable_ip_based_pooling, 538 bool enable_ip_based_pooling,
531 NetLog* net_log) = 0; 539 NetLog* net_log);
532
533 // Creates a non-alternative Job.
534 virtual HttpStreamFactoryImpl::Job* CreateJob(
535 HttpStreamFactoryImpl::Job::Delegate* delegate,
536 HttpStreamFactoryImpl::JobType job_type,
537 HttpNetworkSession* session,
538 const HttpRequestInfo& request_info,
539 RequestPriority priority,
540 const SSLConfig& server_ssl_config,
541 const SSLConfig& proxy_ssl_config,
542 HostPortPair destination,
543 GURL origin_url,
544 bool enable_ip_based_pooling,
545 NetLog* net_log) = 0;
546 }; 540 };
547 541
548 } // namespace net 542 } // namespace net
549 543
550 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 544 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698