| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 7719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7730 // Check that creating a network request while entering/exiting suspend mode | 7730 // Check that creating a network request while entering/exiting suspend mode |
| 7731 // fails as it should. This is the only case where an HttpTransactionFactory | 7731 // fails as it should. This is the only case where an HttpTransactionFactory |
| 7732 // does not return an HttpTransaction. | 7732 // does not return an HttpTransaction. |
| 7733 TEST_F(URLRequestTestHTTP, NetworkSuspendTest) { | 7733 TEST_F(URLRequestTestHTTP, NetworkSuspendTest) { |
| 7734 // Create a new HttpNetworkLayer that thinks it's suspended. | 7734 // Create a new HttpNetworkLayer that thinks it's suspended. |
| 7735 std::unique_ptr<HttpNetworkLayer> network_layer(new HttpNetworkLayer( | 7735 std::unique_ptr<HttpNetworkLayer> network_layer(new HttpNetworkLayer( |
| 7736 default_context_.http_transaction_factory()->GetSession())); | 7736 default_context_.http_transaction_factory()->GetSession())); |
| 7737 network_layer->OnSuspend(); | 7737 network_layer->OnSuspend(); |
| 7738 | 7738 |
| 7739 HttpCache http_cache(std::move(network_layer), | 7739 HttpCache http_cache(std::move(network_layer), |
| 7740 HttpCache::DefaultBackend::InMemory(0), true); | 7740 HttpCache::DefaultBackend::InMemory(0), |
| 7741 false /* set_up_quic_server_info_factory */); |
| 7741 | 7742 |
| 7742 TestURLRequestContext context(true); | 7743 TestURLRequestContext context(true); |
| 7743 context.set_http_transaction_factory(&http_cache); | 7744 context.set_http_transaction_factory(&http_cache); |
| 7744 context.Init(); | 7745 context.Init(); |
| 7745 | 7746 |
| 7746 TestDelegate d; | 7747 TestDelegate d; |
| 7747 std::unique_ptr<URLRequest> req( | 7748 std::unique_ptr<URLRequest> req( |
| 7748 context.CreateRequest(GURL("http://127.0.0.1/"), DEFAULT_PRIORITY, &d)); | 7749 context.CreateRequest(GURL("http://127.0.0.1/"), DEFAULT_PRIORITY, &d)); |
| 7749 req->Start(); | 7750 req->Start(); |
| 7750 base::RunLoop().Run(); | 7751 base::RunLoop().Run(); |
| (...skipping 2989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10740 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10741 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10741 | 10742 |
| 10742 req->Start(); | 10743 req->Start(); |
| 10743 req->Cancel(); | 10744 req->Cancel(); |
| 10744 base::RunLoop().RunUntilIdle(); | 10745 base::RunLoop().RunUntilIdle(); |
| 10745 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 10746 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
| 10746 EXPECT_EQ(0, d.received_redirect_count()); | 10747 EXPECT_EQ(0, d.received_redirect_count()); |
| 10747 } | 10748 } |
| 10748 | 10749 |
| 10749 } // namespace net | 10750 } // namespace net |
| OLD | NEW |