OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 private: | 391 private: |
392 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 392 scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
393 scoped_refptr<ChromeURLRequestContextGetter> original_context_getter_; | 393 scoped_refptr<ChromeURLRequestContextGetter> original_context_getter_; |
394 }; | 394 }; |
395 | 395 |
396 ChromeURLRequestContext* FactoryForOffTheRecord::Create() { | 396 ChromeURLRequestContext* FactoryForOffTheRecord::Create() { |
397 ChromeURLRequestContext* context = new ChromeURLRequestContext; | 397 ChromeURLRequestContext* context = new ChromeURLRequestContext; |
398 ApplyProfileParametersToContext(context); | 398 ApplyProfileParametersToContext(context); |
399 | 399 |
400 ChromeURLRequestContext* original_context = | 400 IOThread::Globals* io_thread_globals = io_thread()->globals(); |
401 original_context_getter_->GetIOContext(); | 401 context->set_host_resolver(io_thread_globals->host_resolver.get()); |
| 402 context->set_cert_verifier(io_thread_globals->cert_verifier.get()); |
| 403 context->set_http_auth_handler_factory( |
| 404 io_thread_globals->http_auth_handler_factory.get()); |
402 | 405 |
403 IOThread::Globals* io_thread_globals = io_thread()->globals(); | |
404 | |
405 // Share the same proxy service, host resolver, cert verifier, | |
406 // and http_auth_handler_factory as the original profile. | |
407 context->set_host_resolver(original_context->host_resolver()); | |
408 context->set_cert_verifier(original_context->cert_verifier()); | |
409 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 406 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
410 context->set_proxy_service( | 407 context->set_proxy_service( |
411 CreateProxyService(io_thread()->net_log(), | 408 CreateProxyService(io_thread()->net_log(), |
412 io_thread_globals->proxy_script_fetcher_context.get(), | 409 io_thread_globals->proxy_script_fetcher_context.get(), |
413 proxy_config_service_.release(), | 410 proxy_config_service_.release(), |
414 command_line)); | 411 command_line)); |
415 context->set_http_auth_handler_factory( | |
416 original_context->http_auth_handler_factory()); | |
417 | 412 |
418 net::HttpCache::BackendFactory* backend = | 413 net::HttpCache::BackendFactory* backend = |
419 net::HttpCache::DefaultBackend::InMemory(0); | 414 net::HttpCache::DefaultBackend::InMemory(0); |
420 | 415 |
421 net::HttpCache* cache = | 416 net::HttpCache* cache = |
422 new net::HttpCache(context->host_resolver(), | 417 new net::HttpCache(context->host_resolver(), |
423 context->cert_verifier(), | 418 context->cert_verifier(), |
424 context->dnsrr_resolver(), | 419 context->dnsrr_resolver(), |
425 NULL /* dns_cert_checker */, | 420 NULL /* dns_cert_checker */, |
426 context->proxy_service(), | 421 context->proxy_service(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 }; | 465 }; |
471 | 466 |
472 ChromeURLRequestContext* FactoryForMedia::Create() { | 467 ChromeURLRequestContext* FactoryForMedia::Create() { |
473 ChromeURLRequestContext* context = new ChromeURLRequestContext; | 468 ChromeURLRequestContext* context = new ChromeURLRequestContext; |
474 ApplyProfileParametersToContext(context); | 469 ApplyProfileParametersToContext(context); |
475 | 470 |
476 ChromeURLRequestContext* main_context = | 471 ChromeURLRequestContext* main_context = |
477 main_context_getter_->GetIOContext(); | 472 main_context_getter_->GetIOContext(); |
478 | 473 |
479 IOThread::Globals* io_thread_globals = io_thread()->globals(); | 474 IOThread::Globals* io_thread_globals = io_thread()->globals(); |
| 475 context->set_http_auth_handler_factory( |
| 476 io_thread_globals->http_auth_handler_factory.get()); |
480 | 477 |
481 // Share the same proxy service of the common profile. | 478 // TODO(willchan): Make a global ProxyService available in IOThread::Globals. |
482 context->set_proxy_service(main_context->proxy_service()); | 479 context->set_proxy_service(main_context->proxy_service()); |
483 context->set_http_auth_handler_factory( | |
484 main_context->http_auth_handler_factory()); | |
485 | 480 |
486 // Also share the cookie store of the common profile. | 481 // Also share the cookie store of the common profile. |
487 context->set_cookie_store(main_context->cookie_store()); | 482 context->set_cookie_store(main_context->cookie_store()); |
488 context->set_cookie_policy( | 483 context->set_cookie_policy( |
489 static_cast<ChromeCookiePolicy*>(main_context->cookie_policy())); | 484 static_cast<ChromeCookiePolicy*>(main_context->cookie_policy())); |
490 | 485 |
491 // Create a media cache with default size. | 486 // Create a media cache with default size. |
492 // TODO(hclam): make the maximum size of media cache configurable. | 487 // TODO(hclam): make the maximum size of media cache configurable. |
493 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( | 488 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( |
494 net::MEDIA_CACHE, disk_cache_path_, cache_size_, | 489 net::MEDIA_CACHE, disk_cache_path_, cache_size_, |
(...skipping 10 matching lines...) Expand all Loading... |
505 // HttpCache(HttpTransactionFactory*, BackendFactory*) constructor. | 500 // HttpCache(HttpTransactionFactory*, BackendFactory*) constructor. |
506 net::HttpNetworkLayer* main_network_layer = | 501 net::HttpNetworkLayer* main_network_layer = |
507 static_cast<net::HttpNetworkLayer*>(main_cache->network_layer()); | 502 static_cast<net::HttpNetworkLayer*>(main_cache->network_layer()); |
508 cache = new net::HttpCache(main_network_layer->GetSession(), backend); | 503 cache = new net::HttpCache(main_network_layer->GetSession(), backend); |
509 // TODO(eroman): Since this is poaching the session from the main | 504 // TODO(eroman): Since this is poaching the session from the main |
510 // context, it should hold a reference to that context preventing the | 505 // context, it should hold a reference to that context preventing the |
511 // session from getting deleted. | 506 // session from getting deleted. |
512 } else { | 507 } else { |
513 // If original HttpCache doesn't exist, simply construct one with a whole | 508 // If original HttpCache doesn't exist, simply construct one with a whole |
514 // new set of network stack. | 509 // new set of network stack. |
515 cache = new net::HttpCache(main_context->host_resolver(), | 510 cache = new net::HttpCache( |
516 main_context->cert_verifier(), | 511 io_thread_globals->host_resolver.get(), |
517 main_context->dnsrr_resolver(), | 512 io_thread_globals->cert_verifier.get(), |
518 NULL /* dns_cert_checker */, | 513 io_thread_globals->dnsrr_resolver.get(), |
519 main_context->proxy_service(), | 514 NULL /* dns_cert_checker */, |
520 main_context->ssl_config_service(), | 515 main_context->proxy_service(), |
521 main_context->http_auth_handler_factory(), | 516 main_context->ssl_config_service(), |
522 &io_thread_globals->network_delegate, | 517 io_thread_globals->http_auth_handler_factory.get(), |
523 io_thread()->net_log(), | 518 &io_thread_globals->network_delegate, |
524 backend); | 519 io_thread()->net_log(), |
| 520 backend); |
525 } | 521 } |
526 | 522 |
527 context->set_http_transaction_factory(cache); | 523 context->set_http_transaction_factory(cache); |
528 context->set_net_log(io_thread()->net_log()); | 524 context->set_net_log(io_thread()->net_log()); |
529 | 525 |
530 return context; | 526 return context; |
531 } | 527 } |
532 | 528 |
533 } // namespace | 529 } // namespace |
534 | 530 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 context->set_transport_security_state( | 907 context->set_transport_security_state( |
912 transport_security_state_); | 908 transport_security_state_); |
913 context->set_ssl_config_service(ssl_config_service_); | 909 context->set_ssl_config_service(ssl_config_service_); |
914 context->set_appcache_service(appcache_service_); | 910 context->set_appcache_service(appcache_service_); |
915 context->set_database_tracker(database_tracker_); | 911 context->set_database_tracker(database_tracker_); |
916 context->set_blob_storage_context(blob_storage_context_); | 912 context->set_blob_storage_context(blob_storage_context_); |
917 context->set_file_system_context(file_system_context_); | 913 context->set_file_system_context(file_system_context_); |
918 context->set_extension_info_map(extension_info_map_); | 914 context->set_extension_info_map(extension_info_map_); |
919 context->set_prerender_manager(prerender_manager_); | 915 context->set_prerender_manager(prerender_manager_); |
920 } | 916 } |
OLD | NEW |