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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 DCHECK(app_iter != app_request_context_getter_map_.end()); | 289 DCHECK(app_iter != app_request_context_getter_map_.end()); |
290 ChromeURLRequestContextGetter* app_context = app_iter->second.get(); | 290 ChromeURLRequestContextGetter* app_context = app_iter->second.get(); |
291 ChromeURLRequestContextGetter* context = | 291 ChromeURLRequestContextGetter* context = |
292 ChromeURLRequestContextGetter::CreateForIsolatedMedia( | 292 ChromeURLRequestContextGetter::CreateForIsolatedMedia( |
293 profile_, app_context, io_data_, descriptor); | 293 profile_, app_context, io_data_, descriptor); |
294 isolated_media_request_context_getter_map_[descriptor] = context; | 294 isolated_media_request_context_getter_map_[descriptor] = context; |
295 | 295 |
296 return context; | 296 return context; |
297 } | 297 } |
298 | 298 |
| 299 DevToolsNetworkController* |
| 300 ProfileImplIOData::Handle::GetDevToolsNetworkController() const { |
| 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 302 return io_data_->network_controller(); |
| 303 } |
| 304 |
299 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( | 305 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( |
300 base::Time time, | 306 base::Time time, |
301 const base::Closure& completion) { | 307 const base::Closure& completion) { |
302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
303 LazyInitialize(); | 309 LazyInitialize(); |
304 | 310 |
305 BrowserThread::PostTask( | 311 BrowserThread::PostTask( |
306 BrowserThread::IO, FROM_HERE, | 312 BrowserThread::IO, FROM_HERE, |
307 base::Bind( | 313 base::Bind( |
308 &ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread, | 314 &ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 main_context->set_server_bound_cert_service(server_bound_cert_service); | 473 main_context->set_server_bound_cert_service(server_bound_cert_service); |
468 | 474 |
469 net::HttpCache::DefaultBackend* main_backend = | 475 net::HttpCache::DefaultBackend* main_backend = |
470 new net::HttpCache::DefaultBackend( | 476 new net::HttpCache::DefaultBackend( |
471 net::DISK_CACHE, | 477 net::DISK_CACHE, |
472 ChooseCacheBackendType(), | 478 ChooseCacheBackendType(), |
473 lazy_params_->cache_path, | 479 lazy_params_->cache_path, |
474 lazy_params_->cache_max_size, | 480 lazy_params_->cache_max_size, |
475 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 481 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
476 .get()); | 482 .get()); |
477 net::HttpNetworkSession::Params network_session_params; | 483 scoped_ptr<net::HttpCache> main_cache = CreateMainHttpFactory( |
478 PopulateNetworkSessionParams(profile_params, &network_session_params); | 484 profile_params, main_backend); |
479 net::HttpCache* main_cache = new net::HttpCache( | |
480 network_session_params, main_backend); | |
481 main_cache->InitializeInfiniteCache(lazy_params_->infinite_cache_path); | 485 main_cache->InitializeInfiniteCache(lazy_params_->infinite_cache_path); |
482 | 486 |
483 #if defined(OS_ANDROID) || defined(OS_IOS) | 487 #if defined(OS_ANDROID) || defined(OS_IOS) |
484 #if defined(SPDY_PROXY_AUTH_VALUE) | 488 #if defined(SPDY_PROXY_AUTH_VALUE) |
485 data_reduction_proxy::DataReductionProxySettings:: | 489 data_reduction_proxy::DataReductionProxySettings:: |
486 InitDataReductionProxySession( | 490 InitDataReductionProxySession( |
487 main_cache->GetSession(), | 491 main_cache->GetSession(), |
488 io_thread_globals->data_reduction_proxy_params.get()); | 492 io_thread_globals->data_reduction_proxy_params.get()); |
489 #endif | 493 #endif |
490 #endif | 494 #endif |
491 | 495 |
492 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { | 496 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
493 main_cache->set_mode( | 497 main_cache->set_mode( |
494 chrome_browser_net::IsCookieRecordMode() ? | 498 chrome_browser_net::IsCookieRecordMode() ? |
495 net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 499 net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
496 } | 500 } |
497 | 501 |
498 main_http_factory_.reset(main_cache); | 502 main_http_factory_.reset(main_cache.release()); |
499 main_context->set_http_transaction_factory(main_cache); | 503 main_context->set_http_transaction_factory(main_http_factory_.get()); |
500 | 504 |
501 #if !defined(DISABLE_FTP_SUPPORT) | 505 #if !defined(DISABLE_FTP_SUPPORT) |
502 ftp_factory_.reset( | 506 ftp_factory_.reset( |
503 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 507 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
504 #endif // !defined(DISABLE_FTP_SUPPORT) | 508 #endif // !defined(DISABLE_FTP_SUPPORT) |
505 | 509 |
506 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 510 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
507 new net::URLRequestJobFactoryImpl()); | 511 new net::URLRequestJobFactoryImpl()); |
508 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 512 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
509 main_job_factory_ = SetUpJobFactoryDefaults( | 513 main_job_factory_ = SetUpJobFactoryDefaults( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 app_backend = new net::HttpCache::DefaultBackend( | 609 app_backend = new net::HttpCache::DefaultBackend( |
606 net::DISK_CACHE, | 610 net::DISK_CACHE, |
607 ChooseCacheBackendType(), | 611 ChooseCacheBackendType(), |
608 cache_path, | 612 cache_path, |
609 app_cache_max_size_, | 613 app_cache_max_size_, |
610 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 614 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
611 .get()); | 615 .get()); |
612 } | 616 } |
613 net::HttpNetworkSession* main_network_session = | 617 net::HttpNetworkSession* main_network_session = |
614 main_http_factory_->GetSession(); | 618 main_http_factory_->GetSession(); |
615 net::HttpCache* app_http_cache = | 619 scoped_ptr<net::HttpCache> app_http_cache = |
616 new net::HttpCache(main_network_session, app_backend); | 620 CreateHttpFactory(main_network_session, app_backend); |
617 | 621 |
618 scoped_refptr<net::CookieStore> cookie_store = NULL; | 622 scoped_refptr<net::CookieStore> cookie_store = NULL; |
619 if (partition_descriptor.in_memory) { | 623 if (partition_descriptor.in_memory) { |
620 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 624 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
621 } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { | 625 } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
622 // Don't use existing cookies and use an in-memory store. | 626 // Don't use existing cookies and use an in-memory store. |
623 // TODO(creis): We should have a cookie delegate for notifying the cookie | 627 // TODO(creis): We should have a cookie delegate for notifying the cookie |
624 // extensions API, but we need to update it to understand isolated apps | 628 // extensions API, but we need to update it to understand isolated apps |
625 // first. | 629 // first. |
626 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 630 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
(...skipping 14 matching lines...) Expand all Loading... |
641 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, | 645 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
642 NULL, NULL); | 646 NULL, NULL); |
643 cookie_config.crypto_delegate = | 647 cookie_config.crypto_delegate = |
644 chrome_browser_net::GetCookieCryptoDelegate(); | 648 chrome_browser_net::GetCookieCryptoDelegate(); |
645 cookie_store = content::CreateCookieStore(cookie_config); | 649 cookie_store = content::CreateCookieStore(cookie_config); |
646 } | 650 } |
647 | 651 |
648 // Transfer ownership of the cookies and cache to AppRequestContext. | 652 // Transfer ownership of the cookies and cache to AppRequestContext. |
649 context->SetCookieStore(cookie_store.get()); | 653 context->SetCookieStore(cookie_store.get()); |
650 context->SetHttpTransactionFactory( | 654 context->SetHttpTransactionFactory( |
651 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 655 scoped_ptr<net::HttpTransactionFactory>( |
| 656 app_http_cache.PassAs<net::HttpTransactionFactory>())); |
652 | 657 |
653 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 658 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
654 new net::URLRequestJobFactoryImpl()); | 659 new net::URLRequestJobFactoryImpl()); |
655 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 660 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
656 scoped_ptr<net::URLRequestJobFactory> top_job_factory( | 661 scoped_ptr<net::URLRequestJobFactory> top_job_factory( |
657 SetUpJobFactoryDefaults(job_factory.Pass(), | 662 SetUpJobFactoryDefaults(job_factory.Pass(), |
658 request_interceptors.Pass(), | 663 request_interceptors.Pass(), |
659 protocol_handler_interceptor.Pass(), | 664 protocol_handler_interceptor.Pass(), |
660 network_delegate(), | 665 network_delegate(), |
661 ftp_factory_.get())); | 666 ftp_factory_.get())); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 net::HttpCache::BackendFactory* media_backend = | 699 net::HttpCache::BackendFactory* media_backend = |
695 new net::HttpCache::DefaultBackend( | 700 new net::HttpCache::DefaultBackend( |
696 net::MEDIA_CACHE, | 701 net::MEDIA_CACHE, |
697 ChooseCacheBackendType(), | 702 ChooseCacheBackendType(), |
698 cache_path, | 703 cache_path, |
699 cache_max_size, | 704 cache_max_size, |
700 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 705 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
701 .get()); | 706 .get()); |
702 net::HttpNetworkSession* main_network_session = | 707 net::HttpNetworkSession* main_network_session = |
703 main_http_factory_->GetSession(); | 708 main_http_factory_->GetSession(); |
704 scoped_ptr<net::HttpTransactionFactory> media_http_cache( | 709 scoped_ptr<net::HttpCache> media_http_cache = |
705 new net::HttpCache(main_network_session, media_backend)); | 710 CreateHttpFactory(main_network_session, media_backend); |
706 | 711 |
707 // Transfer ownership of the cache to MediaRequestContext. | 712 // Transfer ownership of the cache to MediaRequestContext. |
708 context->SetHttpTransactionFactory(media_http_cache.Pass()); | 713 context->SetHttpTransactionFactory( |
| 714 media_http_cache.PassAs<net::HttpTransactionFactory>()); |
709 | 715 |
710 // Note that we do not create a new URLRequestJobFactory because | 716 // Note that we do not create a new URLRequestJobFactory because |
711 // the media context should behave exactly like its parent context | 717 // the media context should behave exactly like its parent context |
712 // in all respects except for cache behavior on media subresources. | 718 // in all respects except for cache behavior on media subresources. |
713 // The CopyFrom() step above means that our media context will use | 719 // The CopyFrom() step above means that our media context will use |
714 // the same URLRequestJobFactory instance that our parent context does. | 720 // the same URLRequestJobFactory instance that our parent context does. |
715 | 721 |
716 return context; | 722 return context; |
717 } | 723 } |
718 | 724 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 domain_reliability::DomainReliabilityClearMode mode, | 774 domain_reliability::DomainReliabilityClearMode mode, |
769 const base::Closure& completion) { | 775 const base::Closure& completion) { |
770 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 776 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
771 DCHECK(initialized()); | 777 DCHECK(initialized()); |
772 | 778 |
773 if (domain_reliability_monitor_) | 779 if (domain_reliability_monitor_) |
774 domain_reliability_monitor_->ClearBrowsingData(mode); | 780 domain_reliability_monitor_->ClearBrowsingData(mode); |
775 | 781 |
776 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion); | 782 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion); |
777 } | 783 } |
OLD | NEW |