| 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_REQUEST_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ |
| 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "net/base/net_log.h" | 11 #include "net/base/net_log.h" |
| 12 #include "net/http/http_stream_factory_impl.h" | 12 #include "net/http/http_stream_factory_impl.h" |
| 13 #include "net/http/websocket_stream_base.h" |
| 13 #include "net/socket/ssl_client_socket.h" | 14 #include "net/socket/ssl_client_socket.h" |
| 14 #include "net/spdy/spdy_session_key.h" | 15 #include "net/spdy/spdy_session_key.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 19 class ClientSocketHandle; |
| 20 class SpdySession; |
| 21 |
| 18 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { | 22 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { |
| 19 public: | 23 public: |
| 20 Request(const GURL& url, | 24 Request(const GURL& url, |
| 21 HttpStreamFactoryImpl* factory, | 25 HttpStreamFactoryImpl* factory, |
| 22 HttpStreamRequest::Delegate* delegate, | 26 HttpStreamRequest::Delegate* delegate, |
| 27 WebSocketStreamBase::Factory* websocket_stream_factory, |
| 23 const BoundNetLog& net_log); | 28 const BoundNetLog& net_log); |
| 24 virtual ~Request(); | 29 virtual ~Request(); |
| 25 | 30 |
| 26 // The GURL from the HttpRequestInfo the started the Request. | 31 // The GURL from the HttpRequestInfo the started the Request. |
| 27 const GURL& url() const { return url_; } | 32 const GURL& url() const { return url_; } |
| 28 | 33 |
| 29 // Called when the Job determines the appropriate |spdy_session_key| for the | 34 // Called when the Job determines the appropriate |spdy_session_key| for the |
| 30 // Request. Note that this does not mean that SPDY is necessarily supported | 35 // Request. Note that this does not mean that SPDY is necessarily supported |
| 31 // for this SpdySessionKey, since we may need to wait for NPN to complete | 36 // for this SpdySessionKey, since we may need to wait for NPN to complete |
| 32 // before knowing if SPDY is available. | 37 // before knowing if SPDY is available. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 | 56 |
| 52 // If this Request has a |spdy_session_key_|, remove this session from the | 57 // If this Request has a |spdy_session_key_|, remove this session from the |
| 53 // SpdySessionRequestMap. | 58 // SpdySessionRequestMap. |
| 54 void RemoveRequestFromSpdySessionRequestMap(); | 59 void RemoveRequestFromSpdySessionRequestMap(); |
| 55 | 60 |
| 56 // If this Request has a |http_pipelining_key_|, remove this session from the | 61 // If this Request has a |http_pipelining_key_|, remove this session from the |
| 57 // HttpPipeliningRequestMap. | 62 // HttpPipeliningRequestMap. |
| 58 void RemoveRequestFromHttpPipeliningRequestMap(); | 63 void RemoveRequestFromHttpPipeliningRequestMap(); |
| 59 | 64 |
| 60 // Called by an attached Job if it sets up a SpdySession. | 65 // Called by an attached Job if it sets up a SpdySession. |
| 61 void OnSpdySessionReady(Job* job, | 66 void OnNewSpdySessionReady(Job* job, |
| 62 scoped_refptr<SpdySession> spdy_session, | 67 scoped_refptr<SpdySession> spdy_session, |
| 63 bool direct); | 68 bool direct); |
| 69 |
| 70 WebSocketStreamBase::Factory* websocket_stream_factory() { |
| 71 return websocket_stream_factory_; |
| 72 } |
| 64 | 73 |
| 65 // HttpStreamRequest::Delegate methods which we implement. Note we don't | 74 // HttpStreamRequest::Delegate methods which we implement. Note we don't |
| 66 // actually subclass HttpStreamRequest::Delegate. | 75 // actually subclass HttpStreamRequest::Delegate. |
| 67 | 76 |
| 68 void OnStreamReady(Job* job, | 77 void OnStreamReady(Job* job, |
| 69 const SSLConfig& used_ssl_config, | 78 const SSLConfig& used_ssl_config, |
| 70 const ProxyInfo& used_proxy_info, | 79 const ProxyInfo& used_proxy_info, |
| 71 HttpStreamBase* stream); | 80 HttpStreamBase* stream); |
| 81 void OnWebSocketStreamReady(Job* job, |
| 82 const SSLConfig& used_ssl_config, |
| 83 const ProxyInfo& used_proxy_info, |
| 84 WebSocketStreamBase* stream); |
| 72 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config); | 85 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config); |
| 73 void OnCertificateError(Job* job, | 86 void OnCertificateError(Job* job, |
| 74 int status, | 87 int status, |
| 75 const SSLConfig& used_ssl_config, | 88 const SSLConfig& used_ssl_config, |
| 76 const SSLInfo& ssl_info); | 89 const SSLInfo& ssl_info); |
| 77 void OnNeedsProxyAuth(Job* job, | 90 void OnNeedsProxyAuth(Job* job, |
| 78 const HttpResponseInfo& proxy_response, | 91 const HttpResponseInfo& proxy_response, |
| 79 const SSLConfig& used_ssl_config, | 92 const SSLConfig& used_ssl_config, |
| 80 const ProxyInfo& used_proxy_info, | 93 const ProxyInfo& used_proxy_info, |
| 81 HttpAuthController* auth_controller); | 94 HttpAuthController* auth_controller); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 virtual bool using_spdy() const OVERRIDE; | 112 virtual bool using_spdy() const OVERRIDE; |
| 100 | 113 |
| 101 private: | 114 private: |
| 102 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound" | 115 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound" |
| 103 // to the request. | 116 // to the request. |
| 104 void OrphanJobsExcept(Job* job); | 117 void OrphanJobsExcept(Job* job); |
| 105 | 118 |
| 106 // Used to orphan all jobs in |jobs_|. | 119 // Used to orphan all jobs in |jobs_|. |
| 107 void OrphanJobs(); | 120 void OrphanJobs(); |
| 108 | 121 |
| 122 // Orphan a job if appropriate. |
| 123 void Orphan(Job* job); |
| 124 |
| 109 const GURL url_; | 125 const GURL url_; |
| 110 HttpStreamFactoryImpl* const factory_; | 126 HttpStreamFactoryImpl* const factory_; |
| 127 WebSocketStreamBase::Factory* const websocket_stream_factory_; |
| 111 HttpStreamRequest::Delegate* const delegate_; | 128 HttpStreamRequest::Delegate* const delegate_; |
| 112 const BoundNetLog net_log_; | 129 const BoundNetLog net_log_; |
| 113 | 130 |
| 114 // At the point where Job is irrevocably tied to the Request, we set this. | 131 // At the point where Job is irrevocably tied to the Request, we set this. |
| 115 scoped_ptr<Job> bound_job_; | 132 scoped_ptr<Job> bound_job_; |
| 116 std::set<HttpStreamFactoryImpl::Job*> jobs_; | 133 std::set<HttpStreamFactoryImpl::Job*> jobs_; |
| 117 scoped_ptr<const SpdySessionKey> spdy_session_key_; | 134 scoped_ptr<const SpdySessionKey> spdy_session_key_; |
| 118 scoped_ptr<const HttpPipelinedHost::Key> http_pipelining_key_; | 135 scoped_ptr<const HttpPipelinedHost::Key> http_pipelining_key_; |
| 119 | 136 |
| 120 bool completed_; | 137 bool completed_; |
| 121 bool was_npn_negotiated_; | 138 bool was_npn_negotiated_; |
| 122 // Protocol negotiated with the server. | 139 // Protocol negotiated with the server. |
| 123 NextProto protocol_negotiated_; | 140 NextProto protocol_negotiated_; |
| 124 bool using_spdy_; | 141 bool using_spdy_; |
| 125 | 142 |
| 126 DISALLOW_COPY_AND_ASSIGN(Request); | 143 DISALLOW_COPY_AND_ASSIGN(Request); |
| 127 }; | 144 }; |
| 128 | 145 |
| 129 } // namespace net | 146 } // namespace net |
| 130 | 147 |
| 131 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 148 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ |
| OLD | NEW |