| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 STATE_NONE | 258 STATE_NONE |
| 259 }; | 259 }; |
| 260 | 260 |
| 261 enum JobStatus { | 261 enum JobStatus { |
| 262 STATUS_RUNNING, | 262 STATUS_RUNNING, |
| 263 STATUS_FAILED, | 263 STATUS_FAILED, |
| 264 STATUS_BROKEN, | 264 STATUS_BROKEN, |
| 265 STATUS_SUCCEEDED | 265 STATUS_SUCCEEDED |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 // Wrapper class for SpdySessionPool methods to enforce certificate | |
| 269 // requirements for SpdySessions. | |
| 270 class ValidSpdySessionPool { | |
| 271 public: | |
| 272 ValidSpdySessionPool(SpdySessionPool* spdy_session_pool, | |
| 273 GURL& origin_url, | |
| 274 bool is_spdy_alternative); | |
| 275 | |
| 276 // Returns OK if a SpdySession was not found (in which case |spdy_session| | |
| 277 // is set to nullptr), or if one was found (in which case |spdy_session| is | |
| 278 // set to it) and it has an associated SSL certificate with is valid for | |
| 279 // |origin_url_|, or if this requirement does not apply because the Job is | |
| 280 // not a SPDY alternative job. Returns the appropriate error code | |
| 281 // otherwise, | |
| 282 // in which case |spdy_session| should not be used. | |
| 283 int FindAvailableSession(const SpdySessionKey& key, | |
| 284 const BoundNetLog& net_log, | |
| 285 base::WeakPtr<SpdySession>* spdy_session); | |
| 286 | |
| 287 // Creates a SpdySession and sets |spdy_session| to point to it. Returns OK | |
| 288 // if the associated SSL certificate is valid for |origin_url_|, or if this | |
| 289 // requirement does not apply because the Job is not a SPDY alternative job. | |
| 290 // Returns the appropriate error code otherwise, in which case | |
| 291 // |spdy_session| should not be used. | |
| 292 int CreateAvailableSessionFromSocket( | |
| 293 const SpdySessionKey& key, | |
| 294 std::unique_ptr<ClientSocketHandle> connection, | |
| 295 const BoundNetLog& net_log, | |
| 296 int certificate_error_code, | |
| 297 bool is_secure, | |
| 298 base::WeakPtr<SpdySession>* spdy_session); | |
| 299 | |
| 300 private: | |
| 301 // Returns OK if |spdy_session| has an associated SSL certificate with is | |
| 302 // valid for |origin_url_|, or if this requirement does not apply because | |
| 303 // the Job is not a SPDY alternative job, or if |spdy_session| is null. | |
| 304 // Returns appropriate error code otherwise. | |
| 305 int CheckAlternativeServiceValidityForOrigin( | |
| 306 base::WeakPtr<SpdySession> spdy_session); | |
| 307 | |
| 308 SpdySessionPool* const spdy_session_pool_; | |
| 309 const GURL origin_url_; | |
| 310 const bool is_spdy_alternative_; | |
| 311 }; | |
| 312 | |
| 313 // Resume the |this| job after the specified |wait_time_|. | 268 // Resume the |this| job after the specified |wait_time_|. |
| 314 void ResumeAfterDelay(); | 269 void ResumeAfterDelay(); |
| 315 | 270 |
| 316 void OnStreamReadyCallback(); | 271 void OnStreamReadyCallback(); |
| 317 void OnBidirectionalStreamImplReadyCallback(); | 272 void OnBidirectionalStreamImplReadyCallback(); |
| 318 void OnWebSocketHandshakeStreamReadyCallback(); | 273 void OnWebSocketHandshakeStreamReadyCallback(); |
| 319 // This callback function is called when a new SPDY session is created. | 274 // This callback function is called when a new SPDY session is created. |
| 320 void OnNewSpdySessionReadyCallback(); | 275 void OnNewSpdySessionReadyCallback(); |
| 321 void OnStreamFailedCallback(int result); | 276 void OnStreamFailedCallback(int result); |
| 322 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); | 277 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 // True if we negotiated NPN. | 455 // True if we negotiated NPN. |
| 501 bool was_npn_negotiated_; | 456 bool was_npn_negotiated_; |
| 502 | 457 |
| 503 // Protocol negotiated with the server. | 458 // Protocol negotiated with the server. |
| 504 NextProto protocol_negotiated_; | 459 NextProto protocol_negotiated_; |
| 505 | 460 |
| 506 // 0 if we're not preconnecting. Otherwise, the number of streams to | 461 // 0 if we're not preconnecting. Otherwise, the number of streams to |
| 507 // preconnect. | 462 // preconnect. |
| 508 int num_streams_; | 463 int num_streams_; |
| 509 | 464 |
| 510 std::unique_ptr<ValidSpdySessionPool> valid_spdy_session_pool_; | |
| 511 | |
| 512 // Initialized when we create a new SpdySession. | 465 // Initialized when we create a new SpdySession. |
| 513 base::WeakPtr<SpdySession> new_spdy_session_; | 466 base::WeakPtr<SpdySession> new_spdy_session_; |
| 514 | 467 |
| 515 // Initialized when we have an existing SpdySession. | 468 // Initialized when we have an existing SpdySession. |
| 516 base::WeakPtr<SpdySession> existing_spdy_session_; | 469 base::WeakPtr<SpdySession> existing_spdy_session_; |
| 517 | 470 |
| 518 // Only used if |new_spdy_session_| is non-NULL. | 471 // Only used if |new_spdy_session_| is non-NULL. |
| 519 bool spdy_session_direct_; | 472 bool spdy_session_direct_; |
| 520 | 473 |
| 521 JobStatus job_status_; | 474 JobStatus job_status_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 const SSLConfig& server_ssl_config, | 512 const SSLConfig& server_ssl_config, |
| 560 const SSLConfig& proxy_ssl_config, | 513 const SSLConfig& proxy_ssl_config, |
| 561 HostPortPair destination, | 514 HostPortPair destination, |
| 562 GURL origin_url, | 515 GURL origin_url, |
| 563 NetLog* net_log) = 0; | 516 NetLog* net_log) = 0; |
| 564 }; | 517 }; |
| 565 | 518 |
| 566 } // namespace net | 519 } // namespace net |
| 567 | 520 |
| 568 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 521 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
| OLD | NEW |