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

Unified Diff: net/http/http_stream_factory_impl_request_unittest.cc

Issue 2073293002: Revert of JobController 1: Remove cross reference between Request, Job, and Impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_stream_factory_impl_request.cc ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e6a37d10462f1e408643c32f2fea96a228955f52..5079cc1492e8266629432061d1c74a6091157c4f 100644
--- a/net/http/http_stream_factory_impl_request_unittest.cc
+++ b/net/http/http_stream_factory_impl_request_unittest.cc
@@ -7,17 +7,12 @@
#include <memory>
#include "base/run_loop.h"
-#include "net/http/http_stream_factory_impl.h"
#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_test_util.h"
#include "net/proxy/proxy_info.h"
#include "net/proxy/proxy_service.h"
#include "net/spdy/spdy_test_util_common.h"
#include "net/ssl/ssl_failure_state.h"
#include "testing/gtest/include/gtest/gtest.h"
-
-using testing::_;
namespace net {
@@ -30,39 +25,82 @@
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(),
ProxyService::CreateDirect());
+
std::unique_ptr<HttpNetworkSession> session =
SpdySessionDependencies::SpdyCreateSession(&session_deps);
HttpStreamFactoryImpl* factory =
static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
- MockHttpStreamRequestDelegate request_delegate;
- TestJobFactory 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(),
+ HttpStreamFactoryImpl::Request::HTTP_STREAM);
HttpRequestInfo request_info;
- std::unique_ptr<HttpStreamFactoryImpl::Request> request(
- job_controller->Start(request_info, &request_delegate, nullptr,
- BoundNetLog(), HttpStreamRequest::HTTP_STREAM,
- DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
- EXPECT_TRUE(job_controller->main_job());
- EXPECT_EQ(DEFAULT_PRIORITY, job_controller->main_job()->priority());
- request->SetPriority(MEDIUM);
- EXPECT_EQ(MEDIUM, job_controller->main_job()->priority());
+ HostPortPair server = HostPortPair::FromURL(request_info.url);
+ GURL original_url = factory->ApplyHostMappingRules(request_info.url, &server);
- EXPECT_CALL(request_delegate, OnStreamFailed(_, _, SSL_FAILURE_NONE))
- .Times(1);
- job_controller->OnStreamFailed(job_factory.main_job(), ERR_FAILED,
- SSLConfig(), SSL_FAILURE_NONE);
+ HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
+ factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
+ SSLConfig(), server, original_url, NULL);
+ request.AttachJob(job);
+ EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
- request->SetPriority(IDLE);
- EXPECT_EQ(IDLE, job_controller->main_job()->priority());
+ request.SetPriority(MEDIUM);
+ EXPECT_EQ(MEDIUM, job->priority());
+
+ // Make |job| the bound job.
+ request.OnStreamFailed(job, ERR_FAILED, SSLConfig(), SSL_FAILURE_NONE);
+
+ request.SetPriority(IDLE);
+ EXPECT_EQ(IDLE, job->priority());
}
TEST_P(HttpStreamFactoryImplRequestTest, DelayMainJob) {
@@ -78,42 +116,30 @@
HttpStreamFactoryImpl* factory =
static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
- MockHttpStreamRequestDelegate request_delegate;
- HttpStreamFactoryImpl::JobFactory* job_factory =
- HttpStreamFactoryImplPeer::GetDefaultJobFactory(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, job_controller, &request_delegate, nullptr,
- BoundNetLog(), HttpStreamFactoryImpl::Request::HTTP_STREAM);
- job_controller->request_ = &request;
+ request_info.url, factory, &request_delegate, NULL, BoundNetLog(),
+ HttpStreamFactoryImpl::Request::HTTP_STREAM);
HostPortPair server = HostPortPair::FromURL(request_info.url);
- GURL original_url =
- job_controller->ApplyHostMappingRules(request_info.url, &server);
+ GURL original_url = factory->ApplyHostMappingRules(request_info.url, &server);
HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::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);
+ factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
+ SSLConfig(), server, original_url, NULL);
+ request.AttachJob(job);
EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
AlternativeService alternative_service(net::NPN_HTTP_2, server);
HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::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);
+ factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
+ SSLConfig(), server, original_url, alternative_service, NULL);
+ request.AttachJob(alternative_job);
job->WaitFor(alternative_job);
EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_);
@@ -128,7 +154,7 @@
EXPECT_TRUE(!job->blocking_job_);
// Start the |job| and verify |job|'s |wait_time_| is cleared.
- job->Start(request.stream_type());
+ job->Start(&request);
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1));
base::RunLoop().RunUntilIdle();
« no previous file with comments | « net/http/http_stream_factory_impl_request.cc ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698