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/socket/ssl_client_socket.h" | 13 #include "net/socket/ssl_client_socket.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class ClientSocketHandle; | |
18 class SpdySession; | |
19 | |
17 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { | 20 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { |
18 public: | 21 public: |
19 Request(const GURL& url, | 22 Request(const GURL& url, |
20 HttpStreamFactoryImpl* factory, | 23 HttpStreamFactoryImpl* factory, |
21 HttpStreamRequest::Delegate* delegate, | 24 HttpStreamRequest::Delegate* delegate, |
22 const BoundNetLog& net_log); | 25 const BoundNetLog& net_log, |
26 bool for_websocket); | |
23 virtual ~Request(); | 27 virtual ~Request(); |
24 | 28 |
25 // The GURL from the HttpRequestInfo the started the Request. | 29 // The GURL from the HttpRequestInfo the started the Request. |
26 const GURL& url() const { return url_; } | 30 const GURL& url() const { return url_; } |
27 | 31 |
28 // Called when the Job determines the appropriate |spdy_session_key| for the | 32 // Called when the Job determines the appropriate |spdy_session_key| for the |
29 // Request. Note that this does not mean that SPDY is necessarily supported | 33 // Request. Note that this does not mean that SPDY is necessarily supported |
30 // for this HostPortProxyPair, since we may need to wait for NPN to complete | 34 // for this HostPortProxyPair, since we may need to wait for NPN to complete |
31 // before knowing if SPDY is available. | 35 // before knowing if SPDY is available. |
32 void SetSpdySessionKey(const HostPortProxyPair& spdy_session_key); | 36 void SetSpdySessionKey(const HostPortProxyPair& spdy_session_key); |
(...skipping 28 matching lines...) Expand all Loading... | |
61 scoped_refptr<SpdySession> spdy_session, | 65 scoped_refptr<SpdySession> spdy_session, |
62 bool direct); | 66 bool direct); |
63 | 67 |
64 // HttpStreamRequest::Delegate methods which we implement. Note we don't | 68 // HttpStreamRequest::Delegate methods which we implement. Note we don't |
65 // actually subclass HttpStreamRequest::Delegate. | 69 // actually subclass HttpStreamRequest::Delegate. |
66 | 70 |
67 void OnStreamReady(Job* job, | 71 void OnStreamReady(Job* job, |
68 const SSLConfig& used_ssl_config, | 72 const SSLConfig& used_ssl_config, |
69 const ProxyInfo& used_proxy_info, | 73 const ProxyInfo& used_proxy_info, |
70 HttpStreamBase* stream); | 74 HttpStreamBase* stream); |
75 // Called by an attached Job if it wants to pass a spdy session | |
76 // to the delegate. | |
77 void OnSpdySessionReadyForWS(Job* job, | |
mmenke
2013/05/15 15:38:20
I think the code is clearer if we don't abbreviate
yhirano
2013/05/16 05:02:35
Done.
| |
78 const SSLConfig& used_ssl_config, | |
79 const ProxyInfo& used_proxy_info, | |
80 scoped_refptr<SpdySession> session); | |
81 void OnSocketReady(Job* job, | |
82 const SSLConfig& used_ssl_config, | |
83 const ProxyInfo& used_proxy_info, | |
84 ClientSocketHandle* connection); | |
mmenke
2013/05/15 15:38:20
I think we need to decide if we're going to consid
Adam Rice
2013/05/16 04:00:36
Unless we have another use case on the table, I wo
yhirano
2013/05/16 05:02:35
I see, I renamed the delegate functions.
| |
71 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config); | 85 void OnStreamFailed(Job* job, int status, const SSLConfig& used_ssl_config); |
72 void OnCertificateError(Job* job, | 86 void OnCertificateError(Job* job, |
73 int status, | 87 int status, |
74 const SSLConfig& used_ssl_config, | 88 const SSLConfig& used_ssl_config, |
75 const SSLInfo& ssl_info); | 89 const SSLInfo& ssl_info); |
76 void OnNeedsProxyAuth(Job* job, | 90 void OnNeedsProxyAuth(Job* job, |
77 const HttpResponseInfo& proxy_response, | 91 const HttpResponseInfo& proxy_response, |
78 const SSLConfig& used_ssl_config, | 92 const SSLConfig& used_ssl_config, |
79 const ProxyInfo& used_proxy_info, | 93 const ProxyInfo& used_proxy_info, |
80 HttpAuthController* auth_controller); | 94 HttpAuthController* auth_controller); |
81 void OnNeedsClientAuth(Job* job, | 95 void OnNeedsClientAuth(Job* job, |
82 const SSLConfig& used_ssl_config, | 96 const SSLConfig& used_ssl_config, |
83 SSLCertRequestInfo* cert_info); | 97 SSLCertRequestInfo* cert_info); |
84 void OnHttpsProxyTunnelResponse( | 98 void OnHttpsProxyTunnelResponse( |
85 Job *job, | 99 Job *job, |
86 const HttpResponseInfo& response_info, | 100 const HttpResponseInfo& response_info, |
87 const SSLConfig& used_ssl_config, | 101 const SSLConfig& used_ssl_config, |
88 const ProxyInfo& used_proxy_info, | 102 const ProxyInfo& used_proxy_info, |
89 HttpStreamBase* stream); | 103 HttpStreamBase* stream); |
90 | 104 |
105 bool for_websocket() const { return for_websocket_; } | |
106 | |
91 // HttpStreamRequest methods. | 107 // HttpStreamRequest methods. |
92 | 108 |
93 virtual int RestartTunnelWithProxyAuth( | 109 virtual int RestartTunnelWithProxyAuth( |
94 const AuthCredentials& credentials) OVERRIDE; | 110 const AuthCredentials& credentials) OVERRIDE; |
95 virtual LoadState GetLoadState() const OVERRIDE; | 111 virtual LoadState GetLoadState() const OVERRIDE; |
96 virtual bool was_npn_negotiated() const OVERRIDE; | 112 virtual bool was_npn_negotiated() const OVERRIDE; |
97 virtual NextProto protocol_negotiated() const OVERRIDE; | 113 virtual NextProto protocol_negotiated() const OVERRIDE; |
98 virtual bool using_spdy() const OVERRIDE; | 114 virtual bool using_spdy() const OVERRIDE; |
99 | 115 |
100 private: | 116 private: |
101 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound" | 117 // Used to orphan all jobs in |jobs_| other than |job| which becomes "bound" |
102 // to the request. | 118 // to the request. |
103 void OrphanJobsExcept(Job* job); | 119 void OrphanJobsExcept(Job* job); |
104 | 120 |
105 // Used to orphan all jobs in |jobs_|. | 121 // Used to orphan all jobs in |jobs_|. |
106 void OrphanJobs(); | 122 void OrphanJobs(); |
107 | 123 |
124 // Orphan a job if appropriate. | |
125 void Orphan(Job* job); | |
126 | |
108 const GURL url_; | 127 const GURL url_; |
109 HttpStreamFactoryImpl* const factory_; | 128 HttpStreamFactoryImpl* const factory_; |
110 HttpStreamRequest::Delegate* const delegate_; | 129 HttpStreamRequest::Delegate* const delegate_; |
111 const BoundNetLog net_log_; | 130 const BoundNetLog net_log_; |
112 | 131 |
113 // At the point where Job is irrevocably tied to the Request, we set this. | 132 // At the point where Job is irrevocably tied to the Request, we set this. |
114 scoped_ptr<Job> bound_job_; | 133 scoped_ptr<Job> bound_job_; |
115 std::set<HttpStreamFactoryImpl::Job*> jobs_; | 134 std::set<HttpStreamFactoryImpl::Job*> jobs_; |
116 scoped_ptr<const HostPortProxyPair> spdy_session_key_; | 135 scoped_ptr<const HostPortProxyPair> spdy_session_key_; |
117 scoped_ptr<const HttpPipelinedHost::Key> http_pipelining_key_; | 136 scoped_ptr<const HttpPipelinedHost::Key> http_pipelining_key_; |
118 | 137 |
119 bool completed_; | 138 bool completed_; |
120 bool was_npn_negotiated_; | 139 bool was_npn_negotiated_; |
121 // Protocol negotiated with the server. | 140 // Protocol negotiated with the server. |
122 NextProto protocol_negotiated_; | 141 NextProto protocol_negotiated_; |
123 bool using_spdy_; | 142 bool using_spdy_; |
143 bool for_websocket_; | |
124 | 144 |
125 DISALLOW_COPY_AND_ASSIGN(Request); | 145 DISALLOW_COPY_AND_ASSIGN(Request); |
126 }; | 146 }; |
127 | 147 |
128 } // namespace net | 148 } // namespace net |
129 | 149 |
130 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 150 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ |
OLD | NEW |