| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_stream_factory_impl_request.h" | 5 #include "net/http/http_stream_factory_impl_request.h" |
| 6 | 6 |
| 7 #include "net/http/http_stream_factory_impl_job.h" | 7 #include "net/http/http_stream_factory_impl_job.h" |
| 8 #include "net/proxy/proxy_info.h" | 8 #include "net/proxy/proxy_info.h" |
| 9 #include "net/proxy/proxy_service.h" | 9 #include "net/proxy/proxy_service.h" |
| 10 #include "net/spdy/spdy_test_util_common.h" | 10 #include "net/spdy/spdy_test_util_common.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 class HttpStreamFactoryImplRequestTest | 15 class HttpStreamFactoryImplRequestTest |
| 16 : public ::testing::Test, | 16 : public ::testing::Test, |
| 17 public ::testing::WithParamInterface<NextProto> {}; | 17 public ::testing::WithParamInterface<NextProto> {}; |
| 18 | 18 |
| 19 INSTANTIATE_TEST_CASE_P( | 19 INSTANTIATE_TEST_CASE_P(NextProto, |
| 20 NextProto, | 20 HttpStreamFactoryImplRequestTest, |
| 21 HttpStreamFactoryImplRequestTest, | 21 testing::Values(kProtoDeprecatedSPDY2, |
| 22 testing::Values(kProtoDeprecatedSPDY2, | 22 kProtoSPDY3, |
| 23 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); | 23 kProtoSPDY31, |
| 24 kProtoSPDY4)); |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 class DoNothingRequestDelegate : public HttpStreamRequest::Delegate { | 28 class DoNothingRequestDelegate : public HttpStreamRequest::Delegate { |
| 28 public: | 29 public: |
| 29 DoNothingRequestDelegate() {} | 30 DoNothingRequestDelegate() {} |
| 30 | 31 |
| 31 virtual ~DoNothingRequestDelegate() {} | 32 virtual ~DoNothingRequestDelegate() {} |
| 32 | 33 |
| 33 // HttpStreamRequest::Delegate | 34 // HttpStreamRequest::Delegate |
| 34 virtual void OnStreamReady( | 35 virtual void OnStreamReady(const SSLConfig& used_ssl_config, |
| 35 const SSLConfig& used_ssl_config, | 36 const ProxyInfo& used_proxy_info, |
| 36 const ProxyInfo& used_proxy_info, | 37 HttpStreamBase* stream) OVERRIDE {} |
| 37 HttpStreamBase* stream) OVERRIDE {} | |
| 38 virtual void OnWebSocketHandshakeStreamReady( | 38 virtual void OnWebSocketHandshakeStreamReady( |
| 39 const SSLConfig& used_ssl_config, | 39 const SSLConfig& used_ssl_config, |
| 40 const ProxyInfo& used_proxy_info, | 40 const ProxyInfo& used_proxy_info, |
| 41 WebSocketHandshakeStreamBase* stream) OVERRIDE {} | 41 WebSocketHandshakeStreamBase* stream) OVERRIDE {} |
| 42 virtual void OnStreamFailed( | 42 virtual void OnStreamFailed(int status, |
| 43 int status, | 43 const SSLConfig& used_ssl_config) OVERRIDE {} |
| 44 const SSLConfig& used_ssl_config) OVERRIDE {} | 44 virtual void OnCertificateError(int status, |
| 45 virtual void OnCertificateError( | 45 const SSLConfig& used_ssl_config, |
| 46 int status, | 46 const SSLInfo& ssl_info) OVERRIDE {} |
| 47 const SSLConfig& used_ssl_config, | |
| 48 const SSLInfo& ssl_info) OVERRIDE {} | |
| 49 virtual void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, | 47 virtual void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, |
| 50 const SSLConfig& used_ssl_config, | 48 const SSLConfig& used_ssl_config, |
| 51 const ProxyInfo& used_proxy_info, | 49 const ProxyInfo& used_proxy_info, |
| 52 HttpAuthController* auth_controller) OVERRIDE {} | 50 HttpAuthController* auth_controller) OVERRIDE {} |
| 53 virtual void OnNeedsClientAuth(const SSLConfig& used_ssl_config, | 51 virtual void OnNeedsClientAuth(const SSLConfig& used_ssl_config, |
| 54 SSLCertRequestInfo* cert_info) OVERRIDE {} | 52 SSLCertRequestInfo* cert_info) OVERRIDE {} |
| 55 virtual void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, | 53 virtual void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, |
| 56 const SSLConfig& used_ssl_config, | 54 const SSLConfig& used_ssl_config, |
| 57 const ProxyInfo& used_proxy_info, | 55 const ProxyInfo& used_proxy_info, |
| 58 HttpStreamBase* stream) OVERRIDE {} | 56 HttpStreamBase* stream) OVERRIDE {} |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 } // namespace | 59 } // namespace |
| 62 | 60 |
| 63 // Make sure that Request passes on its priority updates to its jobs. | 61 // Make sure that Request passes on its priority updates to its jobs. |
| 64 TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) { | 62 TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) { |
| 65 SpdySessionDependencies session_deps(GetParam(), | 63 SpdySessionDependencies session_deps(GetParam(), |
| 66 ProxyService::CreateDirect()); | 64 ProxyService::CreateDirect()); |
| 67 | 65 |
| 68 scoped_refptr<HttpNetworkSession> | 66 scoped_refptr<HttpNetworkSession> session( |
| 69 session(SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 67 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 70 HttpStreamFactoryImpl* factory = | 68 HttpStreamFactoryImpl* factory = |
| 71 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory()); | 69 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory()); |
| 72 | 70 |
| 73 DoNothingRequestDelegate request_delegate; | 71 DoNothingRequestDelegate request_delegate; |
| 74 HttpStreamFactoryImpl::Request request( | 72 HttpStreamFactoryImpl::Request request( |
| 75 GURL(), factory, &request_delegate, NULL, BoundNetLog()); | 73 GURL(), factory, &request_delegate, NULL, BoundNetLog()); |
| 76 | 74 |
| 77 HttpStreamFactoryImpl::Job* job = | 75 HttpStreamFactoryImpl::Job* job = |
| 78 new HttpStreamFactoryImpl::Job(factory, | 76 new HttpStreamFactoryImpl::Job(factory, |
| 79 session, | 77 session, |
| 80 HttpRequestInfo(), | 78 HttpRequestInfo(), |
| 81 DEFAULT_PRIORITY, | 79 DEFAULT_PRIORITY, |
| 82 SSLConfig(), | 80 SSLConfig(), |
| 83 SSLConfig(), | 81 SSLConfig(), |
| 84 NULL); | 82 NULL); |
| 85 request.AttachJob(job); | 83 request.AttachJob(job); |
| 86 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); | 84 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); |
| 87 | 85 |
| 88 request.SetPriority(MEDIUM); | 86 request.SetPriority(MEDIUM); |
| 89 EXPECT_EQ(MEDIUM, job->priority()); | 87 EXPECT_EQ(MEDIUM, job->priority()); |
| 90 | 88 |
| 91 // Make |job| the bound job. | 89 // Make |job| the bound job. |
| 92 request.OnStreamFailed(job, ERR_FAILED, SSLConfig()); | 90 request.OnStreamFailed(job, ERR_FAILED, SSLConfig()); |
| 93 | 91 |
| 94 request.SetPriority(IDLE); | 92 request.SetPriority(IDLE); |
| 95 EXPECT_EQ(IDLE, job->priority()); | 93 EXPECT_EQ(IDLE, job->priority()); |
| 96 } | 94 } |
| 97 | 95 |
| 98 } // namespace net | 96 } // namespace net |
| OLD | NEW |