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

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

Issue 2260623002: Race TCP connection to proxies with QUIC connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, Addressed Ryan, Cherie comments Created 4 years, 4 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 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
17 #include "net/http/bidirectional_stream_impl.h" 17 #include "net/http/bidirectional_stream_impl.h"
18 #include "net/http/http_auth.h" 18 #include "net/http/http_auth.h"
19 #include "net/http/http_auth_controller.h" 19 #include "net/http/http_auth_controller.h"
20 #include "net/http/http_request_info.h" 20 #include "net/http/http_request_info.h"
21 #include "net/http/http_stream_factory_impl.h" 21 #include "net/http/http_stream_factory_impl.h"
22 #include "net/log/net_log.h" 22 #include "net/log/net_log.h"
23 #include "net/proxy/proxy_server.h"
23 #include "net/proxy/proxy_service.h" 24 #include "net/proxy/proxy_service.h"
24 #include "net/quic/chromium/quic_stream_factory.h" 25 #include "net/quic/chromium/quic_stream_factory.h"
25 #include "net/socket/client_socket_handle.h" 26 #include "net/socket/client_socket_handle.h"
26 #include "net/socket/client_socket_pool_manager.h" 27 #include "net/socket/client_socket_pool_manager.h"
27 #include "net/socket/ssl_client_socket.h" 28 #include "net/socket/ssl_client_socket.h"
28 #include "net/spdy/spdy_session_key.h" 29 #include "net/spdy/spdy_session_key.h"
29 #include "net/ssl/ssl_config_service.h" 30 #include "net/ssl/ssl_config_service.h"
30 31
31 namespace net { 32 namespace net {
32 33
33 class ClientSocketHandle; 34 class ClientSocketHandle;
34 class HttpAuthController; 35 class HttpAuthController;
35 class HttpNetworkSession; 36 class HttpNetworkSession;
36 class HttpStream; 37 class HttpStream;
37 class SpdySessionPool; 38 class SpdySessionPool;
39 struct SSLConfig;
38 class QuicHttpStream; 40 class QuicHttpStream;
39 41
40 // An HttpStreamRequestImpl exists for each stream which is in progress of being 42 // An HttpStreamRequestImpl exists for each stream which is in progress of being
41 // created for the StreamFactory. 43 // created for the StreamFactory.
42 class HttpStreamFactoryImpl::Job { 44 class HttpStreamFactoryImpl::Job {
43 public: 45 public:
44 // Delegate to report Job's status to Request and HttpStreamFactory. 46 // Delegate to report Job's status to Request and HttpStreamFactory.
45 class NET_EXPORT_PRIVATE Delegate { 47 class NET_EXPORT_PRIVATE Delegate {
46 public: 48 public:
47 virtual ~Delegate() {} 49 virtual ~Delegate() {}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const SSLConfig& used_ssl_config, 91 const SSLConfig& used_ssl_config,
90 SSLCertRequestInfo* cert_info) = 0; 92 SSLCertRequestInfo* cert_info) = 0;
91 93
92 // Invoked when |job| needs proxy authentication. 94 // Invoked when |job| needs proxy authentication.
93 virtual void OnNeedsProxyAuth(Job* job, 95 virtual void OnNeedsProxyAuth(Job* job,
94 const HttpResponseInfo& proxy_response, 96 const HttpResponseInfo& proxy_response,
95 const SSLConfig& used_ssl_config, 97 const SSLConfig& used_ssl_config,
96 const ProxyInfo& used_proxy_info, 98 const ProxyInfo& used_proxy_info,
97 HttpAuthController* auth_controller) = 0; 99 HttpAuthController* auth_controller) = 0;
98 100
101 // Invoked when |job| has completed proxy resolution.
102 virtual void OnResolveProxyComplete(
103 Job* job,
104 const HttpRequestInfo& request_info,
105 RequestPriority priority,
106 const SSLConfig& server_ssl_config,
107 const SSLConfig& proxy_ssl_config,
108 HttpStreamRequest::StreamType stream_type) = 0;
109
99 // Invoked to notify the Request and Factory of the readiness of new 110 // Invoked to notify the Request and Factory of the readiness of new
100 // SPDY session. 111 // SPDY session.
101 virtual void OnNewSpdySessionReady( 112 virtual void OnNewSpdySessionReady(
102 Job* job, 113 Job* job,
103 const base::WeakPtr<SpdySession>& spdy_session, 114 const base::WeakPtr<SpdySession>& spdy_session,
104 bool direct) = 0; 115 bool direct) = 0;
105 116
106 // Invoked when the orphaned |job| finishes. 117 // Invoked when the orphaned |job| finishes.
107 virtual void OnOrphanedJobComplete(const Job* job) = 0; 118 virtual void OnOrphanedJobComplete(const Job* job) = 0;
108 119
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 JobType job_type, 160 JobType job_type,
150 HttpNetworkSession* session, 161 HttpNetworkSession* session,
151 const HttpRequestInfo& request_info, 162 const HttpRequestInfo& request_info,
152 RequestPriority priority, 163 RequestPriority priority,
153 const SSLConfig& server_ssl_config, 164 const SSLConfig& server_ssl_config,
154 const SSLConfig& proxy_ssl_config, 165 const SSLConfig& proxy_ssl_config,
155 HostPortPair destination, 166 HostPortPair destination,
156 GURL origin_url, 167 GURL origin_url,
157 NetLog* net_log); 168 NetLog* net_log);
158 169
159 // Constructor for alternative Job. 170 // Constructor for alternative Job. The Job is owned by |delegate|, hence
Zhongyi Shi 2016/08/20 06:15:40 Reading the comments. I think it might be better t
tbansal1 2016/08/22 15:42:33 I thought about it, and I had initially written co
Zhongyi Shi 2016/08/23 05:42:33 The old code is not well written. You could possib
tbansal1 2016/08/23 20:56:40 Done.
160 // Job is owned by |delegate|, hence |delegate| is valid for the 171 // |delegate| is valid for the lifetime of the Job. If |alternative_service|
161 // lifetime of the Job. 172 // is initialized, then the Job will use the alternative service. On the
173 // other hand, if |alternative_proxy_server| is a valid proxy server, then the
174 // job will use that instead of using ProxyService for proxy resolution.
175 // Further, if |alternative_proxy_server| is valid but bad proxy, then
176 // fallback proxies are not used. It is illegal to call this with an
177 // initialized |alternative_service|, and a valid |alternative_proxy_server|.
162 Job(Delegate* delegate, 178 Job(Delegate* delegate,
163 JobType job_type, 179 JobType job_type,
164 HttpNetworkSession* session, 180 HttpNetworkSession* session,
165 const HttpRequestInfo& request_info, 181 const HttpRequestInfo& request_info,
166 RequestPriority priority, 182 RequestPriority priority,
167 const SSLConfig& server_ssl_config, 183 const SSLConfig& server_ssl_config,
168 const SSLConfig& proxy_ssl_config, 184 const SSLConfig& proxy_ssl_config,
169 HostPortPair destination, 185 HostPortPair destination,
170 GURL origin_url, 186 GURL origin_url,
171 AlternativeService alternative_service, 187 AlternativeService alternative_service,
188 const ProxyServer& alternative_proxy_server,
172 NetLog* net_log); 189 NetLog* net_log);
173 virtual ~Job(); 190 virtual ~Job();
174 191
175 // Start initiates the process of creating a new HttpStream. 192 // Start initiates the process of creating a new HttpStream.
176 // |delegate_| will be notified upon completion. 193 // |delegate_| will be notified upon completion.
177 void Start(HttpStreamRequest::StreamType stream_type); 194 void Start(HttpStreamRequest::StreamType stream_type);
178 195
179 // Preconnect will attempt to request |num_streams| sockets from the 196 // Preconnect will attempt to request |num_streams| sockets from the
180 // appropriate ClientSocketPool. 197 // appropriate ClientSocketPool.
181 int Preconnect(int num_streams); 198 int Preconnect(int num_streams);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 int HandleCertificateRequest(int error); 374 int HandleCertificateRequest(int error);
358 375
359 // Moves this stream request into SPDY mode. 376 // Moves this stream request into SPDY mode.
360 void SwitchToSpdyMode(); 377 void SwitchToSpdyMode();
361 378
362 // Should we force QUIC for this stream request. 379 // Should we force QUIC for this stream request.
363 bool ShouldForceQuic() const; 380 bool ShouldForceQuic() const;
364 381
365 void MaybeMarkAlternativeServiceBroken(); 382 void MaybeMarkAlternativeServiceBroken();
366 383
384 // May notify proxy delegate that the alternative proxy server is broken. The
385 // alternative proxy server is considered as broken if the alternative proxy
386 // server job failed, but the main job was successful.
387 void MaybeNotifyAlternativeProxyServerBroken() const;
388
367 ClientSocketPoolManager::SocketGroupType GetSocketGroup() const; 389 ClientSocketPoolManager::SocketGroupType GetSocketGroup() const;
368 390
369 void MaybeCopyConnectionAttemptsFromSocketOrHandle(); 391 void MaybeCopyConnectionAttemptsFromSocketOrHandle();
370 392
371 // Record histograms of latency until Connect() completes. 393 // Record histograms of latency until Connect() completes.
372 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); 394 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle);
373 395
374 // Invoked by the transport socket pool after host resolution is complete 396 // Invoked by the transport socket pool after host resolution is complete
375 // to allow the connection to be aborted, if a matching SPDY session can 397 // to allow the connection to be aborted, if a matching SPDY session can
376 // be found. Will return ERR_SPDY_SESSION_ALREADY_EXISTS if such a 398 // be found. Will return ERR_SPDY_SESSION_ALREADY_EXISTS if such a
(...skipping 28 matching lines...) Expand all
405 427
406 // AlternativeService for this Job if this is an alternative Job. 428 // AlternativeService for this Job if this is an alternative Job.
407 const AlternativeService alternative_service_; 429 const AlternativeService alternative_service_;
408 430
409 // AlternativeService for the other Job if this is not an alternative Job. 431 // AlternativeService for the other Job if this is not an alternative Job.
410 AlternativeService other_job_alternative_service_; 432 AlternativeService other_job_alternative_service_;
411 433
412 // Unowned. |this| job is owned by |delegate_|. 434 // Unowned. |this| job is owned by |delegate_|.
413 Delegate* delegate_; 435 Delegate* delegate_;
414 436
437 // Alternative proxy server that should be used by |this| to fetch the
438 // request.
439 const ProxyServer alternative_proxy_server_;
440
441 // Alternative proxy server for the other job.
442 ProxyServer other_job_alternative_proxy_server_;
443
415 JobType job_type_; 444 JobType job_type_;
416 445
417 // True if handling a HTTPS request, or using SPDY with SSL 446 // True if handling a HTTPS request, or using SPDY with SSL
418 bool using_ssl_; 447 bool using_ssl_;
419 448
420 // True if this network transaction is using SPDY instead of HTTP. 449 // True if this network transaction is using SPDY instead of HTTP.
421 bool using_spdy_; 450 bool using_spdy_;
422 451
423 // True if this network transaction is using QUIC instead of HTTP. 452 // True if this network transaction is using QUIC instead of HTTP.
424 bool using_quic_; 453 bool using_quic_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 HttpStreamFactoryImpl::Job::Delegate* delegate, 513 HttpStreamFactoryImpl::Job::Delegate* delegate,
485 HttpStreamFactoryImpl::JobType job_type, 514 HttpStreamFactoryImpl::JobType job_type,
486 HttpNetworkSession* session, 515 HttpNetworkSession* session,
487 const HttpRequestInfo& request_info, 516 const HttpRequestInfo& request_info,
488 RequestPriority priority, 517 RequestPriority priority,
489 const SSLConfig& server_ssl_config, 518 const SSLConfig& server_ssl_config,
490 const SSLConfig& proxy_ssl_config, 519 const SSLConfig& proxy_ssl_config,
491 HostPortPair destination, 520 HostPortPair destination,
492 GURL origin_url, 521 GURL origin_url,
493 AlternativeService alternative_service, 522 AlternativeService alternative_service,
523 const ProxyServer& alternative_proxy_server,
494 NetLog* net_log) = 0; 524 NetLog* net_log) = 0;
495 525
496 // Creates a non-alternative Job. 526 // Creates a non-alternative Job.
497 virtual HttpStreamFactoryImpl::Job* CreateJob( 527 virtual HttpStreamFactoryImpl::Job* CreateJob(
498 HttpStreamFactoryImpl::Job::Delegate* delegate, 528 HttpStreamFactoryImpl::Job::Delegate* delegate,
499 HttpStreamFactoryImpl::JobType job_type, 529 HttpStreamFactoryImpl::JobType job_type,
500 HttpNetworkSession* session, 530 HttpNetworkSession* session,
501 const HttpRequestInfo& request_info, 531 const HttpRequestInfo& request_info,
502 RequestPriority priority, 532 RequestPriority priority,
503 const SSLConfig& server_ssl_config, 533 const SSLConfig& server_ssl_config,
504 const SSLConfig& proxy_ssl_config, 534 const SSLConfig& proxy_ssl_config,
505 HostPortPair destination, 535 HostPortPair destination,
506 GURL origin_url, 536 GURL origin_url,
507 NetLog* net_log) = 0; 537 NetLog* net_log) = 0;
508 }; 538 };
509 539
510 } // namespace net 540 } // namespace net
511 541
512 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 542 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698