OLD | NEW |
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 "chrome/browser/profiles/profile_impl_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 main_context->set_server_bound_cert_service(server_bound_cert_service); | 448 main_context->set_server_bound_cert_service(server_bound_cert_service); |
449 | 449 |
450 net::HttpCache::DefaultBackend* main_backend = | 450 net::HttpCache::DefaultBackend* main_backend = |
451 new net::HttpCache::DefaultBackend( | 451 new net::HttpCache::DefaultBackend( |
452 net::DISK_CACHE, | 452 net::DISK_CACHE, |
453 ChooseCacheBackendType(), | 453 ChooseCacheBackendType(), |
454 lazy_params_->cache_path, | 454 lazy_params_->cache_path, |
455 lazy_params_->cache_max_size, | 455 lazy_params_->cache_max_size, |
456 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 456 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
457 .get()); | 457 .get()); |
458 net::HttpNetworkSession::Params network_session_params; | 458 scoped_ptr<net::HttpCache> main_cache = CreateMainHttpFactory( |
459 PopulateNetworkSessionParams(profile_params, &network_session_params); | 459 profile_params, main_backend); |
460 net::HttpCache* main_cache = new net::HttpCache( | |
461 network_session_params, main_backend); | |
462 main_cache->InitializeInfiniteCache(lazy_params_->infinite_cache_path); | 460 main_cache->InitializeInfiniteCache(lazy_params_->infinite_cache_path); |
463 | 461 |
464 #if defined(OS_ANDROID) || defined(OS_IOS) | 462 #if defined(OS_ANDROID) || defined(OS_IOS) |
465 data_reduction_proxy::DataReductionProxySettings:: | 463 data_reduction_proxy::DataReductionProxySettings:: |
466 InitDataReductionProxySession(main_cache->GetSession()); | 464 InitDataReductionProxySession(main_cache->GetSession()); |
467 #endif | 465 #endif |
468 | 466 |
469 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { | 467 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
470 main_cache->set_mode( | 468 main_cache->set_mode( |
471 chrome_browser_net::IsCookieRecordMode() ? | 469 chrome_browser_net::IsCookieRecordMode() ? |
472 net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 470 net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
473 } | 471 } |
474 | 472 |
475 main_http_factory_.reset(main_cache); | 473 main_http_factory_.reset(main_cache.release()); |
476 main_context->set_http_transaction_factory(main_cache); | 474 main_context->set_http_transaction_factory(main_http_factory_.get()); |
477 | 475 |
478 #if !defined(DISABLE_FTP_SUPPORT) | 476 #if !defined(DISABLE_FTP_SUPPORT) |
479 ftp_factory_.reset( | 477 ftp_factory_.reset( |
480 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 478 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
481 #endif // !defined(DISABLE_FTP_SUPPORT) | 479 #endif // !defined(DISABLE_FTP_SUPPORT) |
482 | 480 |
483 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 481 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
484 new net::URLRequestJobFactoryImpl()); | 482 new net::URLRequestJobFactoryImpl()); |
485 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 483 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
486 main_job_factory_ = SetUpJobFactoryDefaults( | 484 main_job_factory_ = SetUpJobFactoryDefaults( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 app_backend = new net::HttpCache::DefaultBackend( | 578 app_backend = new net::HttpCache::DefaultBackend( |
581 net::DISK_CACHE, | 579 net::DISK_CACHE, |
582 ChooseCacheBackendType(), | 580 ChooseCacheBackendType(), |
583 cache_path, | 581 cache_path, |
584 app_cache_max_size_, | 582 app_cache_max_size_, |
585 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 583 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
586 .get()); | 584 .get()); |
587 } | 585 } |
588 net::HttpNetworkSession* main_network_session = | 586 net::HttpNetworkSession* main_network_session = |
589 main_http_factory_->GetSession(); | 587 main_http_factory_->GetSession(); |
590 net::HttpCache* app_http_cache = | 588 scoped_ptr<net::HttpCache> app_http_cache = |
591 new net::HttpCache(main_network_session, app_backend); | 589 CreateHttpFactory(main_network_session, app_backend); |
592 | 590 |
593 scoped_refptr<net::CookieStore> cookie_store = NULL; | 591 scoped_refptr<net::CookieStore> cookie_store = NULL; |
594 if (partition_descriptor.in_memory) { | 592 if (partition_descriptor.in_memory) { |
595 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 593 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
596 } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { | 594 } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
597 // Don't use existing cookies and use an in-memory store. | 595 // Don't use existing cookies and use an in-memory store. |
598 // TODO(creis): We should have a cookie delegate for notifying the cookie | 596 // TODO(creis): We should have a cookie delegate for notifying the cookie |
599 // extensions API, but we need to update it to understand isolated apps | 597 // extensions API, but we need to update it to understand isolated apps |
600 // first. | 598 // first. |
601 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 599 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
(...skipping 14 matching lines...) Expand all Loading... |
616 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, | 614 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
617 NULL, NULL); | 615 NULL, NULL); |
618 cookie_config.crypto_delegate = | 616 cookie_config.crypto_delegate = |
619 chrome_browser_net::GetCookieCryptoDelegate(); | 617 chrome_browser_net::GetCookieCryptoDelegate(); |
620 cookie_store = content::CreateCookieStore(cookie_config); | 618 cookie_store = content::CreateCookieStore(cookie_config); |
621 } | 619 } |
622 | 620 |
623 // Transfer ownership of the cookies and cache to AppRequestContext. | 621 // Transfer ownership of the cookies and cache to AppRequestContext. |
624 context->SetCookieStore(cookie_store.get()); | 622 context->SetCookieStore(cookie_store.get()); |
625 context->SetHttpTransactionFactory( | 623 context->SetHttpTransactionFactory( |
626 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 624 scoped_ptr<net::HttpTransactionFactory>( |
| 625 app_http_cache.PassAs<net::HttpTransactionFactory>())); |
627 | 626 |
628 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 627 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
629 new net::URLRequestJobFactoryImpl()); | 628 new net::URLRequestJobFactoryImpl()); |
630 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 629 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
631 scoped_ptr<net::URLRequestJobFactory> top_job_factory( | 630 scoped_ptr<net::URLRequestJobFactory> top_job_factory( |
632 SetUpJobFactoryDefaults(job_factory.Pass(), | 631 SetUpJobFactoryDefaults(job_factory.Pass(), |
633 protocol_interceptors.Pass(), | 632 protocol_interceptors.Pass(), |
634 protocol_handler_interceptor.Pass(), | 633 protocol_handler_interceptor.Pass(), |
635 network_delegate(), | 634 network_delegate(), |
636 ftp_factory_.get())); | 635 ftp_factory_.get())); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 net::HttpCache::BackendFactory* media_backend = | 668 net::HttpCache::BackendFactory* media_backend = |
670 new net::HttpCache::DefaultBackend( | 669 new net::HttpCache::DefaultBackend( |
671 net::MEDIA_CACHE, | 670 net::MEDIA_CACHE, |
672 ChooseCacheBackendType(), | 671 ChooseCacheBackendType(), |
673 cache_path, | 672 cache_path, |
674 cache_max_size, | 673 cache_max_size, |
675 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 674 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
676 .get()); | 675 .get()); |
677 net::HttpNetworkSession* main_network_session = | 676 net::HttpNetworkSession* main_network_session = |
678 main_http_factory_->GetSession(); | 677 main_http_factory_->GetSession(); |
679 scoped_ptr<net::HttpTransactionFactory> media_http_cache( | 678 scoped_ptr<net::HttpCache> media_http_cache = |
680 new net::HttpCache(main_network_session, media_backend)); | 679 CreateHttpFactory(main_network_session, media_backend); |
681 | 680 |
682 // Transfer ownership of the cache to MediaRequestContext. | 681 // Transfer ownership of the cache to MediaRequestContext. |
683 context->SetHttpTransactionFactory(media_http_cache.Pass()); | 682 context->SetHttpTransactionFactory( |
| 683 media_http_cache.PassAs<net::HttpTransactionFactory>()); |
684 | 684 |
685 // Note that we do not create a new URLRequestJobFactory because | 685 // Note that we do not create a new URLRequestJobFactory because |
686 // the media context should behave exactly like its parent context | 686 // the media context should behave exactly like its parent context |
687 // in all respects except for cache behavior on media subresources. | 687 // in all respects except for cache behavior on media subresources. |
688 // The CopyFrom() step above means that our media context will use | 688 // The CopyFrom() step above means that our media context will use |
689 // the same URLRequestJobFactory instance that our parent context does. | 689 // the same URLRequestJobFactory instance that our parent context does. |
690 | 690 |
691 return context; | 691 return context; |
692 } | 692 } |
693 | 693 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 const base::Closure& completion) { | 731 const base::Closure& completion) { |
732 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 732 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
733 DCHECK(initialized()); | 733 DCHECK(initialized()); |
734 | 734 |
735 DCHECK(transport_security_state()); | 735 DCHECK(transport_security_state()); |
736 // Completes synchronously. | 736 // Completes synchronously. |
737 transport_security_state()->DeleteAllDynamicDataSince(time); | 737 transport_security_state()->DeleteAllDynamicDataSince(time); |
738 DCHECK(http_server_properties_manager_); | 738 DCHECK(http_server_properties_manager_); |
739 http_server_properties_manager_->Clear(completion); | 739 http_server_properties_manager_->Clear(completion); |
740 } | 740 } |
OLD | NEW |