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

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

Powered by Google App Engine
This is Rietveld 408576698