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

Unified Diff: net/http/http_stream_factory_impl_request_unittest.cc

Issue 1941083002: JobController 1: Adding a new class HttpStreamFactoryImpl::JobController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment fix Created 4 years, 7 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
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..2bf13f731c325a15e35cec3f14925ca77f9a43c7 100644
--- a/net/http/http_stream_factory_impl_request_unittest.cc
+++ b/net/http/http_stream_factory_impl_request_unittest.cc
@@ -7,6 +7,7 @@
#include <memory>
#include "net/http/http_stream_factory_impl_job.h"
+#include "net/http/http_stream_factory_impl_job_controller.h"
#include "net/proxy/proxy_info.h"
#include "net/proxy/proxy_service.h"
#include "net/spdy/spdy_test_util_common.h"
@@ -75,29 +76,36 @@ TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
SpdySessionDependencies::SpdyCreateSession(&session_deps);
HttpStreamFactoryImpl* factory =
static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
-
DoNothingRequestDelegate request_delegate;
+ HttpStreamFactoryImpl::JobController* job_controller =
+ new HttpStreamFactoryImpl::JobController(factory, &request_delegate,
+ session.get());
+ factory->job_controller_set_.insert(base::WrapUnique(job_controller));
+
HttpStreamFactoryImpl::Request request(
- GURL(), factory, &request_delegate, NULL, BoundNetLog(),
+ GURL(), job_controller, &request_delegate, NULL, 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, NULL);
+ 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 +123,39 @@ TEST_P(HttpStreamFactoryImplRequestTest, DelayMainJob) {
HttpStreamFactoryImpl* factory =
static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
-
DoNothingRequestDelegate request_delegate;
+ HttpStreamFactoryImpl::JobController* job_controller =
+ new HttpStreamFactoryImpl::JobController(factory, &request_delegate,
+ session.get());
+ factory->job_controller_set_.insert(base::WrapUnique(job_controller));
+
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(),
+ request_info.url, job_controller, &request_delegate, NULL, 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, NULL);
+ 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, NULL);
+ 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 +170,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();

Powered by Google App Engine
This is Rietveld 408576698