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

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

Issue 10831277: [net] Change factory methods for HostResolver and HostCache to return a scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary initialization; respond to review Created 8 years, 2 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 | Annotate | Revision Log
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_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 private: 164 private:
165 std::string user_agent_; 165 std::string user_agent_;
166 base::Thread cache_thread_; 166 base::Thread cache_thread_;
167 base::Thread file_thread_; 167 base::Thread file_thread_;
168 URLRequestContextStorage storage_; 168 URLRequestContextStorage storage_;
169 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); 169 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext);
170 }; 170 };
171 171
172 } // namespace 172 } // namespace
173 173
174 URLRequestContextBuilder::HostResolverParams::HostResolverParams()
175 : parallelism(HostResolver::kDefaultParallelism),
176 retry_attempts(HostResolver::kDefaultRetryAttempts) {}
177 URLRequestContextBuilder::HostResolverParams::~HostResolverParams() {}
178
179 URLRequestContextBuilder::HttpCacheParams::HttpCacheParams() 174 URLRequestContextBuilder::HttpCacheParams::HttpCacheParams()
180 : type(IN_MEMORY), 175 : type(IN_MEMORY),
181 max_size(0) {} 176 max_size(0) {}
182 URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {} 177 URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {}
183 178
184 URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams() 179 URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams()
185 : ignore_certificate_errors(false), 180 : ignore_certificate_errors(false),
186 host_mapping_rules(NULL), 181 host_mapping_rules(NULL),
187 http_pipelining_enabled(false), 182 http_pipelining_enabled(false),
188 testing_fixed_http_port(0), 183 testing_fixed_http_port(0),
(...skipping 17 matching lines...) Expand all
206 201
207 URLRequestContext* URLRequestContextBuilder::Build() { 202 URLRequestContext* URLRequestContextBuilder::Build() {
208 BasicURLRequestContext* context = new BasicURLRequestContext; 203 BasicURLRequestContext* context = new BasicURLRequestContext;
209 URLRequestContextStorage* storage = context->storage(); 204 URLRequestContextStorage* storage = context->storage();
210 205
211 context->set_user_agent(user_agent_); 206 context->set_user_agent(user_agent_);
212 207
213 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate; 208 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate;
214 storage->set_network_delegate(network_delegate); 209 storage->set_network_delegate(network_delegate);
215 210
216 net::HostResolver* host_resolver = net::CreateSystemHostResolver( 211 storage->set_host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
217 host_resolver_params_.parallelism,
218 host_resolver_params_.retry_attempts,
219 NULL /* no NetLog */);
220 storage->set_host_resolver(host_resolver);
221 212
222 if (ftp_enabled_) { 213 if (ftp_enabled_) {
223 storage->set_ftp_transaction_factory(new FtpNetworkLayer(host_resolver)); 214 storage->set_ftp_transaction_factory(
215 new FtpNetworkLayer(context->host_resolver()));
224 } 216 }
225 217
226 context->StartFileThread(); 218 context->StartFileThread();
227 219
228 // TODO(willchan): Switch to using this code when 220 // TODO(willchan): Switch to using this code when
229 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck. 221 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
230 #if defined(OS_LINUX) 222 #if defined(OS_LINUX)
231 ProxyConfigService* proxy_config_service = proxy_config_service_.release(); 223 ProxyConfigService* proxy_config_service = proxy_config_service_.release();
232 #else 224 #else
233 ProxyConfigService* proxy_config_service = 225 ProxyConfigService* proxy_config_service =
234 ProxyService::CreateSystemProxyConfigService( 226 ProxyService::CreateSystemProxyConfigService(
235 base::ThreadTaskRunnerHandle::Get(), 227 base::ThreadTaskRunnerHandle::Get(),
236 context->file_message_loop()); 228 context->file_message_loop());
237 #endif // defined(OS_LINUX) 229 #endif // defined(OS_LINUX)
238 storage->set_proxy_service( 230 storage->set_proxy_service(
239 ProxyService::CreateUsingSystemProxyResolver( 231 ProxyService::CreateUsingSystemProxyResolver(
240 proxy_config_service, 232 proxy_config_service,
241 4, // TODO(willchan): Find a better constant somewhere. 233 4, // TODO(willchan): Find a better constant somewhere.
242 context->net_log())); 234 context->net_log()));
243 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); 235 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
244 storage->set_http_auth_handler_factory( 236 storage->set_http_auth_handler_factory(
245 net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver)); 237 net::HttpAuthHandlerRegistryFactory::CreateDefault(
238 context->host_resolver()));
246 storage->set_cookie_store(new CookieMonster(NULL, NULL)); 239 storage->set_cookie_store(new CookieMonster(NULL, NULL));
247 storage->set_transport_security_state(new net::TransportSecurityState()); 240 storage->set_transport_security_state(new net::TransportSecurityState());
248 storage->set_http_server_properties(new net::HttpServerPropertiesImpl); 241 storage->set_http_server_properties(new net::HttpServerPropertiesImpl);
249 storage->set_cert_verifier(CertVerifier::CreateDefault()); 242 storage->set_cert_verifier(CertVerifier::CreateDefault());
250 243
251 net::HttpNetworkSession::Params network_session_params; 244 net::HttpNetworkSession::Params network_session_params;
252 network_session_params.host_resolver = host_resolver; 245 network_session_params.host_resolver = context->host_resolver();
253 network_session_params.cert_verifier = context->cert_verifier(); 246 network_session_params.cert_verifier = context->cert_verifier();
254 network_session_params.transport_security_state = 247 network_session_params.transport_security_state =
255 context->transport_security_state(); 248 context->transport_security_state();
256 network_session_params.proxy_service = context->proxy_service(); 249 network_session_params.proxy_service = context->proxy_service();
257 network_session_params.ssl_config_service = 250 network_session_params.ssl_config_service =
258 context->ssl_config_service(); 251 context->ssl_config_service();
259 network_session_params.http_auth_handler_factory = 252 network_session_params.http_auth_handler_factory =
260 context->http_auth_handler_factory(); 253 context->http_auth_handler_factory();
261 network_session_params.network_delegate = 254 network_session_params.network_delegate =
262 context->network_delegate(); 255 context->network_delegate();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 http_transaction_factory = new HttpNetworkLayer(network_session); 295 http_transaction_factory = new HttpNetworkLayer(network_session);
303 } 296 }
304 storage->set_http_transaction_factory(http_transaction_factory); 297 storage->set_http_transaction_factory(http_transaction_factory);
305 298
306 // TODO(willchan): Support sdch. 299 // TODO(willchan): Support sdch.
307 300
308 return context; 301 return context;
309 } 302 }
310 303
311 } // namespace net 304 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_builder.h ('k') | net/url_request/url_request_context_storage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698