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

Side by Side Diff: net/url_request/url_request_test_util.cc

Issue 2506303002: Revert of Add a NetworkQualityEstimator to TestURLRequestContext. (Closed)
Patch Set: Created 4 years, 1 month 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/url_request/url_request_test_util.h ('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) 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 "net/url_request/url_request_test_util.h" 5 #include "net/url_request/url_request_test_util.h"
6 6
7 #include <map>
8 #include <string>
9 #include <utility> 7 #include <utility>
10 8
11 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
12 #include "base/location.h" 10 #include "base/location.h"
13 #include "base/logging.h" 11 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
16 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
18 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/threading/worker_pool.h" 17 #include "base/threading/worker_pool.h"
20 #include "net/base/host_port_pair.h" 18 #include "net/base/host_port_pair.h"
21 #include "net/cert/cert_verifier.h" 19 #include "net/cert/cert_verifier.h"
22 #include "net/cert/ct_policy_enforcer.h" 20 #include "net/cert/ct_policy_enforcer.h"
23 #include "net/cert/multi_log_ct_verifier.h" 21 #include "net/cert/multi_log_ct_verifier.h"
24 #include "net/dns/mock_host_resolver.h" 22 #include "net/dns/mock_host_resolver.h"
25 #include "net/http/http_network_session.h" 23 #include "net/http/http_network_session.h"
26 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
27 #include "net/http/http_server_properties_impl.h" 25 #include "net/http/http_server_properties_impl.h"
28 #include "net/http/transport_security_state.h" 26 #include "net/http/transport_security_state.h"
29 #include "net/nqe/external_estimate_provider.h"
30 #include "net/proxy/proxy_retry_info.h" 27 #include "net/proxy/proxy_retry_info.h"
31 #include "net/ssl/channel_id_service.h" 28 #include "net/ssl/channel_id_service.h"
32 #include "net/ssl/default_channel_id_store.h" 29 #include "net/ssl/default_channel_id_store.h"
33 #include "net/url_request/static_http_user_agent_settings.h" 30 #include "net/url_request/static_http_user_agent_settings.h"
34 #include "net/url_request/url_request_job.h" 31 #include "net/url_request/url_request_job.h"
35 #include "net/url_request/url_request_job_factory_impl.h" 32 #include "net/url_request/url_request_job_factory_impl.h"
36 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
37 34
38 namespace net { 35 namespace net {
39 36
(...skipping 13 matching lines...) Expand all
53 const int kStageCompletedSuccess = 1 << 7; 50 const int kStageCompletedSuccess = 1 << 7;
54 const int kStageCompletedError = 1 << 8; 51 const int kStageCompletedError = 1 << 8;
55 const int kStageURLRequestDestroyed = 1 << 9; 52 const int kStageURLRequestDestroyed = 1 << 9;
56 const int kStageDestruction = 1 << 10; 53 const int kStageDestruction = 1 << 10;
57 54
58 } // namespace 55 } // namespace
59 56
60 TestURLRequestContext::TestURLRequestContext() : TestURLRequestContext(false) {} 57 TestURLRequestContext::TestURLRequestContext() : TestURLRequestContext(false) {}
61 58
62 TestURLRequestContext::TestURLRequestContext(bool delay_initialization) 59 TestURLRequestContext::TestURLRequestContext(bool delay_initialization)
63 : network_quality_estimator_(std::unique_ptr<ExternalEstimateProvider>(), 60 : context_storage_(this) {
64 std::map<std::string, std::string>()),
65 context_storage_(this) {
66 if (!delay_initialization) 61 if (!delay_initialization)
67 Init(); 62 Init();
68 } 63 }
69 64
70 TestURLRequestContext::~TestURLRequestContext() { 65 TestURLRequestContext::~TestURLRequestContext() {
71 DCHECK(initialized_); 66 DCHECK(initialized_);
72 AssertNoURLRequests(); 67 AssertNoURLRequests();
73 } 68 }
74 69
75 void TestURLRequestContext::Init() { 70 void TestURLRequestContext::Init() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 context_storage_.set_cookie_store( 105 context_storage_.set_cookie_store(
111 base::MakeUnique<CookieMonster>(nullptr, nullptr)); 106 base::MakeUnique<CookieMonster>(nullptr, nullptr));
112 } 107 }
113 // In-memory Channel ID service. Must be created before the 108 // In-memory Channel ID service. Must be created before the
114 // HttpNetworkSession. 109 // HttpNetworkSession.
115 if (!channel_id_service()) { 110 if (!channel_id_service()) {
116 context_storage_.set_channel_id_service(base::MakeUnique<ChannelIDService>( 111 context_storage_.set_channel_id_service(base::MakeUnique<ChannelIDService>(
117 new DefaultChannelIDStore(nullptr), 112 new DefaultChannelIDStore(nullptr),
118 base::WorkerPool::GetTaskRunner(true))); 113 base::WorkerPool::GetTaskRunner(true)));
119 } 114 }
120
121 if (!network_quality_estimator())
122 set_network_quality_estimator(&network_quality_estimator_);
123
124 if (http_transaction_factory()) { 115 if (http_transaction_factory()) {
125 // Make sure we haven't been passed an object we're not going to use. 116 // Make sure we haven't been passed an object we're not going to use.
126 EXPECT_FALSE(client_socket_factory_); 117 EXPECT_FALSE(client_socket_factory_);
127 } else { 118 } else {
128 HttpNetworkSession::Params params; 119 HttpNetworkSession::Params params;
129 120
130 if (http_network_session_params_) 121 if (http_network_session_params_)
131 params = *http_network_session_params_; 122 params = *http_network_session_params_;
132 params.client_socket_factory = client_socket_factory(); 123 params.client_socket_factory = client_socket_factory();
133 params.proxy_delegate = proxy_delegate(); 124 params.proxy_delegate = proxy_delegate();
134 params.host_resolver = host_resolver(); 125 params.host_resolver = host_resolver();
135 params.cert_verifier = cert_verifier(); 126 params.cert_verifier = cert_verifier();
136 params.cert_transparency_verifier = cert_transparency_verifier(); 127 params.cert_transparency_verifier = cert_transparency_verifier();
137 params.ct_policy_enforcer = ct_policy_enforcer(); 128 params.ct_policy_enforcer = ct_policy_enforcer();
138 params.transport_security_state = transport_security_state(); 129 params.transport_security_state = transport_security_state();
139 params.proxy_service = proxy_service(); 130 params.proxy_service = proxy_service();
140 params.ssl_config_service = ssl_config_service(); 131 params.ssl_config_service = ssl_config_service();
141 params.http_auth_handler_factory = http_auth_handler_factory(); 132 params.http_auth_handler_factory = http_auth_handler_factory();
142 params.http_server_properties = http_server_properties(); 133 params.http_server_properties = http_server_properties();
143 params.net_log = net_log(); 134 params.net_log = net_log();
144 params.channel_id_service = channel_id_service(); 135 params.channel_id_service = channel_id_service();
145 params.socket_performance_watcher_factory =
146 network_quality_estimator()->GetSocketPerformanceWatcherFactory();
147 context_storage_.set_http_network_session( 136 context_storage_.set_http_network_session(
148 base::MakeUnique<HttpNetworkSession>(params)); 137 base::MakeUnique<HttpNetworkSession>(params));
149 context_storage_.set_http_transaction_factory(base::MakeUnique<HttpCache>( 138 context_storage_.set_http_transaction_factory(base::MakeUnique<HttpCache>(
150 context_storage_.http_network_session(), 139 context_storage_.http_network_session(),
151 HttpCache::DefaultBackend::InMemory(0), false)); 140 HttpCache::DefaultBackend::InMemory(0), false));
152 } 141 }
153 if (!http_user_agent_settings()) { 142 if (!http_user_agent_settings()) {
154 context_storage_.set_http_user_agent_settings( 143 context_storage_.set_http_user_agent_settings(
155 base::MakeUnique<StaticHttpUserAgentSettings>("en-us,fr", 144 base::MakeUnique<StaticHttpUserAgentSettings>("en-us,fr",
156 std::string())); 145 std::string()));
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 NetworkDelegate* network_delegate) const { 672 NetworkDelegate* network_delegate) const {
684 return main_intercept_job_.release(); 673 return main_intercept_job_.release();
685 } 674 }
686 675
687 void TestJobInterceptor::set_main_intercept_job( 676 void TestJobInterceptor::set_main_intercept_job(
688 std::unique_ptr<URLRequestJob> job) { 677 std::unique_ptr<URLRequestJob> job) {
689 main_intercept_job_ = std::move(job); 678 main_intercept_job_ = std::move(job);
690 } 679 }
691 680
692 } // namespace net 681 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698