| 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 7751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7762 params.ssl_config_service = ssl_config_service.get(); | 7762 params.ssl_config_service = ssl_config_service.get(); |
| 7763 params.http_server_properties = &http_server_properties; | 7763 params.http_server_properties = &http_server_properties; |
| 7764 | 7764 |
| 7765 HttpNetworkSession session(params); | 7765 HttpNetworkSession session(params); |
| 7766 DCHECK(session.quic_stream_factory()); | 7766 DCHECK(session.quic_stream_factory()); |
| 7767 | 7767 |
| 7768 std::unique_ptr<HttpNetworkLayer> network_layer1( | 7768 std::unique_ptr<HttpNetworkLayer> network_layer1( |
| 7769 new HttpNetworkLayer(&session)); | 7769 new HttpNetworkLayer(&session)); |
| 7770 | 7770 |
| 7771 HttpCache main_cache(std::move(network_layer1), | 7771 HttpCache main_cache(std::move(network_layer1), |
| 7772 HttpCache::DefaultBackend::InMemory(0), true); | 7772 HttpCache::DefaultBackend::InMemory(0), |
| 7773 true /* is_main_cache */); |
| 7773 | 7774 |
| 7774 EXPECT_TRUE(session.quic_stream_factory()->has_quic_server_info_factory()); | 7775 EXPECT_TRUE(session.quic_stream_factory()->has_quic_server_info_factory()); |
| 7775 | 7776 |
| 7776 default_context_.set_http_transaction_factory(&main_cache); | 7777 default_context_.set_http_transaction_factory(&main_cache); |
| 7777 | 7778 |
| 7778 QuicServerInfoFactory* quic_server_info_factory = | 7779 QuicServerInfoFactory* quic_server_info_factory = |
| 7779 session.quic_stream_factory()->quic_server_info_factory(); | 7780 session.quic_stream_factory()->quic_server_info_factory(); |
| 7780 DCHECK(quic_server_info_factory); | 7781 DCHECK(quic_server_info_factory); |
| 7781 | 7782 |
| 7782 QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED); | 7783 QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7857 // fails as it should. This is the only case where an HttpTransactionFactory | 7858 // fails as it should. This is the only case where an HttpTransactionFactory |
| 7858 // does not return an HttpTransaction. | 7859 // does not return an HttpTransaction. |
| 7859 TEST_F(URLRequestTestHTTP, NetworkSuspendTest) { | 7860 TEST_F(URLRequestTestHTTP, NetworkSuspendTest) { |
| 7860 // Create a new HttpNetworkLayer that thinks it's suspended. | 7861 // Create a new HttpNetworkLayer that thinks it's suspended. |
| 7861 std::unique_ptr<HttpNetworkLayer> network_layer(new HttpNetworkLayer( | 7862 std::unique_ptr<HttpNetworkLayer> network_layer(new HttpNetworkLayer( |
| 7862 default_context_.http_transaction_factory()->GetSession())); | 7863 default_context_.http_transaction_factory()->GetSession())); |
| 7863 network_layer->OnSuspend(); | 7864 network_layer->OnSuspend(); |
| 7864 | 7865 |
| 7865 HttpCache http_cache(std::move(network_layer), | 7866 HttpCache http_cache(std::move(network_layer), |
| 7866 HttpCache::DefaultBackend::InMemory(0), | 7867 HttpCache::DefaultBackend::InMemory(0), |
| 7867 false /* set_up_quic_server_info_factory */); | 7868 false /* is_main_cache */); |
| 7868 | 7869 |
| 7869 TestURLRequestContext context(true); | 7870 TestURLRequestContext context(true); |
| 7870 context.set_http_transaction_factory(&http_cache); | 7871 context.set_http_transaction_factory(&http_cache); |
| 7871 context.Init(); | 7872 context.Init(); |
| 7872 | 7873 |
| 7873 TestDelegate d; | 7874 TestDelegate d; |
| 7874 std::unique_ptr<URLRequest> req( | 7875 std::unique_ptr<URLRequest> req( |
| 7875 context.CreateRequest(GURL("http://127.0.0.1/"), DEFAULT_PRIORITY, &d)); | 7876 context.CreateRequest(GURL("http://127.0.0.1/"), DEFAULT_PRIORITY, &d)); |
| 7876 req->Start(); | 7877 req->Start(); |
| 7877 base::RunLoop().Run(); | 7878 base::RunLoop().Run(); |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9198 params.cert_transparency_verifier = | 9199 params.cert_transparency_verifier = |
| 9199 default_context_.cert_transparency_verifier(); | 9200 default_context_.cert_transparency_verifier(); |
| 9200 params.ct_policy_enforcer = default_context_.ct_policy_enforcer(); | 9201 params.ct_policy_enforcer = default_context_.ct_policy_enforcer(); |
| 9201 params.proxy_service = default_context_.proxy_service(); | 9202 params.proxy_service = default_context_.proxy_service(); |
| 9202 params.ssl_config_service = default_context_.ssl_config_service(); | 9203 params.ssl_config_service = default_context_.ssl_config_service(); |
| 9203 params.http_auth_handler_factory = | 9204 params.http_auth_handler_factory = |
| 9204 default_context_.http_auth_handler_factory(); | 9205 default_context_.http_auth_handler_factory(); |
| 9205 params.http_server_properties = default_context_.http_server_properties(); | 9206 params.http_server_properties = default_context_.http_server_properties(); |
| 9206 | 9207 |
| 9207 HttpNetworkSession network_session(params); | 9208 HttpNetworkSession network_session(params); |
| 9208 std::unique_ptr<HttpCache> cache(new HttpCache( | 9209 std::unique_ptr<HttpCache> cache( |
| 9209 &network_session, HttpCache::DefaultBackend::InMemory(0), false)); | 9210 new HttpCache(&network_session, HttpCache::DefaultBackend::InMemory(0), |
| 9211 false /* is_main_cache */)); |
| 9210 | 9212 |
| 9211 default_context_.set_http_transaction_factory(cache.get()); | 9213 default_context_.set_http_transaction_factory(cache.get()); |
| 9212 | 9214 |
| 9213 { | 9215 { |
| 9214 TestDelegate d; | 9216 TestDelegate d; |
| 9215 std::unique_ptr<URLRequest> r(default_context_.CreateRequest( | 9217 std::unique_ptr<URLRequest> r(default_context_.CreateRequest( |
| 9216 test_server.GetURL("ssl-session-cache"), DEFAULT_PRIORITY, &d)); | 9218 test_server.GetURL("ssl-session-cache"), DEFAULT_PRIORITY, &d)); |
| 9217 | 9219 |
| 9218 r->Start(); | 9220 r->Start(); |
| 9219 EXPECT_TRUE(r->is_pending()); | 9221 EXPECT_TRUE(r->is_pending()); |
| (...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10867 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10869 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10868 | 10870 |
| 10869 req->Start(); | 10871 req->Start(); |
| 10870 req->Cancel(); | 10872 req->Cancel(); |
| 10871 base::RunLoop().RunUntilIdle(); | 10873 base::RunLoop().RunUntilIdle(); |
| 10872 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 10874 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
| 10873 EXPECT_EQ(0, d.received_redirect_count()); | 10875 EXPECT_EQ(0, d.received_redirect_count()); |
| 10874 } | 10876 } |
| 10875 | 10877 |
| 10876 } // namespace net | 10878 } // namespace net |
| OLD | NEW |