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

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

Issue 2621983004: Improve HttpStreamFactory NetLog events (Closed)
Patch Set: Created 3 years, 11 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_job_controller.h" 5 #include "net/http/http_stream_factory_impl_job_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 if (use_alternative_proxy) { 131 if (use_alternative_proxy) {
132 std::unique_ptr<ProxyService> proxy_service = 132 std::unique_ptr<ProxyService> proxy_service =
133 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); 133 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443");
134 session_deps_.proxy_service = std::move(proxy_service); 134 session_deps_.proxy_service = std::move(proxy_service);
135 } 135 }
136 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 136 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
137 factory_ = 137 factory_ =
138 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); 138 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory());
139 job_controller_ = new HttpStreamFactoryImpl::JobController( 139 job_controller_ = new HttpStreamFactoryImpl::JobController(
140 factory_, &request_delegate_, session_.get(), &job_factory_); 140 factory_, &request_delegate_, session_.get(), &job_factory_,
141 /*is_preconnect=*/false, net_log_);
141 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); 142 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_);
142 } 143 }
143 144
144 TestProxyDelegate* test_proxy_delegate() const { 145 TestProxyDelegate* test_proxy_delegate() const {
145 return test_proxy_delegate_; 146 return test_proxy_delegate_;
146 } 147 }
147 148
148 ~HttpStreamFactoryImplJobControllerTest() {} 149 ~HttpStreamFactoryImplJobControllerTest() {}
149 150
150 void SetAlternativeService(const HttpRequestInfo& request_info, 151 void SetAlternativeService(const HttpRequestInfo& request_info,
(...skipping 18 matching lines...) Expand all
169 170
170 // Not owned by |this|. 171 // Not owned by |this|.
171 TestProxyDelegate* test_proxy_delegate_; 172 TestProxyDelegate* test_proxy_delegate_;
172 TestJobFactory job_factory_; 173 TestJobFactory job_factory_;
173 MockHttpStreamRequestDelegate request_delegate_; 174 MockHttpStreamRequestDelegate request_delegate_;
174 SpdySessionDependencies session_deps_; 175 SpdySessionDependencies session_deps_;
175 std::unique_ptr<HttpNetworkSession> session_; 176 std::unique_ptr<HttpNetworkSession> session_;
176 HttpStreamFactoryImpl* factory_; 177 HttpStreamFactoryImpl* factory_;
177 HttpStreamFactoryImpl::JobController* job_controller_; 178 HttpStreamFactoryImpl::JobController* job_controller_;
178 std::unique_ptr<HttpStreamFactoryImpl::Request> request_; 179 std::unique_ptr<HttpStreamFactoryImpl::Request> request_;
180 const NetLogWithSource net_log_;
179 181
180 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest); 182 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest);
181 }; 183 };
182 184
183 TEST_F(HttpStreamFactoryImplJobControllerTest, 185 TEST_F(HttpStreamFactoryImplJobControllerTest,
184 OnStreamFailedWithNoAlternativeJob) { 186 OnStreamFailedWithNoAlternativeJob) {
185 ProxyConfig proxy_config; 187 ProxyConfig proxy_config;
186 proxy_config.set_auto_detect(true); 188 proxy_config.set_auto_detect(true);
187 // Use asynchronous proxy resolver. 189 // Use asynchronous proxy resolver.
188 MockAsyncProxyResolverFactory* proxy_resolver_factory = 190 MockAsyncProxyResolverFactory* proxy_resolver_factory =
189 new MockAsyncProxyResolverFactory(false); 191 new MockAsyncProxyResolverFactory(false);
190 session_deps_.proxy_service.reset( 192 session_deps_.proxy_service.reset(
191 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), 193 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
192 base::WrapUnique(proxy_resolver_factory), nullptr)); 194 base::WrapUnique(proxy_resolver_factory), nullptr));
193 Initialize(false); 195 Initialize(false);
194 196
195 HttpRequestInfo request_info; 197 HttpRequestInfo request_info;
196 request_info.method = "GET"; 198 request_info.method = "GET";
197 request_info.url = GURL("http://www.google.com"); 199 request_info.url = GURL("http://www.google.com");
198 200
199 request_.reset( 201 request_.reset(job_controller_->Start(
200 job_controller_->Start(request_info, &request_delegate_, nullptr, 202 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
201 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 203 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
202 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
203 204
204 EXPECT_TRUE(job_controller_->main_job()); 205 EXPECT_TRUE(job_controller_->main_job());
205 206
206 // There's no other alternative job. Thus when stream failed, it should 207 // There's no other alternative job. Thus when stream failed, it should
207 // notify Request of the stream failure. 208 // notify Request of the stream failure.
208 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); 209 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1);
209 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, 210 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED,
210 SSLConfig()); 211 SSLConfig());
211 } 212 }
212 213
213 TEST_F(HttpStreamFactoryImplJobControllerTest, 214 TEST_F(HttpStreamFactoryImplJobControllerTest,
214 OnStreamReadyWithNoAlternativeJob) { 215 OnStreamReadyWithNoAlternativeJob) {
215 ProxyConfig proxy_config; 216 ProxyConfig proxy_config;
216 proxy_config.set_auto_detect(true); 217 proxy_config.set_auto_detect(true);
217 // Use asynchronous proxy resolver. 218 // Use asynchronous proxy resolver.
218 MockAsyncProxyResolverFactory* proxy_resolver_factory = 219 MockAsyncProxyResolverFactory* proxy_resolver_factory =
219 new MockAsyncProxyResolverFactory(false); 220 new MockAsyncProxyResolverFactory(false);
220 session_deps_.proxy_service.reset( 221 session_deps_.proxy_service.reset(
221 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), 222 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
222 base::WrapUnique(proxy_resolver_factory), nullptr)); 223 base::WrapUnique(proxy_resolver_factory), nullptr));
223 Initialize(false); 224 Initialize(false);
224 225
225 HttpRequestInfo request_info; 226 HttpRequestInfo request_info;
226 request_info.method = "GET"; 227 request_info.method = "GET";
227 request_info.url = GURL("http://www.google.com"); 228 request_info.url = GURL("http://www.google.com");
228 229
229 request_.reset( 230 request_.reset(job_controller_->Start(
230 job_controller_->Start(request_info, &request_delegate_, nullptr, 231 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
231 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 232 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
232 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
233 233
234 // There's no other alternative job. Thus when a stream is ready, it should 234 // There's no other alternative job. Thus when a stream is ready, it should
235 // notify Request. 235 // notify Request.
236 HttpStream* http_stream = 236 HttpStream* http_stream =
237 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); 237 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false);
238 job_factory_.main_job()->SetStream(http_stream); 238 job_factory_.main_job()->SetStream(http_stream);
239 239
240 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) 240 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream))
241 .WillOnce(Invoke(DeleteHttpStreamPointer)); 241 .WillOnce(Invoke(DeleteHttpStreamPointer));
242 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig()); 242 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig());
(...skipping 13 matching lines...) Expand all
256 Initialize(false); 256 Initialize(false);
257 257
258 HttpRequestInfo request_info; 258 HttpRequestInfo request_info;
259 request_info.method = "GET"; 259 request_info.method = "GET";
260 request_info.url = GURL("https://www.google.com"); 260 request_info.url = GURL("https://www.google.com");
261 261
262 url::SchemeHostPort server(request_info.url); 262 url::SchemeHostPort server(request_info.url);
263 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 263 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
264 SetAlternativeService(request_info, alternative_service); 264 SetAlternativeService(request_info, alternative_service);
265 265
266 request_.reset( 266 request_.reset(job_controller_->Start(
267 job_controller_->Start(request_info, &request_delegate_, nullptr, 267 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
268 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 268 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
269 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
270 EXPECT_TRUE(job_controller_->main_job()); 269 EXPECT_TRUE(job_controller_->main_job());
271 EXPECT_TRUE(job_controller_->alternative_job()); 270 EXPECT_TRUE(job_controller_->alternative_job());
272 271
273 // Reset the Request will cancel all the Jobs since there's no Job determined 272 // Reset the Request will cancel all the Jobs since there's no Job determined
274 // to serve Request yet and JobController will notify the factory to delete 273 // to serve Request yet and JobController will notify the factory to delete
275 // itself upon completion. 274 // itself upon completion.
276 request_.reset(); 275 request_.reset();
277 VerifyBrokenAlternateProtocolMapping(request_info, false); 276 VerifyBrokenAlternateProtocolMapping(request_info, false);
278 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 277 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
279 } 278 }
(...skipping 10 matching lines...) Expand all
290 Initialize(false); 289 Initialize(false);
291 290
292 HttpRequestInfo request_info; 291 HttpRequestInfo request_info;
293 request_info.method = "GET"; 292 request_info.method = "GET";
294 request_info.url = GURL("https://www.google.com"); 293 request_info.url = GURL("https://www.google.com");
295 294
296 url::SchemeHostPort server(request_info.url); 295 url::SchemeHostPort server(request_info.url);
297 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 296 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
298 SetAlternativeService(request_info, alternative_service); 297 SetAlternativeService(request_info, alternative_service);
299 298
300 request_.reset( 299 request_.reset(job_controller_->Start(
301 job_controller_->Start(request_info, &request_delegate_, nullptr, 300 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
302 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 301 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
303 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
304 EXPECT_TRUE(job_controller_->main_job()); 302 EXPECT_TRUE(job_controller_->main_job());
305 EXPECT_TRUE(job_controller_->alternative_job()); 303 EXPECT_TRUE(job_controller_->alternative_job());
306 304
307 // We have the main job with unknown status when the alternative job is failed 305 // We have the main job with unknown status when the alternative job is failed
308 // thus should not notify Request of the alternative job's failure. But should 306 // thus should not notify Request of the alternative job's failure. But should
309 // notify the main job to mark the alternative job failed. 307 // notify the main job to mark the alternative job failed.
310 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); 308 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
311 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, 309 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED,
312 SSLConfig()); 310 SSLConfig());
313 EXPECT_TRUE(!job_controller_->alternative_job()); 311 EXPECT_TRUE(!job_controller_->alternative_job());
(...skipping 20 matching lines...) Expand all
334 Initialize(false); 332 Initialize(false);
335 333
336 HttpRequestInfo request_info; 334 HttpRequestInfo request_info;
337 request_info.method = "GET"; 335 request_info.method = "GET";
338 request_info.url = GURL("https://www.google.com"); 336 request_info.url = GURL("https://www.google.com");
339 337
340 url::SchemeHostPort server(request_info.url); 338 url::SchemeHostPort server(request_info.url);
341 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 339 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
342 SetAlternativeService(request_info, alternative_service); 340 SetAlternativeService(request_info, alternative_service);
343 341
344 request_.reset( 342 request_.reset(job_controller_->Start(
345 job_controller_->Start(request_info, &request_delegate_, nullptr, 343 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
346 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 344 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
347 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
348 EXPECT_TRUE(job_controller_->main_job()); 345 EXPECT_TRUE(job_controller_->main_job());
349 EXPECT_TRUE(job_controller_->alternative_job()); 346 EXPECT_TRUE(job_controller_->alternative_job());
350 347
351 // Main job succeeds, starts serving Request and it should report status 348 // Main job succeeds, starts serving Request and it should report status
352 // to Request. The alternative job will mark the main job complete and gets 349 // to Request. The alternative job will mark the main job complete and gets
353 // orphaned. 350 // orphaned.
354 HttpStream* http_stream = 351 HttpStream* http_stream =
355 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); 352 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false);
356 job_factory_.main_job()->SetStream(http_stream); 353 job_factory_.main_job()->SetStream(http_stream);
357 354
(...skipping 26 matching lines...) Expand all
384 base::WrapUnique(proxy_resolver_factory), nullptr)); 381 base::WrapUnique(proxy_resolver_factory), nullptr));
385 Initialize(false); 382 Initialize(false);
386 383
387 HttpRequestInfo request_info; 384 HttpRequestInfo request_info;
388 request_info.method = "GET"; 385 request_info.method = "GET";
389 request_info.url = GURL("https://www.google.com"); 386 request_info.url = GURL("https://www.google.com");
390 387
391 url::SchemeHostPort server(request_info.url); 388 url::SchemeHostPort server(request_info.url);
392 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 389 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
393 SetAlternativeService(request_info, alternative_service); 390 SetAlternativeService(request_info, alternative_service);
394 request_.reset( 391 request_.reset(job_controller_->Start(
395 job_controller_->Start(request_info, &request_delegate_, nullptr, 392 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
396 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 393 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
397 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
398 EXPECT_TRUE(job_controller_->main_job()); 394 EXPECT_TRUE(job_controller_->main_job());
399 EXPECT_TRUE(job_controller_->alternative_job()); 395 EXPECT_TRUE(job_controller_->alternative_job());
400 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); 396 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_));
401 397
402 // |alternative_job| succeeds and should report status to Request. 398 // |alternative_job| succeeds and should report status to Request.
403 HttpStream* http_stream = 399 HttpStream* http_stream =
404 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); 400 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false);
405 job_factory_.alternative_job()->SetStream(http_stream); 401 job_factory_.alternative_job()->SetStream(http_stream);
406 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) 402 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream))
407 .WillOnce(Invoke(DeleteHttpStreamPointer)); 403 .WillOnce(Invoke(DeleteHttpStreamPointer));
(...skipping 27 matching lines...) Expand all
435 HttpRequestInfo request_info; 431 HttpRequestInfo request_info;
436 request_info.method = "GET"; 432 request_info.method = "GET";
437 request_info.url = GURL("https://www.google.com"); 433 request_info.url = GURL("https://www.google.com");
438 434
439 url::SchemeHostPort server(request_info.url); 435 url::SchemeHostPort server(request_info.url);
440 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 436 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
441 SetAlternativeService(request_info, alternative_service); 437 SetAlternativeService(request_info, alternative_service);
442 // Hack to use different URL for the main job to help differentiate the proxy 438 // Hack to use different URL for the main job to help differentiate the proxy
443 // requests. 439 // requests.
444 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); 440 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com"));
445 request_.reset( 441 request_.reset(job_controller_->Start(
446 job_controller_->Start(request_info, &request_delegate_, nullptr, 442 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
447 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 443 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
448 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
449 EXPECT_TRUE(job_controller_->main_job()); 444 EXPECT_TRUE(job_controller_->main_job());
450 EXPECT_TRUE(job_controller_->alternative_job()); 445 EXPECT_TRUE(job_controller_->alternative_job());
451 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); 446 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_));
452 447
453 // Complete main job now. 448 // Complete main job now.
454 MockAsyncProxyResolver resolver; 449 MockAsyncProxyResolver resolver;
455 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( 450 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder(
456 net::OK, &resolver); 451 net::OK, &resolver);
457 int main_job_request_id = 452 int main_job_request_id =
458 resolver.pending_jobs()[0]->url().SchemeIs("http") ? 0 : 1; 453 resolver.pending_jobs()[0]->url().SchemeIs("http") ? 0 : 1;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 Initialize(false); 495 Initialize(false);
501 496
502 HttpRequestInfo request_info; 497 HttpRequestInfo request_info;
503 request_info.method = "GET"; 498 request_info.method = "GET";
504 request_info.url = GURL("https://www.google.com"); 499 request_info.url = GURL("https://www.google.com");
505 500
506 url::SchemeHostPort server(request_info.url); 501 url::SchemeHostPort server(request_info.url);
507 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 502 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
508 SetAlternativeService(request_info, alternative_service); 503 SetAlternativeService(request_info, alternative_service);
509 504
510 request_.reset( 505 request_.reset(job_controller_->Start(
511 job_controller_->Start(request_info, &request_delegate_, nullptr, 506 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
512 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 507 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
513 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
514 EXPECT_TRUE(job_controller_->main_job()); 508 EXPECT_TRUE(job_controller_->main_job());
515 EXPECT_TRUE(job_controller_->alternative_job()); 509 EXPECT_TRUE(job_controller_->alternative_job());
516 510
517 // |main_job| fails but should not report status to Request. 511 // |main_job| fails but should not report status to Request.
518 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); 512 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
519 513
520 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, 514 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED,
521 SSLConfig()); 515 SSLConfig());
522 516
523 // |alternative_job| succeeds and should report status to Request. 517 // |alternative_job| succeeds and should report status to Request.
(...skipping 20 matching lines...) Expand all
544 Initialize(false); 538 Initialize(false);
545 539
546 HttpRequestInfo request_info; 540 HttpRequestInfo request_info;
547 request_info.method = "GET"; 541 request_info.method = "GET";
548 request_info.url = GURL("https://www.google.com"); 542 request_info.url = GURL("https://www.google.com");
549 543
550 url::SchemeHostPort server(request_info.url); 544 url::SchemeHostPort server(request_info.url);
551 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 545 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
552 SetAlternativeService(request_info, alternative_service); 546 SetAlternativeService(request_info, alternative_service);
553 547
554 request_.reset( 548 request_.reset(job_controller_->Start(
555 job_controller_->Start(request_info, &request_delegate_, nullptr, 549 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
556 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 550 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
557 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
558 EXPECT_TRUE(job_controller_->main_job()); 551 EXPECT_TRUE(job_controller_->main_job());
559 EXPECT_TRUE(job_controller_->alternative_job()); 552 EXPECT_TRUE(job_controller_->alternative_job());
560 553
561 // |alternative_job| fails but should not report status to Request. 554 // |alternative_job| fails but should not report status to Request.
562 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); 555 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
563 556
564 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, 557 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED,
565 SSLConfig()); 558 SSLConfig());
566 559
567 // |main_job| succeeds and should report status to Request. 560 // |main_job| succeeds and should report status to Request.
(...skipping 22 matching lines...) Expand all
590 Initialize(false); 583 Initialize(false);
591 584
592 HttpRequestInfo request_info; 585 HttpRequestInfo request_info;
593 request_info.method = "GET"; 586 request_info.method = "GET";
594 request_info.url = GURL("https://www.google.com"); 587 request_info.url = GURL("https://www.google.com");
595 588
596 url::SchemeHostPort server(request_info.url); 589 url::SchemeHostPort server(request_info.url);
597 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 590 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
598 SetAlternativeService(request_info, alternative_service); 591 SetAlternativeService(request_info, alternative_service);
599 592
600 request_.reset( 593 request_.reset(job_controller_->Start(
601 job_controller_->Start(request_info, &request_delegate_, nullptr, 594 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
602 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 595 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
603 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
604 EXPECT_TRUE(job_controller_->main_job()); 596 EXPECT_TRUE(job_controller_->main_job());
605 EXPECT_TRUE(job_controller_->alternative_job()); 597 EXPECT_TRUE(job_controller_->alternative_job());
606 598
607 // |main_job| fails but should not report status to Request. 599 // |main_job| fails but should not report status to Request.
608 // The alternative job will mark the main job complete. 600 // The alternative job will mark the main job complete.
609 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); 601 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
610 602
611 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, 603 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED,
612 SSLConfig()); 604 SSLConfig());
613 605
(...skipping 24 matching lines...) Expand all
638 Initialize(false); 630 Initialize(false);
639 631
640 HttpRequestInfo request_info; 632 HttpRequestInfo request_info;
641 request_info.method = "GET"; 633 request_info.method = "GET";
642 request_info.url = GURL("https://www.google.com"); 634 request_info.url = GURL("https://www.google.com");
643 635
644 url::SchemeHostPort server(request_info.url); 636 url::SchemeHostPort server(request_info.url);
645 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 637 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
646 SetAlternativeService(request_info, alternative_service); 638 SetAlternativeService(request_info, alternative_service);
647 639
648 request_.reset( 640 request_.reset(job_controller_->Start(
649 job_controller_->Start(request_info, &request_delegate_, nullptr, 641 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
650 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 642 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
651 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
652 EXPECT_TRUE(job_controller_->main_job()); 643 EXPECT_TRUE(job_controller_->main_job());
653 EXPECT_TRUE(job_controller_->alternative_job()); 644 EXPECT_TRUE(job_controller_->alternative_job());
654 645
655 // Wait until OnStreamFailedCallback is executed on the alternative job. 646 // Wait until OnStreamFailedCallback is executed on the alternative job.
656 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); 647 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1);
657 base::RunLoop().RunUntilIdle(); 648 base::RunLoop().RunUntilIdle();
658 } 649 }
659 650
660 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { 651 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) {
661 // Using a restricted port 101 for QUIC should fail and the alternative job 652 // Using a restricted port 101 for QUIC should fail and the alternative job
662 // should post OnStreamFailedCall on the controller to resume the main job. 653 // should post OnStreamFailedCall on the controller to resume the main job.
663 Initialize(false); 654 Initialize(false);
664 655
665 HttpRequestInfo request_info; 656 HttpRequestInfo request_info;
666 request_info.method = "GET"; 657 request_info.method = "GET";
667 request_info.url = GURL("https://www.google.com"); 658 request_info.url = GURL("https://www.google.com");
668 659
669 url::SchemeHostPort server(request_info.url); 660 url::SchemeHostPort server(request_info.url);
670 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); 661 AlternativeService alternative_service(kProtoQUIC, server.host(), 101);
671 SetAlternativeService(request_info, alternative_service); 662 SetAlternativeService(request_info, alternative_service);
672 663
673 request_.reset( 664 request_.reset(job_controller_->Start(
674 job_controller_->Start(request_info, &request_delegate_, nullptr, 665 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
675 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 666 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
676 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
677 667
678 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); 668 EXPECT_TRUE(job_factory_.main_job()->is_waiting());
679 669
680 // Wait until OnStreamFailedCallback is executed on the alternative job. 670 // Wait until OnStreamFailedCallback is executed on the alternative job.
681 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); 671 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1);
682 base::RunLoop().RunUntilIdle(); 672 base::RunLoop().RunUntilIdle();
683 } 673 }
684 674
685 TEST_F(HttpStreamFactoryImplJobControllerTest, 675 TEST_F(HttpStreamFactoryImplJobControllerTest,
686 NoAvailableSpdySessionToResumeMainJob) { 676 NoAvailableSpdySessionToResumeMainJob) {
(...skipping 21 matching lines...) Expand all
708 request_info.url = GURL("https://www.google.com"); 698 request_info.url = GURL("https://www.google.com");
709 699
710 // Set a SPDY alternative service for the server. 700 // Set a SPDY alternative service for the server.
711 url::SchemeHostPort server(request_info.url); 701 url::SchemeHostPort server(request_info.url);
712 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 702 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
713 SetAlternativeService(request_info, alternative_service); 703 SetAlternativeService(request_info, alternative_service);
714 // Hack to use different URL for the main job to help differentiate the proxy 704 // Hack to use different URL for the main job to help differentiate the proxy
715 // requests. 705 // requests.
716 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); 706 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com"));
717 707
718 request_.reset( 708 request_.reset(job_controller_->Start(
719 job_controller_->Start(request_info, &request_delegate_, nullptr, 709 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
720 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 710 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
721 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
722 // Both jobs should be created but stalled as proxy resolution not completed. 711 // Both jobs should be created but stalled as proxy resolution not completed.
723 EXPECT_TRUE(job_controller_->main_job()); 712 EXPECT_TRUE(job_controller_->main_job());
724 EXPECT_TRUE(job_controller_->alternative_job()); 713 EXPECT_TRUE(job_controller_->alternative_job());
725 714
726 MockAsyncProxyResolver resolver; 715 MockAsyncProxyResolver resolver;
727 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( 716 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder(
728 net::OK, &resolver); 717 net::OK, &resolver);
729 718
730 // Resolve proxy for the main job which then proceed to wait for the 719 // Resolve proxy for the main job which then proceed to wait for the
731 // alternative job which is IO_PENDING. 720 // alternative job which is IO_PENDING.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 request_info.method = "GET"; 759 request_info.method = "GET";
771 request_info.url = GURL("https://www.google.com"); 760 request_info.url = GURL("https://www.google.com");
772 761
773 url::SchemeHostPort server(request_info.url); 762 url::SchemeHostPort server(request_info.url);
774 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 763 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
775 SetAlternativeService(request_info, alternative_service); 764 SetAlternativeService(request_info, alternative_service);
776 // Hack to use different URL for the main job to help differentiate the proxy 765 // Hack to use different URL for the main job to help differentiate the proxy
777 // requests. 766 // requests.
778 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); 767 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com"));
779 768
780 request_.reset( 769 request_.reset(job_controller_->Start(
781 job_controller_->Start(request_info, &request_delegate_, nullptr, 770 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
782 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 771 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
783 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
784 EXPECT_TRUE(job_controller_->main_job()); 772 EXPECT_TRUE(job_controller_->main_job());
785 EXPECT_TRUE(job_controller_->alternative_job()); 773 EXPECT_TRUE(job_controller_->alternative_job());
786 774
787 MockAsyncProxyResolver resolver; 775 MockAsyncProxyResolver resolver;
788 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( 776 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder(
789 net::OK, &resolver); 777 net::OK, &resolver);
790 778
791 // Resolve proxy for the main job which then proceed to wait for the 779 // Resolve proxy for the main job which then proceed to wait for the
792 // alternative job which is IO_PENDING. 780 // alternative job which is IO_PENDING.
793 int main_job_request_id = 781 int main_job_request_id =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 817
830 HttpRequestInfo request_info; 818 HttpRequestInfo request_info;
831 request_info.method = "GET"; 819 request_info.method = "GET";
832 request_info.url = GURL("https://www.google.com"); 820 request_info.url = GURL("https://www.google.com");
833 821
834 // Set a SPDY alternative service for the server. 822 // Set a SPDY alternative service for the server.
835 url::SchemeHostPort server(request_info.url); 823 url::SchemeHostPort server(request_info.url);
836 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 824 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
837 SetAlternativeService(request_info, alternative_service); 825 SetAlternativeService(request_info, alternative_service);
838 826
839 request_.reset( 827 request_.reset(job_controller_->Start(
840 job_controller_->Start(request_info, &request_delegate_, nullptr, 828 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
841 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 829 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
842 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
843 EXPECT_TRUE(job_controller_->main_job()); 830 EXPECT_TRUE(job_controller_->main_job());
844 EXPECT_TRUE(job_controller_->alternative_job()); 831 EXPECT_TRUE(job_controller_->alternative_job());
845 832
846 // The alternative job stalls as host resolution hangs when creating the QUIC 833 // The alternative job stalls as host resolution hangs when creating the QUIC
847 // request and controller should resume the main job after delay. 834 // request and controller should resume the main job after delay.
848 // Verify the waiting time for delayed main job. 835 // Verify the waiting time for delayed main job.
849 EXPECT_CALL(*job_factory_.main_job(), Resume()) 836 EXPECT_CALL(*job_factory_.main_job(), Resume())
850 .WillOnce(Invoke(testing::CreateFunctor( 837 .WillOnce(Invoke(testing::CreateFunctor(
851 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_, 838 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_,
852 base::TimeDelta::FromMicroseconds(15)))); 839 base::TimeDelta::FromMicroseconds(15))));
853 840
854 base::RunLoop().RunUntilIdle(); 841 base::RunLoop().RunUntilIdle();
855 } 842 }
856 843
857 // Verifies that the alternative proxy server job is not created if the URL 844 // Verifies that the alternative proxy server job is not created if the URL
858 // scheme is HTTPS. 845 // scheme is HTTPS.
859 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) { 846 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) {
860 // Using hanging resolver will cause the alternative job to hang indefinitely. 847 // Using hanging resolver will cause the alternative job to hang indefinitely.
861 HangingResolver* resolver = new HangingResolver(); 848 HangingResolver* resolver = new HangingResolver();
862 session_deps_.host_resolver.reset(resolver); 849 session_deps_.host_resolver.reset(resolver);
863 850
864 Initialize(true); 851 Initialize(true);
865 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); 852 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
866 853
867 HttpRequestInfo request_info; 854 HttpRequestInfo request_info;
868 request_info.method = "GET"; 855 request_info.method = "GET";
869 request_info.url = GURL("https://mail.example.org/"); 856 request_info.url = GURL("https://mail.example.org/");
870 857
871 request_.reset( 858 request_.reset(job_controller_->Start(
872 job_controller_->Start(request_info, &request_delegate_, nullptr, 859 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
873 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 860 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
874 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
875 EXPECT_TRUE(job_controller_->main_job()); 861 EXPECT_TRUE(job_controller_->main_job());
876 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); 862 EXPECT_FALSE(job_controller_->main_job()->is_waiting());
877 EXPECT_FALSE(job_controller_->alternative_job()); 863 EXPECT_FALSE(job_controller_->alternative_job());
878 864
879 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); 865 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0);
880 base::RunLoop().RunUntilIdle(); 866 base::RunLoop().RunUntilIdle();
881 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); 867 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations());
882 } 868 }
883 869
884 // Verifies that the alternative proxy server job is not created if the main job 870 // Verifies that the alternative proxy server job is not created if the main job
885 // does not fetch the resource through a proxy. 871 // does not fetch the resource through a proxy.
886 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { 872 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) {
887 // Using hanging resolver will cause the alternative job to hang indefinitely. 873 // Using hanging resolver will cause the alternative job to hang indefinitely.
888 HangingResolver* resolver = new HangingResolver(); 874 HangingResolver* resolver = new HangingResolver();
889 session_deps_.host_resolver.reset(resolver); 875 session_deps_.host_resolver.reset(resolver);
890 876
891 Initialize(false); 877 Initialize(false);
892 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); 878 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
893 879
894 HttpRequestInfo request_info; 880 HttpRequestInfo request_info;
895 request_info.method = "GET"; 881 request_info.method = "GET";
896 request_info.url = GURL("http://mail.example.org/"); 882 request_info.url = GURL("http://mail.example.org/");
897 883
898 request_.reset( 884 request_.reset(job_controller_->Start(
899 job_controller_->Start(request_info, &request_delegate_, nullptr, 885 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
900 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 886 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
901 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
902 EXPECT_TRUE(job_controller_->main_job()); 887 EXPECT_TRUE(job_controller_->main_job());
903 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); 888 EXPECT_FALSE(job_controller_->main_job()->is_waiting());
904 EXPECT_FALSE(job_controller_->alternative_job()); 889 EXPECT_FALSE(job_controller_->alternative_job());
905 890
906 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); 891 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0);
907 base::RunLoop().RunUntilIdle(); 892 base::RunLoop().RunUntilIdle();
908 893
909 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); 894 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations());
910 } 895 }
911 896
(...skipping 13 matching lines...) Expand all
925 quic_stream_factory->set_require_confirmation(false); 910 quic_stream_factory->set_require_confirmation(false);
926 ServerNetworkStats stats1; 911 ServerNetworkStats stats1;
927 stats1.srtt = base::TimeDelta::FromMicroseconds(10); 912 stats1.srtt = base::TimeDelta::FromMicroseconds(10);
928 session_->http_server_properties()->SetServerNetworkStats( 913 session_->http_server_properties()->SetServerNetworkStats(
929 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); 914 url::SchemeHostPort(GURL("https://myproxy.org")), stats1);
930 915
931 HttpRequestInfo request_info; 916 HttpRequestInfo request_info;
932 request_info.method = "GET"; 917 request_info.method = "GET";
933 request_info.url = GURL("http://mail.example.org/"); 918 request_info.url = GURL("http://mail.example.org/");
934 919
935 request_.reset( 920 request_.reset(job_controller_->Start(
936 job_controller_->Start(request_info, &request_delegate_, nullptr, 921 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
937 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 922 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
938 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
939 EXPECT_TRUE(job_controller_->main_job()); 923 EXPECT_TRUE(job_controller_->main_job());
940 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); 924 EXPECT_TRUE(job_controller_->main_job()->is_waiting());
941 EXPECT_TRUE(job_controller_->alternative_job()); 925 EXPECT_TRUE(job_controller_->alternative_job());
942 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); 926 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_));
943 927
944 // The alternative proxy server job stalls when connecting to the alternative 928 // The alternative proxy server job stalls when connecting to the alternative
945 // proxy server, and controller should resume the main job after delay. 929 // proxy server, and controller should resume the main job after delay.
946 // Verify the waiting time for delayed main job. 930 // Verify the waiting time for delayed main job.
947 EXPECT_CALL(*job_factory_.main_job(), Resume()) 931 EXPECT_CALL(*job_factory_.main_job(), Resume())
948 .WillOnce(Invoke(testing::CreateFunctor( 932 .WillOnce(Invoke(testing::CreateFunctor(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 quic_stream_factory->set_require_confirmation(false); 970 quic_stream_factory->set_require_confirmation(false);
987 ServerNetworkStats stats1; 971 ServerNetworkStats stats1;
988 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); 972 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000);
989 session_->http_server_properties()->SetServerNetworkStats( 973 session_->http_server_properties()->SetServerNetworkStats(
990 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); 974 url::SchemeHostPort(GURL("https://myproxy.org")), stats1);
991 975
992 HttpRequestInfo request_info; 976 HttpRequestInfo request_info;
993 request_info.method = "GET"; 977 request_info.method = "GET";
994 request_info.url = GURL("http://mail.example.org/"); 978 request_info.url = GURL("http://mail.example.org/");
995 979
996 request_.reset( 980 request_.reset(job_controller_->Start(
997 job_controller_->Start(request_info, &request_delegate_, nullptr, 981 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
998 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 982 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
999 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
1000 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); 983 EXPECT_TRUE(job_controller_->main_job()->is_waiting());
1001 EXPECT_TRUE(job_controller_->alternative_job()); 984 EXPECT_TRUE(job_controller_->alternative_job());
1002 985
1003 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)).Times(0); 986 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)).Times(0);
1004 987
1005 // Since the alternative proxy server job is started in the next message loop, 988 // Since the alternative proxy server job is started in the next message loop,
1006 // the main job would remain blocked until the alternative proxy starts, and 989 // the main job would remain blocked until the alternative proxy starts, and
1007 // fails. 990 // fails.
1008 EXPECT_CALL(*job_factory_.main_job(), Resume()) 991 EXPECT_CALL(*job_factory_.main_job(), Resume())
1009 .WillOnce(Invoke(testing::CreateFunctor( 992 .WillOnce(Invoke(testing::CreateFunctor(
(...skipping 13 matching lines...) Expand all
1023 AlternativeProxyServerJobFailsAfterMainJobSucceeds) { 1006 AlternativeProxyServerJobFailsAfterMainJobSucceeds) {
1024 base::HistogramTester histogram_tester; 1007 base::HistogramTester histogram_tester;
1025 Initialize(true); 1008 Initialize(true);
1026 1009
1027 HttpRequestInfo request_info; 1010 HttpRequestInfo request_info;
1028 request_info.method = "GET"; 1011 request_info.method = "GET";
1029 request_info.url = GURL("http://www.google.com"); 1012 request_info.url = GURL("http://www.google.com");
1030 1013
1031 url::SchemeHostPort server(request_info.url); 1014 url::SchemeHostPort server(request_info.url);
1032 1015
1033 request_.reset( 1016 request_.reset(job_controller_->Start(
1034 job_controller_->Start(request_info, &request_delegate_, nullptr, 1017 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM,
1035 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 1018 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
1036 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
1037 EXPECT_TRUE(job_controller_->main_job()); 1019 EXPECT_TRUE(job_controller_->main_job());
1038 EXPECT_TRUE(job_controller_->alternative_job()); 1020 EXPECT_TRUE(job_controller_->alternative_job());
1039 1021
1040 // Main job succeeds, starts serving Request and it should report status 1022 // Main job succeeds, starts serving Request and it should report status
1041 // to Request. The alternative job will mark the main job complete and gets 1023 // to Request. The alternative job will mark the main job complete and gets
1042 // orphaned. 1024 // orphaned.
1043 HttpStream* http_stream = 1025 HttpStream* http_stream =
1044 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); 1026 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false);
1045 job_factory_.main_job()->SetStream(http_stream); 1027 job_factory_.main_job()->SetStream(http_stream);
1046 1028
(...skipping 10 matching lines...) Expand all
1057 // Reset the request as it's been successfully served. 1039 // Reset the request as it's been successfully served.
1058 request_.reset(); 1040 request_.reset();
1059 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 1041 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
1060 1042
1061 histogram_tester.ExpectUniqueSample("Net.QuicAlternativeProxy.Usage", 1043 histogram_tester.ExpectUniqueSample("Net.QuicAlternativeProxy.Usage",
1062 2 /* ALTERNATIVE_PROXY_USAGE_LOST_RACE */, 1044 2 /* ALTERNATIVE_PROXY_USAGE_LOST_RACE */,
1063 1); 1045 1);
1064 } 1046 }
1065 1047
1066 } // namespace net 1048 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698