| Index: net/http/http_stream_factory_impl_request_unittest.cc
|
| diff --git a/net/http/http_stream_factory_impl_request_unittest.cc b/net/http/http_stream_factory_impl_request_unittest.cc
|
| index 06c9445170cefce394935fc4feef2753d9080231..cde44914ca418d8f5ea9a1f02d93c2b497066bae 100644
|
| --- a/net/http/http_stream_factory_impl_request_unittest.cc
|
| +++ b/net/http/http_stream_factory_impl_request_unittest.cc
|
| @@ -7,6 +7,9 @@
|
| #include <memory>
|
|
|
| #include "net/http/http_stream_factory_impl_job.h"
|
| +#include "net/http/http_stream_factory_impl_job_controller.h"
|
| +#include "net/http/http_stream_factory_impl_job_factory_impl.h"
|
| +#include "net/http/http_stream_factory_test_util.h"
|
| #include "net/proxy/proxy_info.h"
|
| #include "net/proxy/proxy_service.h"
|
| #include "net/spdy/spdy_test_util_common.h"
|
| @@ -24,48 +27,6 @@ INSTANTIATE_TEST_CASE_P(NextProto,
|
| testing::Values(kProtoSPDY31,
|
| kProtoHTTP2));
|
|
|
| -namespace {
|
| -
|
| -class DoNothingRequestDelegate : public HttpStreamRequest::Delegate {
|
| - public:
|
| - DoNothingRequestDelegate() {}
|
| -
|
| - ~DoNothingRequestDelegate() override {}
|
| -
|
| - // HttpStreamRequest::Delegate
|
| - void OnStreamReady(const SSLConfig& used_ssl_config,
|
| - const ProxyInfo& used_proxy_info,
|
| - HttpStream* stream) override {}
|
| - void OnBidirectionalStreamImplReady(
|
| - const SSLConfig& used_ssl_config,
|
| - const ProxyInfo& used_proxy_info,
|
| - BidirectionalStreamImpl* stream) override {}
|
| -
|
| - void OnWebSocketHandshakeStreamReady(
|
| - const SSLConfig& used_ssl_config,
|
| - const ProxyInfo& used_proxy_info,
|
| - WebSocketHandshakeStreamBase* stream) override {}
|
| - void OnStreamFailed(int status,
|
| - const SSLConfig& used_ssl_config,
|
| - SSLFailureState ssl_failure_state) override {}
|
| - void OnCertificateError(int status,
|
| - const SSLConfig& used_ssl_config,
|
| - const SSLInfo& ssl_info) override {}
|
| - void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
|
| - const SSLConfig& used_ssl_config,
|
| - const ProxyInfo& used_proxy_info,
|
| - HttpAuthController* auth_controller) override {}
|
| - void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
|
| - SSLCertRequestInfo* cert_info) override {}
|
| - void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
|
| - const SSLConfig& used_ssl_config,
|
| - const ProxyInfo& used_proxy_info,
|
| - HttpStream* stream) override {}
|
| - void OnQuicBroken() override {}
|
| -};
|
| -
|
| -} // namespace
|
| -
|
| // Make sure that Request passes on its priority updates to its jobs.
|
| TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
|
| SpdySessionDependencies session_deps(GetParam(),
|
| @@ -75,29 +36,39 @@ TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
|
| SpdySessionDependencies::SpdyCreateSession(&session_deps);
|
| HttpStreamFactoryImpl* factory =
|
| static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
|
| + TestHttpStreamRequestDelegate request_delegate;
|
| + HttpStreamFactoryImpl::JobFactoryImpl job_factory;
|
| + HttpStreamFactoryImpl::JobController* job_controller =
|
| + new HttpStreamFactoryImpl::JobController(factory, &request_delegate,
|
| + session.get(), &job_factory);
|
| + factory->job_controller_set_.insert(base::WrapUnique(job_controller));
|
|
|
| - DoNothingRequestDelegate request_delegate;
|
| HttpStreamFactoryImpl::Request request(
|
| - GURL(), factory, &request_delegate, NULL, BoundNetLog(),
|
| + GURL(), job_controller, &request_delegate, nullptr, BoundNetLog(),
|
| HttpStreamFactoryImpl::Request::HTTP_STREAM);
|
| + job_controller->request_ = &request;
|
|
|
| HttpRequestInfo request_info;
|
|
|
| HostPortPair server = HostPortPair::FromURL(request_info.url);
|
| - GURL original_url = factory->ApplyHostMappingRules(request_info.url, &server);
|
| + GURL original_url =
|
| + job_controller->ApplyHostMappingRules(request_info.url, &server);
|
|
|
| HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
|
| - factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
|
| - SSLConfig(), server, original_url, NULL);
|
| - request.AttachJob(job);
|
| + job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info,
|
| + DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url,
|
| + nullptr);
|
| + job_controller->main_job_.reset(job);
|
| +
|
| + job_controller->AttachJob(job);
|
| EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
|
|
|
| request.SetPriority(MEDIUM);
|
| EXPECT_EQ(MEDIUM, job->priority());
|
|
|
| // Make |job| the bound job.
|
| - request.OnStreamFailed(job, ERR_FAILED, SSLConfig(), SSL_FAILURE_NONE);
|
| -
|
| + job_controller->OnStreamFailed(job, ERR_FAILED, SSLConfig(),
|
| + SSL_FAILURE_NONE);
|
| request.SetPriority(IDLE);
|
| EXPECT_EQ(IDLE, job->priority());
|
| }
|
| @@ -115,30 +86,41 @@ TEST_P(HttpStreamFactoryImplRequestTest, DelayMainJob) {
|
|
|
| HttpStreamFactoryImpl* factory =
|
| static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
|
| + TestHttpStreamRequestDelegate request_delegate;
|
| + HttpStreamFactoryImpl::JobFactoryImpl job_factory;
|
| + HttpStreamFactoryImpl::JobController* job_controller =
|
| + new HttpStreamFactoryImpl::JobController(factory, &request_delegate,
|
| + session.get(), &job_factory);
|
| + factory->job_controller_set_.insert(base::WrapUnique(job_controller));
|
|
|
| - DoNothingRequestDelegate request_delegate;
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("http://www.google.com");
|
|
|
| HttpStreamFactoryImpl::Request request(
|
| - request_info.url, factory, &request_delegate, NULL, BoundNetLog(),
|
| - HttpStreamFactoryImpl::Request::HTTP_STREAM);
|
| + request_info.url, job_controller, &request_delegate, nullptr,
|
| + BoundNetLog(), HttpStreamFactoryImpl::Request::HTTP_STREAM);
|
| + job_controller->request_ = &request;
|
|
|
| HostPortPair server = HostPortPair::FromURL(request_info.url);
|
| - GURL original_url = factory->ApplyHostMappingRules(request_info.url, &server);
|
| + GURL original_url =
|
| + job_controller->ApplyHostMappingRules(request_info.url, &server);
|
|
|
| HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
|
| - factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
|
| - SSLConfig(), server, original_url, NULL);
|
| - request.AttachJob(job);
|
| + job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info,
|
| + DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url,
|
| + nullptr);
|
| + job_controller->main_job_.reset(job);
|
| + job_controller->AttachJob(job);
|
| EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
|
|
|
| AlternativeService alternative_service(net::NPN_HTTP_2, server);
|
| HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job(
|
| - factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
|
| - SSLConfig(), server, original_url, alternative_service, NULL);
|
| - request.AttachJob(alternative_job);
|
| + job_controller, HttpStreamFactoryImpl::ALTERNATIVE, session.get(),
|
| + request_info, DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server,
|
| + original_url, alternative_service, nullptr);
|
| + job_controller->alternative_job_.reset(alternative_job);
|
| + job_controller->AttachJob(alternative_job);
|
|
|
| job->WaitFor(alternative_job);
|
| EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_);
|
| @@ -153,7 +135,7 @@ TEST_P(HttpStreamFactoryImplRequestTest, DelayMainJob) {
|
| EXPECT_TRUE(!job->blocking_job_);
|
|
|
| // Start the |job| and verify |job|'s |wait_time_| is cleared.
|
| - job->Start(&request);
|
| + job->Start(request.stream_type());
|
|
|
| base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1));
|
| base::MessageLoop::current()->RunUntilIdle();
|
|
|