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

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

Issue 2625133006: Move the logic to cancel main job in OrphanUnboundJob when the alt job succeed while main job is bl… (Closed)
Patch Set: fix test 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
« 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) 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); 364 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
365 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, 365 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED,
366 SSLConfig()); 366 SSLConfig());
367 367
368 VerifyBrokenAlternateProtocolMapping(request_info, true); 368 VerifyBrokenAlternateProtocolMapping(request_info, true);
369 // Reset the request as it's been successfully served. 369 // Reset the request as it's been successfully served.
370 request_.reset(); 370 request_.reset();
371 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 371 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
372 } 372 }
373 373
374 // Tests that if alt job succeeds and main job is blocked, |request_| completion 374 // Tests that if alt job succeeds and main job is blocked, main job should be
375 // will clean up JobController. Regression test for crbug.com/678768. 375 // cancelled immediately. |request_| completion will clean up the JobController.
376 // Regression test for crbug.com/678768.
376 TEST_F(HttpStreamFactoryImplJobControllerTest, 377 TEST_F(HttpStreamFactoryImplJobControllerTest,
377 AltJobSucceedsMainJobBlockedControllerDestroyed) { 378 AltJobSucceedsMainJobBlockedControllerDestroyed) {
378 ProxyConfig proxy_config; 379 ProxyConfig proxy_config;
379 proxy_config.set_auto_detect(true); 380 proxy_config.set_auto_detect(true);
380 MockAsyncProxyResolverFactory* proxy_resolver_factory = 381 MockAsyncProxyResolverFactory* proxy_resolver_factory =
381 new MockAsyncProxyResolverFactory(false); 382 new MockAsyncProxyResolverFactory(false);
382 session_deps_.proxy_service.reset( 383 session_deps_.proxy_service.reset(
383 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), 384 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
384 base::WrapUnique(proxy_resolver_factory), nullptr)); 385 base::WrapUnique(proxy_resolver_factory), nullptr));
385 Initialize(false); 386 Initialize(false);
(...skipping 14 matching lines...) Expand all
400 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); 401 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_));
401 402
402 // |alternative_job| succeeds and should report status to Request. 403 // |alternative_job| succeeds and should report status to Request.
403 HttpStream* http_stream = 404 HttpStream* http_stream =
404 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); 405 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false);
405 job_factory_.alternative_job()->SetStream(http_stream); 406 job_factory_.alternative_job()->SetStream(http_stream);
406 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) 407 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream))
407 .WillOnce(Invoke(DeleteHttpStreamPointer)); 408 .WillOnce(Invoke(DeleteHttpStreamPointer));
408 job_controller_->OnStreamReady(job_factory_.alternative_job(), SSLConfig()); 409 job_controller_->OnStreamReady(job_factory_.alternative_job(), SSLConfig());
409 410
410 EXPECT_TRUE(job_controller_->main_job()); 411 EXPECT_FALSE(job_controller_->main_job());
411 EXPECT_TRUE(job_controller_->alternative_job()); 412 EXPECT_TRUE(job_controller_->alternative_job());
412 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_));
413 413
414 // Invoke OnRequestComplete() which should delete |job_controller_| from 414 // Invoke OnRequestComplete() which should delete |job_controller_| from
415 // |factory_|. 415 // |factory_|.
416 request_.reset(); 416 request_.reset();
417 VerifyBrokenAlternateProtocolMapping(request_info, false); 417 VerifyBrokenAlternateProtocolMapping(request_info, false);
418 // This fails without the fix for crbug.com/678768. 418 // This fails without the fix for crbug.com/678768.
419 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 419 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
420 } 420 }
421 421
422 // Tests that if an orphaned job completes after |request_| is gone, 422 // Tests that if an orphaned job completes after |request_| is gone,
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 // Reset the request as it's been successfully served. 1057 // Reset the request as it's been successfully served.
1058 request_.reset(); 1058 request_.reset();
1059 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 1059 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
1060 1060
1061 histogram_tester.ExpectUniqueSample("Net.QuicAlternativeProxy.Usage", 1061 histogram_tester.ExpectUniqueSample("Net.QuicAlternativeProxy.Usage",
1062 2 /* ALTERNATIVE_PROXY_USAGE_LOST_RACE */, 1062 2 /* ALTERNATIVE_PROXY_USAGE_LOST_RACE */,
1063 1); 1063 1);
1064 } 1064 }
1065 1065
1066 } // namespace net 1066 } // 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