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_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" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 class HttpNetworkSession; | 34 class HttpNetworkSession; |
| 35 class HttpStream; | 35 class HttpStream; |
| 36 class SpdySessionPool; | 36 class SpdySessionPool; |
| 37 class QuicHttpStream; | 37 class QuicHttpStream; |
| 38 | 38 |
| 39 // An HttpStreamRequestImpl exists for each stream which is in progress of being | 39 // An HttpStreamRequestImpl exists for each stream which is in progress of being |
| 40 // created for the StreamFactory. | 40 // created for the StreamFactory. |
| 41 class HttpStreamFactoryImpl::Job { | 41 class HttpStreamFactoryImpl::Job { |
| 42 public: | 42 public: |
| 43 // Constructor for non-alternative Job. | 43 // Constructor for non-alternative Job. |
| 44 Job(HttpStreamFactoryImpl* stream_factory, | 44 Job(JobController* job_controller, |
|
Randy Smith (Not in Mondays)
2016/05/09 20:42:18
nit, suggestion: I have a bit of a reflex for aski
Zhongyi Shi
2016/05/12 07:26:23
Done.
| |
| 45 HttpNetworkSession* session, | 45 HttpNetworkSession* session, |
| 46 const HttpRequestInfo& request_info, | 46 const HttpRequestInfo& request_info, |
| 47 RequestPriority priority, | 47 RequestPriority priority, |
| 48 const SSLConfig& server_ssl_config, | 48 const SSLConfig& server_ssl_config, |
| 49 const SSLConfig& proxy_ssl_config, | 49 const SSLConfig& proxy_ssl_config, |
| 50 HostPortPair destination, | 50 HostPortPair destination, |
| 51 GURL origin_url, | 51 GURL origin_url, |
| 52 NetLog* net_log); | 52 NetLog* net_log); |
| 53 // Constructor for alternative Job. | 53 // Constructor for alternative Job. |
| 54 Job(HttpStreamFactoryImpl* stream_factory, | 54 Job(JobController* job_controller, |
| 55 HttpNetworkSession* session, | 55 HttpNetworkSession* session, |
| 56 const HttpRequestInfo& request_info, | 56 const HttpRequestInfo& request_info, |
| 57 RequestPriority priority, | 57 RequestPriority priority, |
| 58 const SSLConfig& server_ssl_config, | 58 const SSLConfig& server_ssl_config, |
| 59 const SSLConfig& proxy_ssl_config, | 59 const SSLConfig& proxy_ssl_config, |
| 60 HostPortPair destination, | 60 HostPortPair destination, |
| 61 GURL origin_url, | 61 GURL origin_url, |
| 62 AlternativeService alternative_service, | 62 AlternativeService alternative_service, |
| 63 NetLog* net_log); | 63 NetLog* net_log); |
| 64 ~Job(); | 64 ~Job(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 HttpStreamRequest::StreamType stream_type() const { return stream_type_; } | 96 HttpStreamRequest::StreamType stream_type() const { return stream_type_; } |
| 97 | 97 |
| 98 const SSLConfig& server_ssl_config() const; | 98 const SSLConfig& server_ssl_config() const; |
| 99 const SSLConfig& proxy_ssl_config() const; | 99 const SSLConfig& proxy_ssl_config() const; |
| 100 const ProxyInfo& proxy_info() const; | 100 const ProxyInfo& proxy_info() const; |
| 101 | 101 |
| 102 // Indicates whether or not this job is performing a preconnect. | 102 // Indicates whether or not this job is performing a preconnect. |
| 103 bool IsPreconnecting() const; | 103 bool IsPreconnecting() const; |
| 104 | 104 |
| 105 // Indicates whether or not this Job has been orphaned by a Request. | 105 // Indicates whether or not this Job has been orphaned by a Request. |
| 106 bool IsOrphaned() const; | 106 bool IsOrphaned() const { return orphaned_; }; |
| 107 | 107 |
| 108 // Called to indicate that this job succeeded, and some other jobs | 108 // Called to indicate that this job succeeded, and some other jobs |
| 109 // will be orphaned. | 109 // will be orphaned. |
| 110 void ReportJobSucceededForRequest(); | 110 void ReportJobSucceededForRequest(); |
| 111 | 111 |
| 112 // Marks that the other |job| has completed. | 112 // Marks that the other |job| has completed. |
| 113 void MarkOtherJobComplete(const Job& job); | 113 void MarkOtherJobComplete(const Job& job); |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 116 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 // Invoked by the transport socket pool after host resolution is complete | 311 // Invoked by the transport socket pool after host resolution is complete |
| 312 // to allow the connection to be aborted, if a matching SPDY session can | 312 // to allow the connection to be aborted, if a matching SPDY session can |
| 313 // be found. Will return ERR_SPDY_SESSION_ALREADY_EXISTS if such a | 313 // be found. Will return ERR_SPDY_SESSION_ALREADY_EXISTS if such a |
| 314 // session is found, and OK otherwise. | 314 // session is found, and OK otherwise. |
| 315 static int OnHostResolution(SpdySessionPool* spdy_session_pool, | 315 static int OnHostResolution(SpdySessionPool* spdy_session_pool, |
| 316 const SpdySessionKey& spdy_session_key, | 316 const SpdySessionKey& spdy_session_key, |
| 317 const GURL& origin_url, | 317 const GURL& origin_url, |
| 318 const AddressList& addresses, | 318 const AddressList& addresses, |
| 319 const BoundNetLog& net_log); | 319 const BoundNetLog& net_log); |
| 320 | 320 |
| 321 Request* request_; | |
| 322 | |
| 323 const HttpRequestInfo request_info_; | 321 const HttpRequestInfo request_info_; |
| 324 RequestPriority priority_; | 322 RequestPriority priority_; |
| 325 ProxyInfo proxy_info_; | 323 ProxyInfo proxy_info_; |
| 326 SSLConfig server_ssl_config_; | 324 SSLConfig server_ssl_config_; |
| 327 SSLConfig proxy_ssl_config_; | 325 SSLConfig proxy_ssl_config_; |
| 328 const BoundNetLog net_log_; | 326 const BoundNetLog net_log_; |
| 329 | 327 |
| 330 CompletionCallback io_callback_; | 328 CompletionCallback io_callback_; |
| 331 std::unique_ptr<ClientSocketHandle> connection_; | 329 std::unique_ptr<ClientSocketHandle> connection_; |
| 332 HttpNetworkSession* const session_; | 330 HttpNetworkSession* const session_; |
| 333 HttpStreamFactoryImpl* const stream_factory_; | |
| 334 State next_state_; | 331 State next_state_; |
| 335 ProxyService::PacRequest* pac_request_; | 332 ProxyService::PacRequest* pac_request_; |
| 336 SSLInfo ssl_info_; | 333 SSLInfo ssl_info_; |
| 337 | 334 |
| 338 // The server we are trying to reach, could be that of the origin or of the | 335 // The server we are trying to reach, could be that of the origin or of the |
| 339 // alternative service (after applying host mapping rules). | 336 // alternative service (after applying host mapping rules). |
| 340 HostPortPair destination_; | 337 HostPortPair destination_; |
| 341 | 338 |
| 342 // The origin url we're trying to reach. This url may be different from the | 339 // The origin url we're trying to reach. This url may be different from the |
| 343 // original request when host mapping rules are set-up. | 340 // original request when host mapping rules are set-up. |
| 344 GURL origin_url_; | 341 GURL origin_url_; |
| 345 | 342 |
| 346 // AlternativeService for this Job if this is an alternative Job. | 343 // AlternativeService for this Job if this is an alternative Job. |
| 347 const AlternativeService alternative_service_; | 344 const AlternativeService alternative_service_; |
| 348 | 345 |
| 349 // AlternativeService for the other Job if this is not an alternative Job. | 346 // AlternativeService for the other Job if this is not an alternative Job. |
| 350 AlternativeService other_job_alternative_service_; | 347 AlternativeService other_job_alternative_service_; |
| 351 | 348 |
| 349 JobController* job_controller_; | |
|
Ryan Hamilton
2016/05/06 20:49:01
nit: // Unowned.
Zhongyi Shi
2016/05/12 07:26:23
Done.
| |
| 350 | |
| 352 // This is the Job we're dependent on. It will notify us if/when it's OK to | 351 // This is the Job we're dependent on. It will notify us if/when it's OK to |
| 353 // proceed. | 352 // proceed. |
| 354 Job* blocking_job_; | 353 Job* blocking_job_; |
| 355 | 354 |
| 356 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. | 355 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. |
| 357 // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to | 356 // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to |
| 358 // proceed and then race the two Jobs. | 357 // proceed and then race the two Jobs. |
| 359 Job* waiting_job_; | 358 Job* waiting_job_; |
| 360 | 359 |
| 361 base::TimeDelta wait_time_; | 360 base::TimeDelta wait_time_; |
| 362 | 361 |
| 362 // True if this job has been launched by a request but orphaned. | |
| 363 bool orphaned_; | |
| 364 | |
| 363 // True if handling a HTTPS request, or using SPDY with SSL | 365 // True if handling a HTTPS request, or using SPDY with SSL |
| 364 bool using_ssl_; | 366 bool using_ssl_; |
| 365 | 367 |
| 366 // True if this network transaction is using SPDY instead of HTTP. | 368 // True if this network transaction is using SPDY instead of HTTP. |
| 367 bool using_spdy_; | 369 bool using_spdy_; |
| 368 | 370 |
| 369 // True if this network transaction is using QUIC instead of HTTP. | 371 // True if this network transaction is using QUIC instead of HTTP. |
| 370 bool using_quic_; | 372 bool using_quic_; |
| 371 QuicStreamRequest quic_request_; | 373 QuicStreamRequest quic_request_; |
| 372 | 374 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 HttpStreamRequest::StreamType stream_type_; | 421 HttpStreamRequest::StreamType stream_type_; |
| 420 | 422 |
| 421 base::WeakPtrFactory<Job> ptr_factory_; | 423 base::WeakPtrFactory<Job> ptr_factory_; |
| 422 | 424 |
| 423 DISALLOW_COPY_AND_ASSIGN(Job); | 425 DISALLOW_COPY_AND_ASSIGN(Job); |
| 424 }; | 426 }; |
| 425 | 427 |
| 426 } // namespace net | 428 } // namespace net |
| 427 | 429 |
| 428 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 430 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
| OLD | NEW |