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 #include "net/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 }; | 51 }; |
52 | 52 |
53 explicit MockWebSocketHandshakeStream(StreamType type) : type_(type) {} | 53 explicit MockWebSocketHandshakeStream(StreamType type) : type_(type) {} |
54 | 54 |
55 ~MockWebSocketHandshakeStream() override {} | 55 ~MockWebSocketHandshakeStream() override {} |
56 | 56 |
57 StreamType type() const { | 57 StreamType type() const { |
58 return type_; | 58 return type_; |
59 } | 59 } |
60 | 60 |
61 // HttpStreamBase methods | 61 // HttpStream methods |
62 int InitializeStream(const HttpRequestInfo* request_info, | 62 int InitializeStream(const HttpRequestInfo* request_info, |
63 RequestPriority priority, | 63 RequestPriority priority, |
64 const BoundNetLog& net_log, | 64 const BoundNetLog& net_log, |
65 const CompletionCallback& callback) override { | 65 const CompletionCallback& callback) override { |
66 return ERR_IO_PENDING; | 66 return ERR_IO_PENDING; |
67 } | 67 } |
68 int SendRequest(const HttpRequestHeaders& request_headers, | 68 int SendRequest(const HttpRequestHeaders& request_headers, |
69 HttpResponseInfo* response, | 69 HttpResponseInfo* response, |
70 const CompletionCallback& callback) override { | 70 const CompletionCallback& callback) override { |
71 return ERR_IO_PENDING; | 71 return ERR_IO_PENDING; |
(...skipping 14 matching lines...) Expand all Loading... | |
86 bool IsConnectionReusable() const override { return false; } | 86 bool IsConnectionReusable() const override { return false; } |
87 int64 GetTotalReceivedBytes() const override { return 0; } | 87 int64 GetTotalReceivedBytes() const override { return 0; } |
88 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override { | 88 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override { |
89 return false; | 89 return false; |
90 } | 90 } |
91 void GetSSLInfo(SSLInfo* ssl_info) override {} | 91 void GetSSLInfo(SSLInfo* ssl_info) override {} |
92 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {} | 92 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {} |
93 bool IsSpdyHttpStream() const override { return false; } | 93 bool IsSpdyHttpStream() const override { return false; } |
94 void Drain(HttpNetworkSession* session) override {} | 94 void Drain(HttpNetworkSession* session) override {} |
95 void SetPriority(RequestPriority priority) override {} | 95 void SetPriority(RequestPriority priority) override {} |
96 UploadProgress GetUploadProgress() const override { return UploadProgress(); } | |
97 HttpStream* RenewStreamForAuth() override { return nullptr; } | |
tyoshino-do-not-use
2014/11/05 02:51:44
NULL -> nullptr in this file
yhirano
2014/11/05 03:55:37
Done.
| |
96 | 98 |
97 scoped_ptr<WebSocketStream> Upgrade() override { | 99 scoped_ptr<WebSocketStream> Upgrade() override { |
98 return scoped_ptr<WebSocketStream>(); | 100 return scoped_ptr<WebSocketStream>(); |
99 } | 101 } |
100 | 102 |
101 private: | 103 private: |
102 const StreamType type_; | 104 const StreamType type_; |
103 }; | 105 }; |
104 | 106 |
105 // HttpStreamFactoryImpl subclass that can wait until a preconnect is complete. | 107 // HttpStreamFactoryImpl subclass that can wait until a preconnect is complete. |
(...skipping 29 matching lines...) Expand all Loading... | |
135 class StreamRequestWaiter : public HttpStreamRequest::Delegate { | 137 class StreamRequestWaiter : public HttpStreamRequest::Delegate { |
136 public: | 138 public: |
137 StreamRequestWaiter() | 139 StreamRequestWaiter() |
138 : waiting_for_stream_(false), | 140 : waiting_for_stream_(false), |
139 stream_done_(false) {} | 141 stream_done_(false) {} |
140 | 142 |
141 // HttpStreamRequest::Delegate | 143 // HttpStreamRequest::Delegate |
142 | 144 |
143 void OnStreamReady(const SSLConfig& used_ssl_config, | 145 void OnStreamReady(const SSLConfig& used_ssl_config, |
144 const ProxyInfo& used_proxy_info, | 146 const ProxyInfo& used_proxy_info, |
145 HttpStreamBase* stream) override { | 147 HttpStream* stream) override { |
146 stream_done_ = true; | 148 stream_done_ = true; |
147 if (waiting_for_stream_) | 149 if (waiting_for_stream_) |
148 base::MessageLoop::current()->Quit(); | 150 base::MessageLoop::current()->Quit(); |
149 stream_.reset(stream); | 151 stream_.reset(stream); |
150 used_ssl_config_ = used_ssl_config; | 152 used_ssl_config_ = used_ssl_config; |
151 used_proxy_info_ = used_proxy_info; | 153 used_proxy_info_ = used_proxy_info; |
152 } | 154 } |
153 | 155 |
154 void OnWebSocketHandshakeStreamReady( | 156 void OnWebSocketHandshakeStreamReady( |
155 const SSLConfig& used_ssl_config, | 157 const SSLConfig& used_ssl_config, |
(...skipping 17 matching lines...) Expand all Loading... | |
173 const SSLConfig& used_ssl_config, | 175 const SSLConfig& used_ssl_config, |
174 const ProxyInfo& used_proxy_info, | 176 const ProxyInfo& used_proxy_info, |
175 HttpAuthController* auth_controller) override {} | 177 HttpAuthController* auth_controller) override {} |
176 | 178 |
177 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, | 179 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, |
178 SSLCertRequestInfo* cert_info) override {} | 180 SSLCertRequestInfo* cert_info) override {} |
179 | 181 |
180 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, | 182 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, |
181 const SSLConfig& used_ssl_config, | 183 const SSLConfig& used_ssl_config, |
182 const ProxyInfo& used_proxy_info, | 184 const ProxyInfo& used_proxy_info, |
183 HttpStreamBase* stream) override {} | 185 HttpStream* stream) override {} |
184 | 186 |
185 void WaitForStream() { | 187 void WaitForStream() { |
186 while (!stream_done_) { | 188 while (!stream_done_) { |
187 waiting_for_stream_ = true; | 189 waiting_for_stream_ = true; |
188 base::MessageLoop::current()->Run(); | 190 base::MessageLoop::current()->Run(); |
189 waiting_for_stream_ = false; | 191 waiting_for_stream_ = false; |
190 } | 192 } |
191 } | 193 } |
192 | 194 |
193 const SSLConfig& used_ssl_config() const { | 195 const SSLConfig& used_ssl_config() const { |
194 return used_ssl_config_; | 196 return used_ssl_config_; |
195 } | 197 } |
196 | 198 |
197 const ProxyInfo& used_proxy_info() const { | 199 const ProxyInfo& used_proxy_info() const { |
198 return used_proxy_info_; | 200 return used_proxy_info_; |
199 } | 201 } |
200 | 202 |
201 HttpStreamBase* stream() { | 203 HttpStream* stream() { |
202 return stream_.get(); | 204 return stream_.get(); |
203 } | 205 } |
204 | 206 |
205 MockWebSocketHandshakeStream* websocket_stream() { | 207 MockWebSocketHandshakeStream* websocket_stream() { |
206 return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get()); | 208 return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get()); |
207 } | 209 } |
208 | 210 |
209 bool stream_done() const { return stream_done_; } | 211 bool stream_done() const { return stream_done_; } |
210 | 212 |
211 private: | 213 private: |
212 bool waiting_for_stream_; | 214 bool waiting_for_stream_; |
213 bool stream_done_; | 215 bool stream_done_; |
214 scoped_ptr<HttpStreamBase> stream_; | 216 scoped_ptr<HttpStream> stream_; |
215 scoped_ptr<WebSocketHandshakeStreamBase> websocket_stream_; | 217 scoped_ptr<WebSocketHandshakeStreamBase> websocket_stream_; |
216 SSLConfig used_ssl_config_; | 218 SSLConfig used_ssl_config_; |
217 ProxyInfo used_proxy_info_; | 219 ProxyInfo used_proxy_info_; |
218 | 220 |
219 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); | 221 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); |
220 }; | 222 }; |
221 | 223 |
222 class WebSocketSpdyHandshakeStream : public MockWebSocketHandshakeStream { | 224 class WebSocketSpdyHandshakeStream : public MockWebSocketHandshakeStream { |
223 public: | 225 public: |
224 explicit WebSocketSpdyHandshakeStream( | 226 explicit WebSocketSpdyHandshakeStream( |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1297 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 1299 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
1298 | 1300 |
1299 // Make sure there is no orphaned job. it is already canceled. | 1301 // Make sure there is no orphaned job. it is already canceled. |
1300 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( | 1302 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( |
1301 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); | 1303 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); |
1302 } | 1304 } |
1303 | 1305 |
1304 } // namespace | 1306 } // namespace |
1305 | 1307 |
1306 } // namespace net | 1308 } // namespace net |
OLD | NEW |