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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 STATE_NONE | 133 STATE_NONE |
134 }; | 134 }; |
135 | 135 |
136 enum JobStatus { | 136 enum JobStatus { |
137 STATUS_RUNNING, | 137 STATUS_RUNNING, |
138 STATUS_FAILED, | 138 STATUS_FAILED, |
139 STATUS_BROKEN, | 139 STATUS_BROKEN, |
140 STATUS_SUCCEEDED | 140 STATUS_SUCCEEDED |
141 }; | 141 }; |
142 | 142 |
| 143 // Wrapper class for SpdySessionPool methods to enforce certificate |
| 144 // requirements for SpdySessions. |
| 145 class ValidSpdySessionPool { |
| 146 public: |
| 147 ValidSpdySessionPool(SpdySessionPool* spdy_session_pool, |
| 148 GURL& origin_url, |
| 149 bool is_spdy_alternate); |
| 150 |
| 151 // Returns OK if a SpdySession was not found (in which case |spdy_session| |
| 152 // is set to nullptr), or if one was found (in which case |spdy_session| is |
| 153 // set to it) and it has an associated SSL certificate with is valid for |
| 154 // |origin_url_|, or if this requirement does not apply because the Job is |
| 155 // not a SPDY alternate job. Returns the appropriate error code otherwise, |
| 156 // in which case |spdy_session| should not be used. |
| 157 int FindAvailableSession(const SpdySessionKey& key, |
| 158 const BoundNetLog& net_log, |
| 159 base::WeakPtr<SpdySession>* spdy_session); |
| 160 |
| 161 // Creates a SpdySession and sets |spdy_session| to point to it. Returns OK |
| 162 // if the associated SSL certificate is valid for |origin_url_|, or if this |
| 163 // requirement does not apply because the Job is not a SPDY alternate job. |
| 164 // Returns the appropriate error code otherwise, in which case |
| 165 // |spdy_session| should not be used. |
| 166 int CreateAvailableSessionFromSocket( |
| 167 const SpdySessionKey& key, |
| 168 scoped_ptr<ClientSocketHandle> connection, |
| 169 const BoundNetLog& net_log, |
| 170 int certificate_error_code, |
| 171 bool is_secure, |
| 172 base::WeakPtr<SpdySession>* spdy_session); |
| 173 |
| 174 private: |
| 175 // Returns OK if |spdy_session| has an associated SSL certificate with is |
| 176 // valid for |origin_url_|, or if this requirement does not apply because |
| 177 // the Job is not a SPDY alternate job, or if |spdy_session| is null. |
| 178 // Returns appropriate error code otherwise. |
| 179 int CheckAlternativeServiceValidityForOrigin( |
| 180 base::WeakPtr<SpdySession> spdy_session); |
| 181 |
| 182 SpdySessionPool* const spdy_session_pool_; |
| 183 const GURL origin_url_; |
| 184 const bool is_spdy_alternate_; |
| 185 }; |
| 186 |
143 void OnStreamReadyCallback(); | 187 void OnStreamReadyCallback(); |
144 void OnWebSocketHandshakeStreamReadyCallback(); | 188 void OnWebSocketHandshakeStreamReadyCallback(); |
145 // This callback function is called when a new SPDY session is created. | 189 // This callback function is called when a new SPDY session is created. |
146 void OnNewSpdySessionReadyCallback(); | 190 void OnNewSpdySessionReadyCallback(); |
147 void OnStreamFailedCallback(int result); | 191 void OnStreamFailedCallback(int result); |
148 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); | 192 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); |
149 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, | 193 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, |
150 HttpAuthController* auth_controller); | 194 HttpAuthController* auth_controller); |
151 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); | 195 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); |
152 void OnHttpsProxyTunnelResponseCallback(const HttpResponseInfo& response_info, | 196 void OnHttpsProxyTunnelResponseCallback(const HttpResponseInfo& response_info, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // True if we negotiated NPN. | 364 // True if we negotiated NPN. |
321 bool was_npn_negotiated_; | 365 bool was_npn_negotiated_; |
322 | 366 |
323 // Protocol negotiated with the server. | 367 // Protocol negotiated with the server. |
324 NextProto protocol_negotiated_; | 368 NextProto protocol_negotiated_; |
325 | 369 |
326 // 0 if we're not preconnecting. Otherwise, the number of streams to | 370 // 0 if we're not preconnecting. Otherwise, the number of streams to |
327 // preconnect. | 371 // preconnect. |
328 int num_streams_; | 372 int num_streams_; |
329 | 373 |
| 374 scoped_ptr<ValidSpdySessionPool> valid_spdy_session_pool_; |
| 375 |
330 // Initialized when we create a new SpdySession. | 376 // Initialized when we create a new SpdySession. |
331 base::WeakPtr<SpdySession> new_spdy_session_; | 377 base::WeakPtr<SpdySession> new_spdy_session_; |
332 | 378 |
333 // Initialized when we have an existing SpdySession. | 379 // Initialized when we have an existing SpdySession. |
334 base::WeakPtr<SpdySession> existing_spdy_session_; | 380 base::WeakPtr<SpdySession> existing_spdy_session_; |
335 | 381 |
336 // Only used if |new_spdy_session_| is non-NULL. | 382 // Only used if |new_spdy_session_| is non-NULL. |
337 bool spdy_session_direct_; | 383 bool spdy_session_direct_; |
338 | 384 |
339 JobStatus job_status_; | 385 JobStatus job_status_; |
340 JobStatus other_job_status_; | 386 JobStatus other_job_status_; |
341 | 387 |
342 base::WeakPtrFactory<Job> ptr_factory_; | 388 base::WeakPtrFactory<Job> ptr_factory_; |
343 | 389 |
344 DISALLOW_COPY_AND_ASSIGN(Job); | 390 DISALLOW_COPY_AND_ASSIGN(Job); |
345 }; | 391 }; |
346 | 392 |
347 } // namespace net | 393 } // namespace net |
348 | 394 |
349 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 395 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
OLD | NEW |