OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 8173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8184 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8184 const HttpResponseInfo* response = trans->GetResponseInfo(); |
8185 EXPECT_FALSE(response); | 8185 EXPECT_FALSE(response); |
8186 | 8186 |
8187 base::DeleteFile(temp_file, false); | 8187 base::DeleteFile(temp_file, false); |
8188 } | 8188 } |
8189 | 8189 |
8190 TEST_P(HttpNetworkTransactionTest, CancelDuringInitRequestBody) { | 8190 TEST_P(HttpNetworkTransactionTest, CancelDuringInitRequestBody) { |
8191 class FakeUploadElementReader : public UploadElementReader { | 8191 class FakeUploadElementReader : public UploadElementReader { |
8192 public: | 8192 public: |
8193 FakeUploadElementReader() {} | 8193 FakeUploadElementReader() {} |
8194 virtual ~FakeUploadElementReader() {} | 8194 ~FakeUploadElementReader() override {} |
8195 | 8195 |
8196 const CompletionCallback& callback() const { return callback_; } | 8196 const CompletionCallback& callback() const { return callback_; } |
8197 | 8197 |
8198 // UploadElementReader overrides: | 8198 // UploadElementReader overrides: |
8199 virtual int Init(const CompletionCallback& callback) override { | 8199 int Init(const CompletionCallback& callback) override { |
8200 callback_ = callback; | 8200 callback_ = callback; |
8201 return ERR_IO_PENDING; | 8201 return ERR_IO_PENDING; |
8202 } | 8202 } |
8203 virtual uint64 GetContentLength() const override { return 0; } | 8203 uint64 GetContentLength() const override { return 0; } |
8204 virtual uint64 BytesRemaining() const override { return 0; } | 8204 uint64 BytesRemaining() const override { return 0; } |
8205 virtual int Read(IOBuffer* buf, | 8205 int Read(IOBuffer* buf, |
8206 int buf_length, | 8206 int buf_length, |
8207 const CompletionCallback& callback) override { | 8207 const CompletionCallback& callback) override { |
8208 return ERR_FAILED; | 8208 return ERR_FAILED; |
8209 } | 8209 } |
8210 | 8210 |
8211 private: | 8211 private: |
8212 CompletionCallback callback_; | 8212 CompletionCallback callback_; |
8213 }; | 8213 }; |
8214 | 8214 |
8215 FakeUploadElementReader* fake_reader = new FakeUploadElementReader; | 8215 FakeUploadElementReader* fake_reader = new FakeUploadElementReader; |
8216 ScopedVector<UploadElementReader> element_readers; | 8216 ScopedVector<UploadElementReader> element_readers; |
8217 element_readers.push_back(fake_reader); | 8217 element_readers.push_back(fake_reader); |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9090 EXPECT_FALSE(response->was_fetched_via_spdy); | 9090 EXPECT_FALSE(response->was_fetched_via_spdy); |
9091 EXPECT_FALSE(response->was_npn_negotiated); | 9091 EXPECT_FALSE(response->was_npn_negotiated); |
9092 | 9092 |
9093 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9093 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
9094 EXPECT_EQ("hello world", response_data); | 9094 EXPECT_EQ("hello world", response_data); |
9095 } | 9095 } |
9096 | 9096 |
9097 class CapturingProxyResolver : public ProxyResolver { | 9097 class CapturingProxyResolver : public ProxyResolver { |
9098 public: | 9098 public: |
9099 CapturingProxyResolver() : ProxyResolver(false /* expects_pac_bytes */) {} | 9099 CapturingProxyResolver() : ProxyResolver(false /* expects_pac_bytes */) {} |
9100 virtual ~CapturingProxyResolver() {} | 9100 ~CapturingProxyResolver() override {} |
9101 | 9101 |
9102 virtual int GetProxyForURL(const GURL& url, | 9102 int GetProxyForURL(const GURL& url, |
9103 ProxyInfo* results, | 9103 ProxyInfo* results, |
9104 const CompletionCallback& callback, | 9104 const CompletionCallback& callback, |
9105 RequestHandle* request, | 9105 RequestHandle* request, |
9106 const BoundNetLog& net_log) override { | 9106 const BoundNetLog& net_log) override { |
9107 ProxyServer proxy_server(ProxyServer::SCHEME_HTTP, | 9107 ProxyServer proxy_server(ProxyServer::SCHEME_HTTP, |
9108 HostPortPair("myproxy", 80)); | 9108 HostPortPair("myproxy", 80)); |
9109 results->UseProxyServer(proxy_server); | 9109 results->UseProxyServer(proxy_server); |
9110 resolved_.push_back(url); | 9110 resolved_.push_back(url); |
9111 return OK; | 9111 return OK; |
9112 } | 9112 } |
9113 | 9113 |
9114 virtual void CancelRequest(RequestHandle request) override { | 9114 void CancelRequest(RequestHandle request) override { NOTREACHED(); } |
9115 NOTREACHED(); | |
9116 } | |
9117 | 9115 |
9118 virtual LoadState GetLoadState(RequestHandle request) const override { | 9116 LoadState GetLoadState(RequestHandle request) const override { |
9119 NOTREACHED(); | 9117 NOTREACHED(); |
9120 return LOAD_STATE_IDLE; | 9118 return LOAD_STATE_IDLE; |
9121 } | 9119 } |
9122 | 9120 |
9123 virtual void CancelSetPacScript() override { | 9121 void CancelSetPacScript() override { NOTREACHED(); } |
9124 NOTREACHED(); | |
9125 } | |
9126 | 9122 |
9127 virtual int SetPacScript(const scoped_refptr<ProxyResolverScriptData>&, | 9123 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>&, |
9128 const CompletionCallback& /*callback*/) override { | 9124 const CompletionCallback& /*callback*/) override { |
9129 return OK; | 9125 return OK; |
9130 } | 9126 } |
9131 | 9127 |
9132 const std::vector<GURL>& resolved() const { return resolved_; } | 9128 const std::vector<GURL>& resolved() const { return resolved_; } |
9133 | 9129 |
9134 private: | 9130 private: |
9135 std::vector<GURL> resolved_; | 9131 std::vector<GURL> resolved_; |
9136 | 9132 |
9137 DISALLOW_COPY_AND_ASSIGN(CapturingProxyResolver); | 9133 DISALLOW_COPY_AND_ASSIGN(CapturingProxyResolver); |
9138 }; | 9134 }; |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10053 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 10049 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
10054 } | 10050 } |
10055 | 10051 |
10056 // A subclass of HttpAuthHandlerMock that records the request URL when | 10052 // A subclass of HttpAuthHandlerMock that records the request URL when |
10057 // it gets it. This is needed since the auth handler may get destroyed | 10053 // it gets it. This is needed since the auth handler may get destroyed |
10058 // before we get a chance to query it. | 10054 // before we get a chance to query it. |
10059 class UrlRecordingHttpAuthHandlerMock : public HttpAuthHandlerMock { | 10055 class UrlRecordingHttpAuthHandlerMock : public HttpAuthHandlerMock { |
10060 public: | 10056 public: |
10061 explicit UrlRecordingHttpAuthHandlerMock(GURL* url) : url_(url) {} | 10057 explicit UrlRecordingHttpAuthHandlerMock(GURL* url) : url_(url) {} |
10062 | 10058 |
10063 virtual ~UrlRecordingHttpAuthHandlerMock() {} | 10059 ~UrlRecordingHttpAuthHandlerMock() override {} |
10064 | 10060 |
10065 protected: | 10061 protected: |
10066 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 10062 int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
10067 const HttpRequestInfo* request, | 10063 const HttpRequestInfo* request, |
10068 const CompletionCallback& callback, | 10064 const CompletionCallback& callback, |
10069 std::string* auth_token) override { | 10065 std::string* auth_token) override { |
10070 *url_ = request->url; | 10066 *url_ = request->url; |
10071 return HttpAuthHandlerMock::GenerateAuthTokenImpl( | 10067 return HttpAuthHandlerMock::GenerateAuthTokenImpl( |
10072 credentials, request, callback, auth_token); | 10068 credentials, request, callback, auth_token); |
10073 } | 10069 } |
10074 | 10070 |
10075 private: | 10071 private: |
10076 GURL* url_; | 10072 GURL* url_; |
10077 }; | 10073 }; |
10078 | 10074 |
10079 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { | 10075 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11146 EXPECT_TRUE(response->was_fetched_via_spdy); | 11142 EXPECT_TRUE(response->was_fetched_via_spdy); |
11147 EXPECT_TRUE(response->was_npn_negotiated); | 11143 EXPECT_TRUE(response->was_npn_negotiated); |
11148 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 11144 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
11149 EXPECT_EQ("hello!", response_data); | 11145 EXPECT_EQ("hello!", response_data); |
11150 } | 11146 } |
11151 | 11147 |
11152 class OneTimeCachingHostResolver : public net::HostResolver { | 11148 class OneTimeCachingHostResolver : public net::HostResolver { |
11153 public: | 11149 public: |
11154 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) | 11150 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) |
11155 : host_port_(host_port) {} | 11151 : host_port_(host_port) {} |
11156 virtual ~OneTimeCachingHostResolver() {} | 11152 ~OneTimeCachingHostResolver() override {} |
11157 | 11153 |
11158 RuleBasedHostResolverProc* rules() { return host_resolver_.rules(); } | 11154 RuleBasedHostResolverProc* rules() { return host_resolver_.rules(); } |
11159 | 11155 |
11160 // HostResolver methods: | 11156 // HostResolver methods: |
11161 virtual int Resolve(const RequestInfo& info, | 11157 int Resolve(const RequestInfo& info, |
11162 RequestPriority priority, | 11158 RequestPriority priority, |
11163 AddressList* addresses, | 11159 AddressList* addresses, |
11164 const CompletionCallback& callback, | 11160 const CompletionCallback& callback, |
11165 RequestHandle* out_req, | 11161 RequestHandle* out_req, |
11166 const BoundNetLog& net_log) override { | 11162 const BoundNetLog& net_log) override { |
11167 return host_resolver_.Resolve( | 11163 return host_resolver_.Resolve( |
11168 info, priority, addresses, callback, out_req, net_log); | 11164 info, priority, addresses, callback, out_req, net_log); |
11169 } | 11165 } |
11170 | 11166 |
11171 virtual int ResolveFromCache(const RequestInfo& info, | 11167 int ResolveFromCache(const RequestInfo& info, |
11172 AddressList* addresses, | 11168 AddressList* addresses, |
11173 const BoundNetLog& net_log) override { | 11169 const BoundNetLog& net_log) override { |
11174 int rv = host_resolver_.ResolveFromCache(info, addresses, net_log); | 11170 int rv = host_resolver_.ResolveFromCache(info, addresses, net_log); |
11175 if (rv == OK && info.host_port_pair().Equals(host_port_)) | 11171 if (rv == OK && info.host_port_pair().Equals(host_port_)) |
11176 host_resolver_.GetHostCache()->clear(); | 11172 host_resolver_.GetHostCache()->clear(); |
11177 return rv; | 11173 return rv; |
11178 } | 11174 } |
11179 | 11175 |
11180 virtual void CancelRequest(RequestHandle req) override { | 11176 void CancelRequest(RequestHandle req) override { |
11181 host_resolver_.CancelRequest(req); | 11177 host_resolver_.CancelRequest(req); |
11182 } | 11178 } |
11183 | 11179 |
11184 MockCachingHostResolver* GetMockHostResolver() { | 11180 MockCachingHostResolver* GetMockHostResolver() { |
11185 return &host_resolver_; | 11181 return &host_resolver_; |
11186 } | 11182 } |
11187 | 11183 |
11188 private: | 11184 private: |
11189 MockCachingHostResolver host_resolver_; | 11185 MockCachingHostResolver host_resolver_; |
11190 const HostPortPair host_port_; | 11186 const HostPortPair host_port_; |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12195 EXPECT_EQ("bar", foo); | 12191 EXPECT_EQ("bar", foo); |
12196 } | 12192 } |
12197 | 12193 |
12198 namespace { | 12194 namespace { |
12199 | 12195 |
12200 // Fake HttpStreamBase that simply records calls to SetPriority(). | 12196 // Fake HttpStreamBase that simply records calls to SetPriority(). |
12201 class FakeStream : public HttpStreamBase, | 12197 class FakeStream : public HttpStreamBase, |
12202 public base::SupportsWeakPtr<FakeStream> { | 12198 public base::SupportsWeakPtr<FakeStream> { |
12203 public: | 12199 public: |
12204 explicit FakeStream(RequestPriority priority) : priority_(priority) {} | 12200 explicit FakeStream(RequestPriority priority) : priority_(priority) {} |
12205 virtual ~FakeStream() {} | 12201 ~FakeStream() override {} |
12206 | 12202 |
12207 RequestPriority priority() const { return priority_; } | 12203 RequestPriority priority() const { return priority_; } |
12208 | 12204 |
12209 virtual int InitializeStream(const HttpRequestInfo* request_info, | 12205 int InitializeStream(const HttpRequestInfo* request_info, |
12210 RequestPriority priority, | 12206 RequestPriority priority, |
12211 const BoundNetLog& net_log, | 12207 const BoundNetLog& net_log, |
12212 const CompletionCallback& callback) override { | 12208 const CompletionCallback& callback) override { |
12213 return ERR_IO_PENDING; | 12209 return ERR_IO_PENDING; |
12214 } | 12210 } |
12215 | 12211 |
12216 virtual int SendRequest(const HttpRequestHeaders& request_headers, | 12212 int SendRequest(const HttpRequestHeaders& request_headers, |
12217 HttpResponseInfo* response, | 12213 HttpResponseInfo* response, |
12218 const CompletionCallback& callback) override { | 12214 const CompletionCallback& callback) override { |
12219 ADD_FAILURE(); | 12215 ADD_FAILURE(); |
12220 return ERR_UNEXPECTED; | 12216 return ERR_UNEXPECTED; |
12221 } | 12217 } |
12222 | 12218 |
12223 virtual int ReadResponseHeaders(const CompletionCallback& callback) override { | 12219 int ReadResponseHeaders(const CompletionCallback& callback) override { |
12224 ADD_FAILURE(); | 12220 ADD_FAILURE(); |
12225 return ERR_UNEXPECTED; | 12221 return ERR_UNEXPECTED; |
12226 } | 12222 } |
12227 | 12223 |
12228 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, | 12224 int ReadResponseBody(IOBuffer* buf, |
12229 const CompletionCallback& callback) override { | 12225 int buf_len, |
| 12226 const CompletionCallback& callback) override { |
12230 ADD_FAILURE(); | 12227 ADD_FAILURE(); |
12231 return ERR_UNEXPECTED; | 12228 return ERR_UNEXPECTED; |
12232 } | 12229 } |
12233 | 12230 |
12234 virtual void Close(bool not_reusable) override {} | 12231 void Close(bool not_reusable) override {} |
12235 | 12232 |
12236 virtual bool IsResponseBodyComplete() const override { | 12233 bool IsResponseBodyComplete() const override { |
12237 ADD_FAILURE(); | 12234 ADD_FAILURE(); |
12238 return false; | 12235 return false; |
12239 } | 12236 } |
12240 | 12237 |
12241 virtual bool CanFindEndOfResponse() const override { | 12238 bool CanFindEndOfResponse() const override { return false; } |
12242 return false; | |
12243 } | |
12244 | 12239 |
12245 virtual bool IsConnectionReused() const override { | 12240 bool IsConnectionReused() const override { |
12246 ADD_FAILURE(); | 12241 ADD_FAILURE(); |
12247 return false; | 12242 return false; |
12248 } | 12243 } |
12249 | 12244 |
12250 virtual void SetConnectionReused() override { | 12245 void SetConnectionReused() override { ADD_FAILURE(); } |
12251 ADD_FAILURE(); | |
12252 } | |
12253 | 12246 |
12254 virtual bool IsConnectionReusable() const override { | 12247 bool IsConnectionReusable() const override { |
12255 ADD_FAILURE(); | 12248 ADD_FAILURE(); |
12256 return false; | 12249 return false; |
12257 } | 12250 } |
12258 | 12251 |
12259 virtual int64 GetTotalReceivedBytes() const override { | 12252 int64 GetTotalReceivedBytes() const override { |
12260 ADD_FAILURE(); | 12253 ADD_FAILURE(); |
12261 return 0; | 12254 return 0; |
12262 } | 12255 } |
12263 | 12256 |
12264 virtual bool GetLoadTimingInfo( | 12257 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override { |
12265 LoadTimingInfo* load_timing_info) const override { | |
12266 ADD_FAILURE(); | 12258 ADD_FAILURE(); |
12267 return false; | 12259 return false; |
12268 } | 12260 } |
12269 | 12261 |
12270 virtual void GetSSLInfo(SSLInfo* ssl_info) override { | 12262 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); } |
| 12263 |
| 12264 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { |
12271 ADD_FAILURE(); | 12265 ADD_FAILURE(); |
12272 } | 12266 } |
12273 | 12267 |
12274 virtual void GetSSLCertRequestInfo( | 12268 bool IsSpdyHttpStream() const override { |
12275 SSLCertRequestInfo* cert_request_info) override { | |
12276 ADD_FAILURE(); | |
12277 } | |
12278 | |
12279 virtual bool IsSpdyHttpStream() const override { | |
12280 ADD_FAILURE(); | 12269 ADD_FAILURE(); |
12281 return false; | 12270 return false; |
12282 } | 12271 } |
12283 | 12272 |
12284 virtual void Drain(HttpNetworkSession* session) override { | 12273 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); } |
12285 ADD_FAILURE(); | |
12286 } | |
12287 | 12274 |
12288 virtual void SetPriority(RequestPriority priority) override { | 12275 void SetPriority(RequestPriority priority) override { priority_ = priority; } |
12289 priority_ = priority; | |
12290 } | |
12291 | 12276 |
12292 private: | 12277 private: |
12293 RequestPriority priority_; | 12278 RequestPriority priority_; |
12294 | 12279 |
12295 DISALLOW_COPY_AND_ASSIGN(FakeStream); | 12280 DISALLOW_COPY_AND_ASSIGN(FakeStream); |
12296 }; | 12281 }; |
12297 | 12282 |
12298 // Fake HttpStreamRequest that simply records calls to SetPriority() | 12283 // Fake HttpStreamRequest that simply records calls to SetPriority() |
12299 // and vends FakeStreams with its current priority. | 12284 // and vends FakeStreams with its current priority. |
12300 class FakeStreamRequest : public HttpStreamRequest, | 12285 class FakeStreamRequest : public HttpStreamRequest, |
12301 public base::SupportsWeakPtr<FakeStreamRequest> { | 12286 public base::SupportsWeakPtr<FakeStreamRequest> { |
12302 public: | 12287 public: |
12303 FakeStreamRequest(RequestPriority priority, | 12288 FakeStreamRequest(RequestPriority priority, |
12304 HttpStreamRequest::Delegate* delegate) | 12289 HttpStreamRequest::Delegate* delegate) |
12305 : priority_(priority), | 12290 : priority_(priority), |
12306 delegate_(delegate), | 12291 delegate_(delegate), |
12307 websocket_stream_create_helper_(NULL) {} | 12292 websocket_stream_create_helper_(NULL) {} |
12308 | 12293 |
12309 FakeStreamRequest(RequestPriority priority, | 12294 FakeStreamRequest(RequestPriority priority, |
12310 HttpStreamRequest::Delegate* delegate, | 12295 HttpStreamRequest::Delegate* delegate, |
12311 WebSocketHandshakeStreamBase::CreateHelper* create_helper) | 12296 WebSocketHandshakeStreamBase::CreateHelper* create_helper) |
12312 : priority_(priority), | 12297 : priority_(priority), |
12313 delegate_(delegate), | 12298 delegate_(delegate), |
12314 websocket_stream_create_helper_(create_helper) {} | 12299 websocket_stream_create_helper_(create_helper) {} |
12315 | 12300 |
12316 virtual ~FakeStreamRequest() {} | 12301 ~FakeStreamRequest() override {} |
12317 | 12302 |
12318 RequestPriority priority() const { return priority_; } | 12303 RequestPriority priority() const { return priority_; } |
12319 | 12304 |
12320 const WebSocketHandshakeStreamBase::CreateHelper* | 12305 const WebSocketHandshakeStreamBase::CreateHelper* |
12321 websocket_stream_create_helper() const { | 12306 websocket_stream_create_helper() const { |
12322 return websocket_stream_create_helper_; | 12307 return websocket_stream_create_helper_; |
12323 } | 12308 } |
12324 | 12309 |
12325 // Create a new FakeStream and pass it to the request's | 12310 // Create a new FakeStream and pass it to the request's |
12326 // delegate. Returns a weak pointer to the FakeStream. | 12311 // delegate. Returns a weak pointer to the FakeStream. |
12327 base::WeakPtr<FakeStream> FinishStreamRequest() { | 12312 base::WeakPtr<FakeStream> FinishStreamRequest() { |
12328 FakeStream* fake_stream = new FakeStream(priority_); | 12313 FakeStream* fake_stream = new FakeStream(priority_); |
12329 // Do this before calling OnStreamReady() as OnStreamReady() may | 12314 // Do this before calling OnStreamReady() as OnStreamReady() may |
12330 // immediately delete |fake_stream|. | 12315 // immediately delete |fake_stream|. |
12331 base::WeakPtr<FakeStream> weak_stream = fake_stream->AsWeakPtr(); | 12316 base::WeakPtr<FakeStream> weak_stream = fake_stream->AsWeakPtr(); |
12332 delegate_->OnStreamReady(SSLConfig(), ProxyInfo(), fake_stream); | 12317 delegate_->OnStreamReady(SSLConfig(), ProxyInfo(), fake_stream); |
12333 return weak_stream; | 12318 return weak_stream; |
12334 } | 12319 } |
12335 | 12320 |
12336 virtual int RestartTunnelWithProxyAuth( | 12321 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials) override { |
12337 const AuthCredentials& credentials) override { | |
12338 ADD_FAILURE(); | 12322 ADD_FAILURE(); |
12339 return ERR_UNEXPECTED; | 12323 return ERR_UNEXPECTED; |
12340 } | 12324 } |
12341 | 12325 |
12342 virtual LoadState GetLoadState() const override { | 12326 LoadState GetLoadState() const override { |
12343 ADD_FAILURE(); | 12327 ADD_FAILURE(); |
12344 return LoadState(); | 12328 return LoadState(); |
12345 } | 12329 } |
12346 | 12330 |
12347 virtual void SetPriority(RequestPriority priority) override { | 12331 void SetPriority(RequestPriority priority) override { priority_ = priority; } |
12348 priority_ = priority; | |
12349 } | |
12350 | 12332 |
12351 virtual bool was_npn_negotiated() const override { | 12333 bool was_npn_negotiated() const override { return false; } |
12352 return false; | |
12353 } | |
12354 | 12334 |
12355 virtual NextProto protocol_negotiated() const override { | 12335 NextProto protocol_negotiated() const override { return kProtoUnknown; } |
12356 return kProtoUnknown; | |
12357 } | |
12358 | 12336 |
12359 virtual bool using_spdy() const override { | 12337 bool using_spdy() const override { return false; } |
12360 return false; | |
12361 } | |
12362 | 12338 |
12363 private: | 12339 private: |
12364 RequestPriority priority_; | 12340 RequestPriority priority_; |
12365 HttpStreamRequest::Delegate* const delegate_; | 12341 HttpStreamRequest::Delegate* const delegate_; |
12366 WebSocketHandshakeStreamBase::CreateHelper* websocket_stream_create_helper_; | 12342 WebSocketHandshakeStreamBase::CreateHelper* websocket_stream_create_helper_; |
12367 | 12343 |
12368 DISALLOW_COPY_AND_ASSIGN(FakeStreamRequest); | 12344 DISALLOW_COPY_AND_ASSIGN(FakeStreamRequest); |
12369 }; | 12345 }; |
12370 | 12346 |
12371 // Fake HttpStreamFactory that vends FakeStreamRequests. | 12347 // Fake HttpStreamFactory that vends FakeStreamRequests. |
12372 class FakeStreamFactory : public HttpStreamFactory { | 12348 class FakeStreamFactory : public HttpStreamFactory { |
12373 public: | 12349 public: |
12374 FakeStreamFactory() {} | 12350 FakeStreamFactory() {} |
12375 virtual ~FakeStreamFactory() {} | 12351 ~FakeStreamFactory() override {} |
12376 | 12352 |
12377 // Returns a WeakPtr<> to the last HttpStreamRequest returned by | 12353 // Returns a WeakPtr<> to the last HttpStreamRequest returned by |
12378 // RequestStream() (which may be NULL if it was destroyed already). | 12354 // RequestStream() (which may be NULL if it was destroyed already). |
12379 base::WeakPtr<FakeStreamRequest> last_stream_request() { | 12355 base::WeakPtr<FakeStreamRequest> last_stream_request() { |
12380 return last_stream_request_; | 12356 return last_stream_request_; |
12381 } | 12357 } |
12382 | 12358 |
12383 virtual HttpStreamRequest* RequestStream( | 12359 HttpStreamRequest* RequestStream(const HttpRequestInfo& info, |
12384 const HttpRequestInfo& info, | 12360 RequestPriority priority, |
12385 RequestPriority priority, | 12361 const SSLConfig& server_ssl_config, |
12386 const SSLConfig& server_ssl_config, | 12362 const SSLConfig& proxy_ssl_config, |
12387 const SSLConfig& proxy_ssl_config, | 12363 HttpStreamRequest::Delegate* delegate, |
12388 HttpStreamRequest::Delegate* delegate, | 12364 const BoundNetLog& net_log) override { |
12389 const BoundNetLog& net_log) override { | |
12390 FakeStreamRequest* fake_request = new FakeStreamRequest(priority, delegate); | 12365 FakeStreamRequest* fake_request = new FakeStreamRequest(priority, delegate); |
12391 last_stream_request_ = fake_request->AsWeakPtr(); | 12366 last_stream_request_ = fake_request->AsWeakPtr(); |
12392 return fake_request; | 12367 return fake_request; |
12393 } | 12368 } |
12394 | 12369 |
12395 virtual HttpStreamRequest* RequestWebSocketHandshakeStream( | 12370 HttpStreamRequest* RequestWebSocketHandshakeStream( |
12396 const HttpRequestInfo& info, | 12371 const HttpRequestInfo& info, |
12397 RequestPriority priority, | 12372 RequestPriority priority, |
12398 const SSLConfig& server_ssl_config, | 12373 const SSLConfig& server_ssl_config, |
12399 const SSLConfig& proxy_ssl_config, | 12374 const SSLConfig& proxy_ssl_config, |
12400 HttpStreamRequest::Delegate* delegate, | 12375 HttpStreamRequest::Delegate* delegate, |
12401 WebSocketHandshakeStreamBase::CreateHelper* create_helper, | 12376 WebSocketHandshakeStreamBase::CreateHelper* create_helper, |
12402 const BoundNetLog& net_log) override { | 12377 const BoundNetLog& net_log) override { |
12403 FakeStreamRequest* fake_request = | 12378 FakeStreamRequest* fake_request = |
12404 new FakeStreamRequest(priority, delegate, create_helper); | 12379 new FakeStreamRequest(priority, delegate, create_helper); |
12405 last_stream_request_ = fake_request->AsWeakPtr(); | 12380 last_stream_request_ = fake_request->AsWeakPtr(); |
12406 return fake_request; | 12381 return fake_request; |
12407 } | 12382 } |
12408 | 12383 |
12409 virtual void PreconnectStreams(int num_streams, | 12384 void PreconnectStreams(int num_streams, |
12410 const HttpRequestInfo& info, | 12385 const HttpRequestInfo& info, |
12411 RequestPriority priority, | 12386 RequestPriority priority, |
12412 const SSLConfig& server_ssl_config, | 12387 const SSLConfig& server_ssl_config, |
12413 const SSLConfig& proxy_ssl_config) override { | 12388 const SSLConfig& proxy_ssl_config) override { |
12414 ADD_FAILURE(); | 12389 ADD_FAILURE(); |
12415 } | 12390 } |
12416 | 12391 |
12417 virtual const HostMappingRules* GetHostMappingRules() const override { | 12392 const HostMappingRules* GetHostMappingRules() const override { |
12418 ADD_FAILURE(); | 12393 ADD_FAILURE(); |
12419 return NULL; | 12394 return NULL; |
12420 } | 12395 } |
12421 | 12396 |
12422 private: | 12397 private: |
12423 base::WeakPtr<FakeStreamRequest> last_stream_request_; | 12398 base::WeakPtr<FakeStreamRequest> last_stream_request_; |
12424 | 12399 |
12425 DISALLOW_COPY_AND_ASSIGN(FakeStreamFactory); | 12400 DISALLOW_COPY_AND_ASSIGN(FakeStreamFactory); |
12426 }; | 12401 }; |
12427 | 12402 |
12428 // TODO(yhirano): Split this class out into a net/websockets file, if it is | 12403 // TODO(yhirano): Split this class out into a net/websockets file, if it is |
12429 // worth doing. | 12404 // worth doing. |
12430 class FakeWebSocketStreamCreateHelper : | 12405 class FakeWebSocketStreamCreateHelper : |
12431 public WebSocketHandshakeStreamBase::CreateHelper { | 12406 public WebSocketHandshakeStreamBase::CreateHelper { |
12432 public: | 12407 public: |
12433 virtual WebSocketHandshakeStreamBase* CreateBasicStream( | 12408 WebSocketHandshakeStreamBase* CreateBasicStream( |
12434 scoped_ptr<ClientSocketHandle> connection, | 12409 scoped_ptr<ClientSocketHandle> connection, |
12435 bool using_proxy) override { | 12410 bool using_proxy) override { |
12436 NOTREACHED(); | 12411 NOTREACHED(); |
12437 return NULL; | 12412 return NULL; |
12438 } | 12413 } |
12439 | 12414 |
12440 virtual WebSocketHandshakeStreamBase* CreateSpdyStream( | 12415 WebSocketHandshakeStreamBase* CreateSpdyStream( |
12441 const base::WeakPtr<SpdySession>& session, | 12416 const base::WeakPtr<SpdySession>& session, |
12442 bool use_relative_url) override { | 12417 bool use_relative_url) override { |
12443 NOTREACHED(); | 12418 NOTREACHED(); |
12444 return NULL; | 12419 return NULL; |
12445 }; | 12420 }; |
12446 | 12421 |
12447 virtual ~FakeWebSocketStreamCreateHelper() {} | 12422 ~FakeWebSocketStreamCreateHelper() override {} |
12448 | 12423 |
12449 virtual scoped_ptr<WebSocketStream> Upgrade() { | 12424 virtual scoped_ptr<WebSocketStream> Upgrade() { |
12450 NOTREACHED(); | 12425 NOTREACHED(); |
12451 return scoped_ptr<WebSocketStream>(); | 12426 return scoped_ptr<WebSocketStream>(); |
12452 } | 12427 } |
12453 }; | 12428 }; |
12454 | 12429 |
12455 } // namespace | 12430 } // namespace |
12456 | 12431 |
12457 // Make sure that HttpNetworkTransaction passes on its priority to its | 12432 // Make sure that HttpNetworkTransaction passes on its priority to its |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13202 EXPECT_EQ(ERR_IO_PENDING, rv); | 13177 EXPECT_EQ(ERR_IO_PENDING, rv); |
13203 | 13178 |
13204 rv = callback.WaitForResult(); | 13179 rv = callback.WaitForResult(); |
13205 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 13180 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
13206 | 13181 |
13207 const HttpResponseInfo* response = trans->GetResponseInfo(); | 13182 const HttpResponseInfo* response = trans->GetResponseInfo(); |
13208 EXPECT_TRUE(response == NULL); | 13183 EXPECT_TRUE(response == NULL); |
13209 } | 13184 } |
13210 | 13185 |
13211 } // namespace net | 13186 } // namespace net |
OLD | NEW |