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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 URLRequestContextBuilder::URLRequestContextBuilder() 203 URLRequestContextBuilder::URLRequestContextBuilder()
204 : data_enabled_(false), 204 : data_enabled_(false),
205 #if !defined(DISABLE_FILE_SUPPORT) 205 #if !defined(DISABLE_FILE_SUPPORT)
206 file_enabled_(false), 206 file_enabled_(false),
207 #endif 207 #endif
208 #if !defined(DISABLE_FTP_SUPPORT) 208 #if !defined(DISABLE_FTP_SUPPORT)
209 ftp_enabled_(false), 209 ftp_enabled_(false),
210 #endif 210 #endif
211 http_cache_enabled_(true), 211 http_cache_enabled_(true),
212 throttling_enabled_(false), 212 throttling_enabled_(false) {
213 channel_id_enabled_(true) {
214 } 213 }
215 214
216 URLRequestContextBuilder::~URLRequestContextBuilder() {} 215 URLRequestContextBuilder::~URLRequestContextBuilder() {}
217 216
218 void URLRequestContextBuilder::EnableHttpCache(const HttpCacheParams& params) { 217 void URLRequestContextBuilder::EnableHttpCache(const HttpCacheParams& params) {
219 http_cache_enabled_ = true; 218 http_cache_enabled_ = true;
220 http_cache_params_ = params; 219 http_cache_params_ = params;
221 } 220 }
222 221
223 void URLRequestContextBuilder::DisableHttpCache() { 222 void URLRequestContextBuilder::DisableHttpCache() {
224 http_cache_enabled_ = false; 223 http_cache_enabled_ = false;
225 http_cache_params_ = HttpCacheParams(); 224 http_cache_params_ = HttpCacheParams();
226 } 225 }
227 226
228 void URLRequestContextBuilder::SetSpdyAndQuicEnabled(bool spdy_enabled, 227 void URLRequestContextBuilder::SetSpdyAndQuicEnabled(bool spdy_enabled,
229 bool quic_enabled) { 228 bool quic_enabled) {
230 http_network_session_params_.next_protos = 229 http_network_session_params_.next_protos =
231 NextProtosWithSpdyAndQuic(spdy_enabled, quic_enabled); 230 NextProtosWithSpdyAndQuic(spdy_enabled, quic_enabled);
232 http_network_session_params_.enable_quic = quic_enabled; 231 http_network_session_params_.enable_quic = quic_enabled;
233 } 232 }
234 233
234 void URLRequestContextBuilder::SetCookieAndChannelIdStores(
235 const scoped_refptr<CookieStore>& cookie_store,
236 scoped_ptr<ChannelIDService> channel_id_service) {
237 DCHECK(cookie_store);
238 cookie_store_ = cookie_store;
239 channel_id_service_ = channel_id_service.Pass();
240 }
241
235 URLRequestContext* URLRequestContextBuilder::Build() { 242 URLRequestContext* URLRequestContextBuilder::Build() {
236 BasicURLRequestContext* context = new BasicURLRequestContext; 243 BasicURLRequestContext* context = new BasicURLRequestContext;
237 URLRequestContextStorage* storage = context->storage(); 244 URLRequestContextStorage* storage = context->storage();
238 245
239 storage->set_http_user_agent_settings(new StaticHttpUserAgentSettings( 246 storage->set_http_user_agent_settings(new StaticHttpUserAgentSettings(
240 accept_language_, user_agent_)); 247 accept_language_, user_agent_));
241 248
242 if (!network_delegate_) 249 if (!network_delegate_)
243 network_delegate_.reset(new BasicNetworkDelegate); 250 network_delegate_.reset(new BasicNetworkDelegate);
244 NetworkDelegate* network_delegate = network_delegate_.release(); 251 NetworkDelegate* network_delegate = network_delegate_.release();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); 290 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
284 HttpAuthHandlerRegistryFactory* http_auth_handler_registry_factory = 291 HttpAuthHandlerRegistryFactory* http_auth_handler_registry_factory =
285 net::HttpAuthHandlerRegistryFactory::CreateDefault( 292 net::HttpAuthHandlerRegistryFactory::CreateDefault(
286 context->host_resolver()); 293 context->host_resolver());
287 for (size_t i = 0; i < extra_http_auth_handlers_.size(); ++i) { 294 for (size_t i = 0; i < extra_http_auth_handlers_.size(); ++i) {
288 http_auth_handler_registry_factory->RegisterSchemeFactory( 295 http_auth_handler_registry_factory->RegisterSchemeFactory(
289 extra_http_auth_handlers_[i].scheme, 296 extra_http_auth_handlers_[i].scheme,
290 extra_http_auth_handlers_[i].factory); 297 extra_http_auth_handlers_[i].factory);
291 } 298 }
292 storage->set_http_auth_handler_factory(http_auth_handler_registry_factory); 299 storage->set_http_auth_handler_factory(http_auth_handler_registry_factory);
293 storage->set_cookie_store(new CookieMonster(NULL, NULL));
294 300
295 if (channel_id_enabled_) { 301 if (cookie_store_) {
302 storage->set_cookie_store(cookie_store_.get());
303 storage->set_channel_id_service(channel_id_service_.Pass());
304 } else {
305 storage->set_cookie_store(new CookieMonster(NULL, NULL));
296 // TODO(mmenke): This always creates a file thread, even when it ends up 306 // TODO(mmenke): This always creates a file thread, even when it ends up
297 // not being used. Consider lazily creating the thread. 307 // not being used. Consider lazily creating the thread.
298 storage->set_channel_id_service( 308 storage->set_channel_id_service(make_scoped_ptr(
299 new ChannelIDService( 309 new ChannelIDService(new DefaultChannelIDStore(NULL),
300 new DefaultChannelIDStore(NULL), 310 context->GetFileThread()->message_loop_proxy())));
301 context->GetFileThread()->message_loop_proxy()));
302 } 311 }
303 312
304 storage->set_transport_security_state(new net::TransportSecurityState()); 313 storage->set_transport_security_state(new net::TransportSecurityState());
305 if (!transport_security_persister_path_.empty()) { 314 if (!transport_security_persister_path_.empty()) {
306 context->set_transport_security_persister( 315 context->set_transport_security_persister(
307 make_scoped_ptr<TransportSecurityPersister>( 316 make_scoped_ptr<TransportSecurityPersister>(
308 new TransportSecurityPersister( 317 new TransportSecurityPersister(
309 context->transport_security_state(), 318 context->transport_security_state(),
310 transport_security_persister_path_, 319 transport_security_persister_path_,
311 context->GetFileThread()->message_loop_proxy(), 320 context->GetFileThread()->message_loop_proxy(),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 #endif // !defined(DISABLE_FTP_SUPPORT) 410 #endif // !defined(DISABLE_FTP_SUPPORT)
402 411
403 storage->set_job_factory(job_factory); 412 storage->set_job_factory(job_factory);
404 413
405 // TODO(willchan): Support sdch. 414 // TODO(willchan): Support sdch.
406 415
407 return context; 416 return context;
408 } 417 }
409 418
410 } // namespace net 419 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698