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

Side by Side Diff: net/http/http_stream_factory_impl_request_unittest.cc

Issue 1952423002: JobController 2: Remove reference between HttpStreamFactoryImpl::Jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Job_Controller_1
Patch Set: Remove ResumeAfterDelay Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "net/http/http_stream_factory_impl.h" 10 #include "net/http/http_stream_factory_impl.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 HostPortPair server = HostPortPair::FromURL(request_info.url); 98 HostPortPair server = HostPortPair::FromURL(request_info.url);
99 GURL original_url = 99 GURL original_url =
100 job_controller->ApplyHostMappingRules(request_info.url, &server); 100 job_controller->ApplyHostMappingRules(request_info.url, &server);
101 101
102 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job( 102 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
103 job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info, 103 job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info,
104 DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url, 104 DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url,
105 nullptr); 105 nullptr);
106 job_controller->main_job_.reset(job); 106 job_controller->main_job_.reset(job);
107 job_controller->AttachJob(job); 107 job_controller->AttachJob(job);
108
108 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); 109 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
109 110
110 AlternativeService alternative_service(net::NPN_HTTP_2, server); 111 AlternativeService alternative_service(net::NPN_HTTP_2, server);
111 HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job( 112 HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job(
112 job_controller, HttpStreamFactoryImpl::ALTERNATIVE, session.get(), 113 job_controller, HttpStreamFactoryImpl::ALTERNATIVE, session.get(),
113 request_info, DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, 114 request_info, DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server,
114 original_url, alternative_service, nullptr); 115 original_url, alternative_service, nullptr);
115 job_controller->alternative_job_.reset(alternative_job); 116 job_controller->alternative_job_.reset(alternative_job);
116 job_controller->AttachJob(alternative_job); 117 job_controller->AttachJob(alternative_job);
117 118
118 job->WaitFor(alternative_job); 119 job_controller->main_job_is_blocked_ = true;
119 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_); 120 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_);
120 121
121 // Test |alternative_job| resuming the |job| after delay. 122 // Test |alternative_job| resuming the |job| after delay.
122 int wait_time = 1; 123 int wait_time = 1;
123 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(wait_time); 124 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(wait_time);
124 job->Resume(alternative_job, delay); 125 job_controller->set_wait_time_for_main_job(delay);
126 job_controller->MaybeResumeMainJob(alternative_job, delay);
125 127
126 // Verify |job| has |wait_time_| and there is no |blocking_job_| 128 // Verify |job| has |wait_time_| and there is no blocking job.
127 EXPECT_EQ(delay, job->wait_time_); 129 EXPECT_EQ(delay, job_controller->wait_time_for_main_job());
128 EXPECT_TRUE(!job->blocking_job_); 130 EXPECT_TRUE(!job_controller->main_job_is_blocked());
129 131
130 // Start the |job| and verify |job|'s |wait_time_| is cleared. 132 // Start the |job| and verify |job|'s |wait_time_| is cleared.
131 job->Start(request.stream_type()); 133 job->Start(request.stream_type());
132 134
133 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1)); 135 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1));
134 base::RunLoop().RunUntilIdle(); 136 base::RunLoop().RunUntilIdle();
135 137
136 EXPECT_NE(delay, job->wait_time_); 138 EXPECT_NE(delay, job_controller->wait_time_for_main_job());
137 EXPECT_TRUE(job->wait_time_.is_zero()); 139 EXPECT_TRUE(job_controller->wait_time_for_main_job().is_zero());
138 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_INIT_CONNECTION_COMPLETE, 140 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_INIT_CONNECTION_COMPLETE,
139 job->next_state_); 141 job->next_state_);
140 } 142 }
141 143
142 } // namespace net 144 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698