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

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: add ChromeBrowserFieldTrials::AsyncDnsFieldTrial Created 8 years, 4 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::URLRequestContextBuilder() 179 URLRequestContextBuilder::URLRequestContextBuilder()
185 : ftp_enabled_(false), 180 : ftp_enabled_(false),
186 http_cache_enabled_(true) {} 181 http_cache_enabled_(true) {}
187 URLRequestContextBuilder::~URLRequestContextBuilder() {} 182 URLRequestContextBuilder::~URLRequestContextBuilder() {}
188 183
189 #if defined(OS_LINUX) 184 #if defined(OS_LINUX)
190 void URLRequestContextBuilder::set_proxy_config_service( 185 void URLRequestContextBuilder::set_proxy_config_service(
191 ProxyConfigService* proxy_config_service) { 186 ProxyConfigService* proxy_config_service) {
192 proxy_config_service_.reset(proxy_config_service); 187 proxy_config_service_.reset(proxy_config_service);
193 } 188 }
194 #endif // defined(OS_LINUX) 189 #endif // defined(OS_LINUX)
195 190
196 URLRequestContext* URLRequestContextBuilder::Build() { 191 URLRequestContext* URLRequestContextBuilder::Build() {
197 BasicURLRequestContext* context = new BasicURLRequestContext; 192 BasicURLRequestContext* context = new BasicURLRequestContext;
198 URLRequestContextStorage* storage = context->storage(); 193 URLRequestContextStorage* storage = context->storage();
199 194
200 context->set_user_agent(user_agent_); 195 context->set_user_agent(user_agent_);
201 196
202 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate; 197 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate;
203 storage->set_network_delegate(network_delegate); 198 storage->set_network_delegate(network_delegate);
204 199
205 net::HostResolver* host_resolver = net::CreateSystemHostResolver( 200 storage->set_host_resolver(
206 host_resolver_params_.parallelism, 201 net::HostResolver::CreateDefaultResolver(NULL).release());
207 host_resolver_params_.retry_attempts,
208 NULL /* no NetLog */);
209 storage->set_host_resolver(host_resolver);
210 202
211 if (ftp_enabled_) { 203 if (ftp_enabled_) {
212 storage->set_ftp_transaction_factory(new FtpNetworkLayer(host_resolver)); 204 storage->set_ftp_transaction_factory(
205 new FtpNetworkLayer(context->host_resolver()));
213 } 206 }
214 207
215 context->StartFileThread(); 208 context->StartFileThread();
216 209
217 // TODO(willchan): Switch to using this code when 210 // TODO(willchan): Switch to using this code when
218 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck. 211 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
219 #if defined(OS_LINUX) 212 #if defined(OS_LINUX)
220 ProxyConfigService* proxy_config_service = proxy_config_service_.release(); 213 ProxyConfigService* proxy_config_service = proxy_config_service_.release();
221 #else 214 #else
222 ProxyConfigService* proxy_config_service = 215 ProxyConfigService* proxy_config_service =
223 ProxyService::CreateSystemProxyConfigService( 216 ProxyService::CreateSystemProxyConfigService(
224 base::ThreadTaskRunnerHandle::Get(), 217 base::ThreadTaskRunnerHandle::Get(),
225 context->file_message_loop()); 218 context->file_message_loop());
226 #endif // defined(OS_LINUX) 219 #endif // defined(OS_LINUX)
227 storage->set_proxy_service( 220 storage->set_proxy_service(
228 ProxyService::CreateUsingSystemProxyResolver( 221 ProxyService::CreateUsingSystemProxyResolver(
229 proxy_config_service, 222 proxy_config_service,
230 4, // TODO(willchan): Find a better constant somewhere. 223 4, // TODO(willchan): Find a better constant somewhere.
231 context->net_log())); 224 context->net_log()));
232 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); 225 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
233 storage->set_http_auth_handler_factory( 226 storage->set_http_auth_handler_factory(
234 net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver)); 227 net::HttpAuthHandlerRegistryFactory::CreateDefault(
228 context->host_resolver()));
235 storage->set_cookie_store(new CookieMonster(NULL, NULL)); 229 storage->set_cookie_store(new CookieMonster(NULL, NULL));
236 storage->set_transport_security_state(new net::TransportSecurityState()); 230 storage->set_transport_security_state(new net::TransportSecurityState());
237 storage->set_http_server_properties(new net::HttpServerPropertiesImpl); 231 storage->set_http_server_properties(new net::HttpServerPropertiesImpl);
238 storage->set_cert_verifier(CertVerifier::CreateDefault()); 232 storage->set_cert_verifier(CertVerifier::CreateDefault());
239 233
240 HttpTransactionFactory* http_transaction_factory = NULL; 234 HttpTransactionFactory* http_transaction_factory = NULL;
241 if (http_cache_enabled_) { 235 if (http_cache_enabled_) {
242 HttpCache::BackendFactory* http_cache_backend = NULL; 236 HttpCache::BackendFactory* http_cache_backend = NULL;
243 if (http_cache_params_.type == HttpCacheParams::DISK) { 237 if (http_cache_params_.type == HttpCacheParams::DISK) {
244 context->StartCacheThread(); 238 context->StartCacheThread();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 http_transaction_factory = new HttpNetworkLayer(network_session); 279 http_transaction_factory = new HttpNetworkLayer(network_session);
286 } 280 }
287 storage->set_http_transaction_factory(http_transaction_factory); 281 storage->set_http_transaction_factory(http_transaction_factory);
288 282
289 // TODO(willchan): Support sdch. 283 // TODO(willchan): Support sdch.
290 284
291 return context; 285 return context;
292 } 286 }
293 287
294 } // namespace net 288 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698