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

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: sync to JobController1, and move DoWaitForJob to JobController 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 unified diff | Download patch
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/http/http_stream_factory_impl_job.h" 9 #include "net/http/http_stream_factory_impl_job.h"
10 #include "net/http/http_stream_factory_impl_job_controller.h" 10 #include "net/http/http_stream_factory_impl_job_controller.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 HostPortPair server = HostPortPair::FromURL(request_info.url); 92 HostPortPair server = HostPortPair::FromURL(request_info.url);
93 GURL original_url = 93 GURL original_url =
94 job_controller->ApplyHostMappingRules(request_info.url, &server); 94 job_controller->ApplyHostMappingRules(request_info.url, &server);
95 95
96 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job( 96 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
97 job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info, 97 job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info,
98 DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url, NULL); 98 DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url, NULL);
99 job_controller->main_job_.reset(job); 99 job_controller->main_job_.reset(job);
100 job_controller->AttachJob(job); 100 job_controller->AttachJob(job);
101
101 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); 102 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
102 103
103 request.SetPriority(MEDIUM); 104 request.SetPriority(MEDIUM);
104 EXPECT_EQ(MEDIUM, job->priority()); 105 EXPECT_EQ(MEDIUM, job->priority());
105 106
106 // Make |job| the bound job. 107 // Make |job| the bound job.
107 job_controller->OnStreamFailed(job, ERR_FAILED, SSLConfig(), 108 job_controller->OnStreamFailed(job, ERR_FAILED, SSLConfig(),
108 SSL_FAILURE_NONE); 109 SSL_FAILURE_NONE);
109 request.SetPriority(IDLE); 110 request.SetPriority(IDLE);
110 EXPECT_EQ(IDLE, job->priority()); 111 EXPECT_EQ(IDLE, job->priority());
(...skipping 29 matching lines...) Expand all
140 141
141 HostPortPair server = HostPortPair::FromURL(request_info.url); 142 HostPortPair server = HostPortPair::FromURL(request_info.url);
142 GURL original_url = 143 GURL original_url =
143 job_controller->ApplyHostMappingRules(request_info.url, &server); 144 job_controller->ApplyHostMappingRules(request_info.url, &server);
144 145
145 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job( 146 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
146 job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info, 147 job_controller, HttpStreamFactoryImpl::MAIN, session.get(), request_info,
147 DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url, NULL); 148 DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, original_url, NULL);
148 job_controller->main_job_.reset(job); 149 job_controller->main_job_.reset(job);
149 job_controller->AttachJob(job); 150 job_controller->AttachJob(job);
151
150 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); 152 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
151 153
152 AlternativeService alternative_service(net::NPN_HTTP_2, server); 154 AlternativeService alternative_service(net::NPN_HTTP_2, server);
153 HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job( 155 HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job(
154 job_controller, HttpStreamFactoryImpl::ALTERNATIVE, session.get(), 156 job_controller, HttpStreamFactoryImpl::ALTERNATIVE, session.get(),
155 request_info, DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server, 157 request_info, DEFAULT_PRIORITY, SSLConfig(), SSLConfig(), server,
156 original_url, alternative_service, NULL); 158 original_url, alternative_service, NULL);
157 job_controller->alternative_job_.reset(alternative_job); 159 job_controller->alternative_job_.reset(alternative_job);
158 job_controller->AttachJob(alternative_job); 160 job_controller->AttachJob(alternative_job);
159 161
160 job->WaitFor(alternative_job); 162 job_controller->blocking_ = true;
161 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_); 163 EXPECT_EQ(HttpStreamFactoryImpl::STATE_NONE, job->next_state_);
162 164
163 // Test |alternative_job| resuming the |job| after delay. 165 // Test |alternative_job| resuming the |job| after delay.
164 int wait_time = 1; 166 int wait_time = 1;
165 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(wait_time); 167 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(wait_time);
166 job->Resume(alternative_job, delay); 168 job_controller->MaybeResumeOtherJob(alternative_job, delay);
167 169
168 // Verify |job| has |wait_time_| and there is no |blocking_job_| 170 // Verify |job| has |wait_time_| and there is no blocking job.
169 EXPECT_EQ(delay, job->wait_time_); 171 EXPECT_EQ(delay, job->wait_time_);
170 EXPECT_TRUE(!job->blocking_job_); 172 EXPECT_TRUE(!job_controller->blocking());
171 173
172 // Start the |job| and verify |job|'s |wait_time_| is cleared. 174 // Start the |job| and verify |job|'s |wait_time_| is cleared.
173 job->Start(request.stream_type()); 175 job->Start(request.stream_type());
174 176
175 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1)); 177 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1));
176 base::MessageLoop::current()->RunUntilIdle(); 178 base::MessageLoop::current()->RunUntilIdle();
177 179
178 EXPECT_NE(delay, job->wait_time_); 180 EXPECT_NE(delay, job->wait_time_);
179 EXPECT_TRUE(job->wait_time_.is_zero()); 181 EXPECT_TRUE(job->wait_time_.is_zero());
180 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_INIT_CONNECTION_COMPLETE, 182 EXPECT_EQ(HttpStreamFactoryImpl::STATE_INIT_CONNECTION_COMPLETE,
181 job->next_state_); 183 job->next_state_);
182 } 184 }
183 185
184 } // namespace net 186 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698