Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: net/http/http_stream_factory_impl_request.h

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Misha's comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/socket/connection_attempts.h" 14 #include "net/socket/connection_attempts.h"
15 #include "net/socket/ssl_client_socket.h" 15 #include "net/socket/ssl_client_socket.h"
16 #include "net/spdy/spdy_session_key.h" 16 #include "net/spdy/spdy_session_key.h"
17 #include "net/ssl/ssl_failure_state.h" 17 #include "net/ssl/ssl_failure_state.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 class BidirectionalStreamJob;
22 class ClientSocketHandle; 23 class ClientSocketHandle;
23 class HttpStream; 24 class HttpStream;
24 class SpdySession; 25 class SpdySession;
25 26
26 class HttpStreamFactoryImpl::Request : public HttpStreamRequest { 27 class HttpStreamFactoryImpl::Request : public HttpStreamRequest {
27 public: 28 public:
29 // Indicates which type of stream is requested.
30 enum StreamType {
31 BIDIRECTIONAL_STREAM_SPDY_JOB,
32 HTTP_STREAM,
33 };
34
28 Request(const GURL& url, 35 Request(const GURL& url,
29 HttpStreamFactoryImpl* factory, 36 HttpStreamFactoryImpl* factory,
30 HttpStreamRequest::Delegate* delegate, 37 HttpStreamRequest::Delegate* delegate,
31 WebSocketHandshakeStreamBase::CreateHelper* 38 WebSocketHandshakeStreamBase::CreateHelper*
32 websocket_handshake_stream_create_helper, 39 websocket_handshake_stream_create_helper,
33 const BoundNetLog& net_log); 40 const BoundNetLog& net_log,
41 StreamType stream_type);
42
34 ~Request() override; 43 ~Request() override;
35 44
36 // The GURL from the HttpRequestInfo the started the Request. 45 // The GURL from the HttpRequestInfo the started the Request.
37 const GURL& url() const { return url_; } 46 const GURL& url() const { return url_; }
38 47
39 const BoundNetLog& net_log() const { return net_log_; } 48 const BoundNetLog& net_log() const { return net_log_; }
40 49
41 // Called when the Job determines the appropriate |spdy_session_key| for the 50 // Called when the Job determines the appropriate |spdy_session_key| for the
42 // Request. Note that this does not mean that SPDY is necessarily supported 51 // Request. Note that this does not mean that SPDY is necessarily supported
43 // for this SpdySessionKey, since we may need to wait for NPN to complete 52 // for this SpdySessionKey, since we may need to wait for NPN to complete
44 // before knowing if SPDY is available. 53 // before knowing if SPDY is available.
45 void SetSpdySessionKey(const SpdySessionKey& spdy_session_key); 54 void SetSpdySessionKey(const SpdySessionKey& spdy_session_key);
46 bool HasSpdySessionKey() const; 55 bool HasSpdySessionKey() const;
47 56
48 // Attaches |job| to this request. Does not mean that Request will use |job|, 57 // Attaches |job| to this request. Does not mean that Request will use |job|,
49 // but Request will own |job|. 58 // but Request will own |job|.
50 void AttachJob(HttpStreamFactoryImpl::Job* job); 59 void AttachJob(HttpStreamFactoryImpl::Job* job);
51 60
52 // Marks completion of the request. Must be called before OnStreamReady(). 61 // Marks completion of the request. Must be called before OnStreamReady().
53 void Complete(bool was_npn_negotiated, 62 void Complete(bool was_npn_negotiated,
54 NextProto protocol_negotiated, 63 NextProto protocol_negotiated,
55 bool using_spdy); 64 bool using_spdy);
56 65
57 // If this Request has a |spdy_session_key_|, remove this session from the 66 // If this Request has a |spdy_session_key_|, remove this session from the
58 // SpdySessionRequestMap. 67 // SpdySessionRequestMap.
59 void RemoveRequestFromSpdySessionRequestMap(); 68 void RemoveRequestFromSpdySessionRequestMap();
60 69
61 // Called by an attached Job if it sets up a SpdySession. 70 // Called by an attached Job if it sets up a SpdySession.
62 void OnNewSpdySessionReady(Job* job, 71 // |stream| is null when |for_bidirectional| is true.
63 scoped_ptr<HttpStream> stream, 72 // |bidirectional_stream_spdy_job| is null when |for_bidirectional| is false.
64 const base::WeakPtr<SpdySession>& spdy_session, 73 void OnNewSpdySessionReady(
65 bool direct); 74 Job* job,
75 scoped_ptr<HttpStream> stream,
76 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_spdy_job,
77 const base::WeakPtr<SpdySession>& spdy_session,
78 bool direct);
66 79
67 // Called by an attached Job to record connection attempts made by the socket 80 // Called by an attached Job to record connection attempts made by the socket
68 // layer for this stream request. 81 // layer for this stream request.
69 void AddConnectionAttempts(const ConnectionAttempts& attempts); 82 void AddConnectionAttempts(const ConnectionAttempts& attempts);
70 83
71 WebSocketHandshakeStreamBase::CreateHelper* 84 WebSocketHandshakeStreamBase::CreateHelper*
72 websocket_handshake_stream_create_helper() { 85 websocket_handshake_stream_create_helper() {
73 return websocket_handshake_stream_create_helper_; 86 return websocket_handshake_stream_create_helper_;
74 } 87 }
75 88
76 // HttpStreamRequest::Delegate methods which we implement. Note we don't 89 // HttpStreamRequest::Delegate methods which we implement. Note we don't
77 // actually subclass HttpStreamRequest::Delegate. 90 // actually subclass HttpStreamRequest::Delegate.
78 91
79 void OnStreamReady(Job* job, 92 void OnStreamReady(Job* job,
80 const SSLConfig& used_ssl_config, 93 const SSLConfig& used_ssl_config,
81 const ProxyInfo& used_proxy_info, 94 const ProxyInfo& used_proxy_info,
82 HttpStream* stream); 95 HttpStream* stream);
96 void OnBidirectionalStreamJobReady(Job* job,
97 const SSLConfig& used_ssl_config,
98 const ProxyInfo& used_proxy_info,
99 BidirectionalStreamJob* stream);
100
83 void OnWebSocketHandshakeStreamReady(Job* job, 101 void OnWebSocketHandshakeStreamReady(Job* job,
84 const SSLConfig& used_ssl_config, 102 const SSLConfig& used_ssl_config,
85 const ProxyInfo& used_proxy_info, 103 const ProxyInfo& used_proxy_info,
86 WebSocketHandshakeStreamBase* stream); 104 WebSocketHandshakeStreamBase* stream);
87 void OnStreamFailed(Job* job, 105 void OnStreamFailed(Job* job,
88 int status, 106 int status,
89 const SSLConfig& used_ssl_config, 107 const SSLConfig& used_ssl_config,
90 SSLFailureState ssl_failure_state); 108 SSLFailureState ssl_failure_state);
91 void OnCertificateError(Job* job, 109 void OnCertificateError(Job* job,
92 int status, 110 int status,
(...skipping 16 matching lines...) Expand all
109 127
110 // HttpStreamRequest methods. 128 // HttpStreamRequest methods.
111 129
112 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override; 130 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override;
113 void SetPriority(RequestPriority priority) override; 131 void SetPriority(RequestPriority priority) override;
114 LoadState GetLoadState() const override; 132 LoadState GetLoadState() const override;
115 bool was_npn_negotiated() const override; 133 bool was_npn_negotiated() const override;
116 NextProto protocol_negotiated() const override; 134 NextProto protocol_negotiated() const override;
117 bool using_spdy() const override; 135 bool using_spdy() const override;
118 const ConnectionAttempts& connection_attempts() const override; 136 const ConnectionAttempts& connection_attempts() const override;
137 bool for_bidirectional() const { return for_bidirectional_; }
119 138
120 private: 139 private:
121 // 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_|.
122 void BindJob(Job* job); 141 void BindJob(Job* job);
123 142
124 // Used to orphan all jobs in |jobs_|. 143 // Used to orphan all jobs in |jobs_|.
125 void OrphanJobs(); 144 void OrphanJobs();
126 145
127 // Used to cancel all jobs in |jobs_|. 146 // Used to cancel all jobs in |jobs_|.
128 void CancelJobs(); 147 void CancelJobs();
(...skipping 13 matching lines...) Expand all
142 std::set<HttpStreamFactoryImpl::Job*> jobs_; 161 std::set<HttpStreamFactoryImpl::Job*> jobs_;
143 scoped_ptr<const SpdySessionKey> spdy_session_key_; 162 scoped_ptr<const SpdySessionKey> spdy_session_key_;
144 163
145 bool completed_; 164 bool completed_;
146 bool was_npn_negotiated_; 165 bool was_npn_negotiated_;
147 // Protocol negotiated with the server. 166 // Protocol negotiated with the server.
148 NextProto protocol_negotiated_; 167 NextProto protocol_negotiated_;
149 bool using_spdy_; 168 bool using_spdy_;
150 ConnectionAttempts connection_attempts_; 169 ConnectionAttempts connection_attempts_;
151 170
171 const bool for_bidirectional_;
152 DISALLOW_COPY_AND_ASSIGN(Request); 172 DISALLOW_COPY_AND_ASSIGN(Request);
153 }; 173 };
154 174
155 } // namespace net 175 } // namespace net
156 176
157 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_ 177 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698