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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 | 228 |
229 bool is_waiting() const { return next_state_ == STATE_WAIT_COMPLETE; } | 229 bool is_waiting() const { return next_state_ == STATE_WAIT_COMPLETE; } |
230 const SSLConfig& server_ssl_config() const; | 230 const SSLConfig& server_ssl_config() const; |
231 const SSLConfig& proxy_ssl_config() const; | 231 const SSLConfig& proxy_ssl_config() const; |
232 const ProxyInfo& proxy_info() const; | 232 const ProxyInfo& proxy_info() const; |
233 | 233 |
234 // Called to indicate that this job succeeded, and some other jobs | 234 // Called to indicate that this job succeeded, and some other jobs |
235 // will be orphaned. | 235 // will be orphaned. |
236 void ReportJobSucceededForRequest(); | 236 void ReportJobSucceededForRequest(); |
237 | 237 |
238 // Marks that the other |job| has completed. | 238 JobType job_type() const { return job_type_; } |
239 virtual void MarkOtherJobComplete(const Job& job); | |
240 | 239 |
241 JobType job_type() const { return job_type_; } | 240 bool alternative_broken() const { return alternative_broken_; } |
241 | |
242 const AlternativeService alternative_service() const { | |
243 return alternative_service_; | |
244 } | |
245 const ProxyServer alternative_proxy_server() const { | |
246 return alternative_proxy_server_; | |
247 } | |
242 | 248 |
243 private: | 249 private: |
244 friend class HttpStreamFactoryImplJobPeer; | 250 friend class HttpStreamFactoryImplJobPeer; |
245 | 251 |
246 enum State { | 252 enum State { |
247 STATE_START, | 253 STATE_START, |
248 STATE_RESOLVE_PROXY, | 254 STATE_RESOLVE_PROXY, |
249 STATE_RESOLVE_PROXY_COMPLETE, | 255 STATE_RESOLVE_PROXY_COMPLETE, |
250 | 256 |
251 // Note that when Alternate-Protocol says we can connect to an alternate | 257 // Note that when Alternate-Protocol says we can connect to an alternate |
(...skipping 22 matching lines...) Expand all Loading... | |
274 STATE_RESTART_TUNNEL_AUTH, | 280 STATE_RESTART_TUNNEL_AUTH, |
275 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 281 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
276 STATE_CREATE_STREAM, | 282 STATE_CREATE_STREAM, |
277 STATE_CREATE_STREAM_COMPLETE, | 283 STATE_CREATE_STREAM_COMPLETE, |
278 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | 284 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
279 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | 285 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
280 STATE_DONE, | 286 STATE_DONE, |
281 STATE_NONE | 287 STATE_NONE |
282 }; | 288 }; |
283 | 289 |
284 enum JobStatus { | |
285 STATUS_RUNNING, | |
286 STATUS_FAILED, | |
287 STATUS_BROKEN, | |
288 STATUS_SUCCEEDED | |
289 }; | |
290 | |
291 void OnStreamReadyCallback(); | 290 void OnStreamReadyCallback(); |
292 void OnBidirectionalStreamImplReadyCallback(); | 291 void OnBidirectionalStreamImplReadyCallback(); |
293 void OnWebSocketHandshakeStreamReadyCallback(); | 292 void OnWebSocketHandshakeStreamReadyCallback(); |
294 // This callback function is called when a new SPDY session is created. | 293 // This callback function is called when a new SPDY session is created. |
295 void OnNewSpdySessionReadyCallback(); | 294 void OnNewSpdySessionReadyCallback(); |
296 void OnStreamFailedCallback(int result); | 295 void OnStreamFailedCallback(int result); |
297 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); | 296 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); |
298 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, | 297 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, |
299 HttpAuthController* auth_controller); | 298 HttpAuthController* auth_controller); |
300 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); | 299 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 | 372 |
374 // Called to handle a client certificate request. | 373 // Called to handle a client certificate request. |
375 int HandleCertificateRequest(int error); | 374 int HandleCertificateRequest(int error); |
376 | 375 |
377 // Moves this stream request into SPDY mode. | 376 // Moves this stream request into SPDY mode. |
378 void SwitchToSpdyMode(); | 377 void SwitchToSpdyMode(); |
379 | 378 |
380 // Should we force QUIC for this stream request. | 379 // Should we force QUIC for this stream request. |
381 bool ShouldForceQuic() const; | 380 bool ShouldForceQuic() const; |
382 | 381 |
383 void MaybeMarkAlternativeServiceBroken(); | |
384 | |
385 // May notify proxy delegate that the alternative proxy server is broken. The | |
386 // alternative proxy server is considered as broken if the alternative proxy | |
387 // server job failed, but the main job was successful. | |
388 void MaybeNotifyAlternativeProxyServerBroken() const; | |
389 | |
390 ClientSocketPoolManager::SocketGroupType GetSocketGroup() const; | 382 ClientSocketPoolManager::SocketGroupType GetSocketGroup() const; |
391 | 383 |
392 void MaybeCopyConnectionAttemptsFromSocketOrHandle(); | 384 void MaybeCopyConnectionAttemptsFromSocketOrHandle(); |
393 | 385 |
394 // Record histograms of latency until Connect() completes. | 386 // Record histograms of latency until Connect() completes. |
395 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); | 387 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); |
396 | 388 |
397 // Invoked by the transport socket pool after host resolution is complete | 389 // Invoked by the transport socket pool after host resolution is complete |
398 // to allow the connection to be aborted, if a matching SPDY session can | 390 // to allow the connection to be aborted, if a matching SPDY session can |
399 // be found. Will return ERR_SPDY_SESSION_ALREADY_EXISTS if such a | 391 // be found. Will return ERR_SPDY_SESSION_ALREADY_EXISTS if such a |
(...skipping 19 matching lines...) Expand all Loading... | |
419 SSLInfo ssl_info_; | 411 SSLInfo ssl_info_; |
420 | 412 |
421 // The server we are trying to reach, could be that of the origin or of the | 413 // The server we are trying to reach, could be that of the origin or of the |
422 // alternative service (after applying host mapping rules). | 414 // alternative service (after applying host mapping rules). |
423 const HostPortPair destination_; | 415 const HostPortPair destination_; |
424 | 416 |
425 // The origin url we're trying to reach. This url may be different from the | 417 // The origin url we're trying to reach. This url may be different from the |
426 // original request when host mapping rules are set-up. | 418 // original request when host mapping rules are set-up. |
427 const GURL origin_url_; | 419 const GURL origin_url_; |
428 | 420 |
421 // True if alternative service or alternative proxy server needs to be marked | |
422 // as broken. | |
423 bool alternative_broken_; | |
Ryan Hamilton
2016/09/13 23:23:15
Is this different than the job failing?
| |
424 | |
429 // AlternativeService for this Job if this is an alternative Job. | 425 // AlternativeService for this Job if this is an alternative Job. |
430 const AlternativeService alternative_service_; | 426 const AlternativeService alternative_service_; |
431 | 427 |
432 // AlternativeService for the other Job if this is not an alternative Job. | |
433 AlternativeService other_job_alternative_service_; | |
434 | |
435 // Unowned. |this| job is owned by |delegate_|. | 428 // Unowned. |this| job is owned by |delegate_|. |
436 Delegate* delegate_; | 429 Delegate* delegate_; |
437 | 430 |
438 // Alternative proxy server that should be used by |this| to fetch the | 431 // Alternative proxy server that should be used by |this| to fetch the |
439 // request. | 432 // request. |
440 const ProxyServer alternative_proxy_server_; | 433 const ProxyServer alternative_proxy_server_; |
441 | 434 |
442 // Alternative proxy server for the other job. | |
443 ProxyServer other_job_alternative_proxy_server_; | |
444 | |
445 const JobType job_type_; | 435 const JobType job_type_; |
446 | 436 |
447 // True if handling a HTTPS request, or using SPDY with SSL | 437 // True if handling a HTTPS request, or using SPDY with SSL |
448 bool using_ssl_; | 438 bool using_ssl_; |
449 | 439 |
450 // True if this network transaction is using SPDY instead of HTTP. | 440 // True if this network transaction is using SPDY instead of HTTP. |
451 bool using_spdy_; | 441 bool using_spdy_; |
452 | 442 |
453 // True if this network transaction is using QUIC instead of HTTP. | 443 // True if this network transaction is using QUIC instead of HTTP. |
454 bool using_quic_; | 444 bool using_quic_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 | 476 |
487 // Initialized when we create a new SpdySession. | 477 // Initialized when we create a new SpdySession. |
488 base::WeakPtr<SpdySession> new_spdy_session_; | 478 base::WeakPtr<SpdySession> new_spdy_session_; |
489 | 479 |
490 // Initialized when we have an existing SpdySession. | 480 // Initialized when we have an existing SpdySession. |
491 base::WeakPtr<SpdySession> existing_spdy_session_; | 481 base::WeakPtr<SpdySession> existing_spdy_session_; |
492 | 482 |
493 // Only used if |new_spdy_session_| is non-NULL. | 483 // Only used if |new_spdy_session_| is non-NULL. |
494 bool spdy_session_direct_; | 484 bool spdy_session_direct_; |
495 | 485 |
496 JobStatus job_status_; | |
497 JobStatus other_job_status_; | |
498 | |
499 // Type of stream that is requested. | 486 // Type of stream that is requested. |
500 HttpStreamRequest::StreamType stream_type_; | 487 HttpStreamRequest::StreamType stream_type_; |
501 | 488 |
502 base::WeakPtrFactory<Job> ptr_factory_; | 489 base::WeakPtrFactory<Job> ptr_factory_; |
503 | 490 |
504 DISALLOW_COPY_AND_ASSIGN(Job); | 491 DISALLOW_COPY_AND_ASSIGN(Job); |
505 }; | 492 }; |
506 | 493 |
507 // Factory for creating Jobs. | 494 // Factory for creating Jobs. |
508 class HttpStreamFactoryImpl::JobFactory { | 495 class HttpStreamFactoryImpl::JobFactory { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 const SSLConfig& server_ssl_config, | 534 const SSLConfig& server_ssl_config, |
548 const SSLConfig& proxy_ssl_config, | 535 const SSLConfig& proxy_ssl_config, |
549 HostPortPair destination, | 536 HostPortPair destination, |
550 GURL origin_url, | 537 GURL origin_url, |
551 NetLog* net_log) = 0; | 538 NetLog* net_log) = 0; |
552 }; | 539 }; |
553 | 540 |
554 } // namespace net | 541 } // namespace net |
555 | 542 |
556 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 543 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
OLD | NEW |