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 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "net/http/http_stream_factory_impl.h" | 12 #include "net/http/http_stream_factory_impl.h" |
13 #include "net/log/net_log.h" | 13 #include "net/log/net_log.h" |
14 #include "net/net_features.h" | 14 #include "net/net_features.h" |
15 #include "net/socket/connection_attempts.h" | 15 #include "net/socket/connection_attempts.h" |
16 #include "net/socket/ssl_client_socket.h" | 16 #include "net/socket/ssl_client_socket.h" |
17 #include "net/spdy/spdy_session_key.h" | 17 #include "net/spdy/spdy_session_key.h" |
18 #include "net/ssl/ssl_failure_state.h" | 18 #include "net/ssl/ssl_failure_state.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 class BidirectionalStreamJob; | 23 class BidirectionalStreamJob; |
24 class ClientSocketHandle; | 24 class ClientSocketHandle; |
25 class HttpStream; | 25 class HttpStream; |
26 class SpdySession; | 26 class SpdySession; |
27 | 27 |
28 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { | 28 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { |
29 public: | 29 public: |
30 // Indicates which type of stream is requested. | |
31 enum StreamType { | |
32 BIDIRECTIONAL_STREAM_SPDY_JOB, | |
33 HTTP_STREAM, | |
34 }; | |
35 | |
36 Request(const GURL& url, | 30 Request(const GURL& url, |
37 HttpStreamFactoryImpl* factory, | 31 HttpStreamFactoryImpl* factory, |
38 HttpStreamRequest::Delegate* delegate, | 32 HttpStreamRequest::Delegate* delegate, |
39 WebSocketHandshakeStreamBase::CreateHelper* | 33 WebSocketHandshakeStreamBase::CreateHelper* |
40 websocket_handshake_stream_create_helper, | 34 websocket_handshake_stream_create_helper, |
41 const BoundNetLog& net_log, | 35 const BoundNetLog& net_log, |
42 StreamType stream_type); | 36 StreamType stream_type); |
43 | 37 |
44 ~Request() override; | 38 ~Request() override; |
45 | 39 |
(...skipping 16 matching lines...) Expand all Loading... |
62 // Marks completion of the request. Must be called before OnStreamReady(). | 56 // Marks completion of the request. Must be called before OnStreamReady(). |
63 void Complete(bool was_npn_negotiated, | 57 void Complete(bool was_npn_negotiated, |
64 NextProto protocol_negotiated, | 58 NextProto protocol_negotiated, |
65 bool using_spdy); | 59 bool using_spdy); |
66 | 60 |
67 // If this Request has a |spdy_session_key_|, remove this session from the | 61 // If this Request has a |spdy_session_key_|, remove this session from the |
68 // SpdySessionRequestMap. | 62 // SpdySessionRequestMap. |
69 void RemoveRequestFromSpdySessionRequestMap(); | 63 void RemoveRequestFromSpdySessionRequestMap(); |
70 | 64 |
71 // Called by an attached Job if it sets up a SpdySession. | 65 // Called by an attached Job if it sets up a SpdySession. |
72 // |stream| is null when |for_bidirectional| is true. | 66 // |stream| is null when |stream_type| is HttpStreamRequest::HTTP_STREAM. |
73 // |bidirectional_stream_spdy_job| is null when |for_bidirectional| is false. | 67 // |bidirectional_stream_spdy_job| is null when |stream_type| is |
| 68 // HttpStreamRequest::BIDIRECTIONAL_STREAM. |
74 void OnNewSpdySessionReady( | 69 void OnNewSpdySessionReady( |
75 Job* job, | 70 Job* job, |
76 scoped_ptr<HttpStream> stream, | 71 scoped_ptr<HttpStream> stream, |
77 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) | 72 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
78 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_spdy_job, | 73 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_spdy_job, |
79 #else | 74 #else |
80 void* unused, | 75 void* unused, |
81 #endif | 76 #endif |
82 const base::WeakPtr<SpdySession>& spdy_session, | 77 const base::WeakPtr<SpdySession>& spdy_session, |
83 bool direct); | 78 bool direct); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 127 |
133 // HttpStreamRequest methods. | 128 // HttpStreamRequest methods. |
134 | 129 |
135 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override; | 130 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override; |
136 void SetPriority(RequestPriority priority) override; | 131 void SetPriority(RequestPriority priority) override; |
137 LoadState GetLoadState() const override; | 132 LoadState GetLoadState() const override; |
138 bool was_npn_negotiated() const override; | 133 bool was_npn_negotiated() const override; |
139 NextProto protocol_negotiated() const override; | 134 NextProto protocol_negotiated() const override; |
140 bool using_spdy() const override; | 135 bool using_spdy() const override; |
141 const ConnectionAttempts& connection_attempts() const override; | 136 const ConnectionAttempts& connection_attempts() const override; |
142 bool for_bidirectional() const { return for_bidirectional_; } | 137 HttpStreamRequest::StreamType stream_type() const { return stream_type_; } |
143 | 138 |
144 private: | 139 private: |
145 // Used to bind |job| to the request and orphan all other jobs in |jobs_|. | 140 // Used to bind |job| to the request and orphan all other jobs in |jobs_|. |
146 void BindJob(Job* job); | 141 void BindJob(Job* job); |
147 | 142 |
148 // Used to orphan all jobs in |jobs_|. | 143 // Used to orphan all jobs in |jobs_|. |
149 void OrphanJobs(); | 144 void OrphanJobs(); |
150 | 145 |
151 // Used to cancel all jobs in |jobs_|. | 146 // Used to cancel all jobs in |jobs_|. |
152 void CancelJobs(); | 147 void CancelJobs(); |
(...skipping 13 matching lines...) Expand all Loading... |
166 std::set<HttpStreamFactoryImpl::Job*> jobs_; | 161 std::set<HttpStreamFactoryImpl::Job*> jobs_; |
167 scoped_ptr<const SpdySessionKey> spdy_session_key_; | 162 scoped_ptr<const SpdySessionKey> spdy_session_key_; |
168 | 163 |
169 bool completed_; | 164 bool completed_; |
170 bool was_npn_negotiated_; | 165 bool was_npn_negotiated_; |
171 // Protocol negotiated with the server. | 166 // Protocol negotiated with the server. |
172 NextProto protocol_negotiated_; | 167 NextProto protocol_negotiated_; |
173 bool using_spdy_; | 168 bool using_spdy_; |
174 ConnectionAttempts connection_attempts_; | 169 ConnectionAttempts connection_attempts_; |
175 | 170 |
176 const bool for_bidirectional_; | 171 const HttpStreamRequest::StreamType stream_type_; |
177 DISALLOW_COPY_AND_ASSIGN(Request); | 172 DISALLOW_COPY_AND_ASSIGN(Request); |
178 }; | 173 }; |
179 | 174 |
180 } // namespace net | 175 } // namespace net |
181 | 176 |
182 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ | 177 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ |
OLD | NEW |