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 <set> | 7 #include <set> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
15 #include "base/prefs/json_pref_store.h" | 16 #include "base/prefs/json_pref_store.h" |
16 #include "base/prefs/pref_filter.h" | 17 #include "base/prefs/pref_filter.h" |
17 #include "base/prefs/pref_member.h" | 18 #include "base/prefs/pref_member.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 121 } |
121 | 122 |
122 if (io_data_->http_server_properties_manager_) | 123 if (io_data_->http_server_properties_manager_) |
123 io_data_->http_server_properties_manager_->ShutdownOnPrefThread(); | 124 io_data_->http_server_properties_manager_->ShutdownOnPrefThread(); |
124 | 125 |
125 // io_data_->data_reduction_proxy_io_data() might be NULL if Init() was | 126 // io_data_->data_reduction_proxy_io_data() might be NULL if Init() was |
126 // never called. | 127 // never called. |
127 if (io_data_->data_reduction_proxy_io_data()) | 128 if (io_data_->data_reduction_proxy_io_data()) |
128 io_data_->data_reduction_proxy_io_data()->ShutdownOnUIThread(); | 129 io_data_->data_reduction_proxy_io_data()->ShutdownOnUIThread(); |
129 | 130 |
130 io_data_->ShutdownOnUIThread(GetAllContextGetters().Pass()); | 131 io_data_->ShutdownOnUIThread(GetAllContextGetters()); |
131 } | 132 } |
132 | 133 |
133 void ProfileImplIOData::Handle::Init( | 134 void ProfileImplIOData::Handle::Init( |
134 const base::FilePath& cookie_path, | 135 const base::FilePath& cookie_path, |
135 const base::FilePath& channel_id_path, | 136 const base::FilePath& channel_id_path, |
136 const base::FilePath& cache_path, | 137 const base::FilePath& cache_path, |
137 int cache_max_size, | 138 int cache_max_size, |
138 const base::FilePath& media_cache_path, | 139 const base::FilePath& media_cache_path, |
139 int media_cache_max_size, | 140 int media_cache_max_size, |
140 const base::FilePath& extensions_cookie_path, | 141 const base::FilePath& extensions_cookie_path, |
(...skipping 21 matching lines...) Expand all Loading... |
162 | 163 |
163 io_data_->lazy_params_.reset(lazy_params); | 164 io_data_->lazy_params_.reset(lazy_params); |
164 | 165 |
165 // Keep track of profile path and cache sizes separately so we can use them | 166 // Keep track of profile path and cache sizes separately so we can use them |
166 // on demand when creating storage isolated URLRequestContextGetters. | 167 // on demand when creating storage isolated URLRequestContextGetters. |
167 io_data_->profile_path_ = profile_path; | 168 io_data_->profile_path_ = profile_path; |
168 io_data_->app_cache_max_size_ = cache_max_size; | 169 io_data_->app_cache_max_size_ = cache_max_size; |
169 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 170 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
170 | 171 |
171 io_data_->predictor_.reset(predictor); | 172 io_data_->predictor_.reset(predictor); |
172 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); | 173 io_data_->domain_reliability_monitor_ = std::move(domain_reliability_monitor); |
173 | 174 |
174 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 175 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
175 if (io_data_->domain_reliability_monitor_) | 176 if (io_data_->domain_reliability_monitor_) |
176 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); | 177 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); |
177 | 178 |
178 // TODO(tbansal): Move this to IO thread once the data reduction proxy | 179 // TODO(tbansal): Move this to IO thread once the data reduction proxy |
179 // params are unified into a single object. | 180 // params are unified into a single object. |
180 bool enable_quic_for_data_reduction_proxy = | 181 bool enable_quic_for_data_reduction_proxy = |
181 IOThread::ShouldEnableQuicForDataReductionProxy(); | 182 IOThread::ShouldEnableQuicForDataReductionProxy(); |
182 | 183 |
183 io_data_->set_data_reduction_proxy_io_data( | 184 io_data_->set_data_reduction_proxy_io_data( |
184 CreateDataReductionProxyChromeIOData( | 185 CreateDataReductionProxyChromeIOData( |
185 g_browser_process->io_thread()->net_log(), profile_->GetPrefs(), | 186 g_browser_process->io_thread()->net_log(), profile_->GetPrefs(), |
186 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 187 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
187 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 188 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
188 enable_quic_for_data_reduction_proxy) | 189 enable_quic_for_data_reduction_proxy)); |
189 .Pass()); | |
190 | 190 |
191 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 191 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
192 scoped_refptr<base::SequencedTaskRunner> db_task_runner = | 192 scoped_refptr<base::SequencedTaskRunner> db_task_runner = |
193 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 193 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
194 pool->GetSequenceToken(), | 194 pool->GetSequenceToken(), |
195 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 195 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
196 scoped_ptr<data_reduction_proxy::DataStore> store( | 196 scoped_ptr<data_reduction_proxy::DataStore> store( |
197 new data_reduction_proxy::DataStoreImpl(profile_path)); | 197 new data_reduction_proxy::DataStoreImpl(profile_path)); |
198 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_) | 198 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_) |
199 ->InitDataReductionProxySettings( | 199 ->InitDataReductionProxySettings( |
200 io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), | 200 io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), |
201 profile_->GetRequestContext(), store.Pass(), | 201 profile_->GetRequestContext(), std::move(store), |
202 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 202 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
203 db_task_runner); | 203 db_task_runner); |
204 } | 204 } |
205 | 205 |
206 content::ResourceContext* | 206 content::ResourceContext* |
207 ProfileImplIOData::Handle::GetResourceContext() const { | 207 ProfileImplIOData::Handle::GetResourceContext() const { |
208 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 208 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
209 LazyInitialize(); | 209 LazyInitialize(); |
210 return GetResourceContextNoInit(); | 210 return GetResourceContextNoInit(); |
211 } | 211 } |
(...skipping 10 matching lines...) Expand all Loading... |
222 scoped_refptr<ChromeURLRequestContextGetter> | 222 scoped_refptr<ChromeURLRequestContextGetter> |
223 ProfileImplIOData::Handle::CreateMainRequestContextGetter( | 223 ProfileImplIOData::Handle::CreateMainRequestContextGetter( |
224 content::ProtocolHandlerMap* protocol_handlers, | 224 content::ProtocolHandlerMap* protocol_handlers, |
225 content::URLRequestInterceptorScopedVector request_interceptors, | 225 content::URLRequestInterceptorScopedVector request_interceptors, |
226 PrefService* local_state, | 226 PrefService* local_state, |
227 IOThread* io_thread) const { | 227 IOThread* io_thread) const { |
228 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 228 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
229 LazyInitialize(); | 229 LazyInitialize(); |
230 DCHECK(!main_request_context_getter_.get()); | 230 DCHECK(!main_request_context_getter_.get()); |
231 main_request_context_getter_ = ChromeURLRequestContextGetter::Create( | 231 main_request_context_getter_ = ChromeURLRequestContextGetter::Create( |
232 profile_, io_data_, protocol_handlers, request_interceptors.Pass()); | 232 profile_, io_data_, protocol_handlers, std::move(request_interceptors)); |
233 | 233 |
234 io_data_->predictor_ | 234 io_data_->predictor_ |
235 ->InitNetworkPredictor(profile_->GetPrefs(), | 235 ->InitNetworkPredictor(profile_->GetPrefs(), |
236 local_state, | 236 local_state, |
237 io_thread, | 237 io_thread, |
238 main_request_context_getter_.get(), | 238 main_request_context_getter_.get(), |
239 io_data_); | 239 io_data_); |
240 | 240 |
241 content::NotificationService::current()->Notify( | 241 content::NotificationService::current()->Notify( |
242 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 242 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 app_request_context_getter_map_.find(descriptor); | 285 app_request_context_getter_map_.find(descriptor); |
286 if (iter != app_request_context_getter_map_.end()) | 286 if (iter != app_request_context_getter_map_.end()) |
287 return iter->second; | 287 return iter->second; |
288 | 288 |
289 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 289 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
290 protocol_handler_interceptor( | 290 protocol_handler_interceptor( |
291 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_)-> | 291 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_)-> |
292 CreateJobInterceptorFactory()); | 292 CreateJobInterceptorFactory()); |
293 ChromeURLRequestContextGetter* context = | 293 ChromeURLRequestContextGetter* context = |
294 ChromeURLRequestContextGetter::CreateForIsolatedApp( | 294 ChromeURLRequestContextGetter::CreateForIsolatedApp( |
295 profile_, | 295 profile_, io_data_, descriptor, |
296 io_data_, | 296 std::move(protocol_handler_interceptor), protocol_handlers, |
297 descriptor, | 297 std::move(request_interceptors)); |
298 protocol_handler_interceptor.Pass(), | |
299 protocol_handlers, | |
300 request_interceptors.Pass()); | |
301 app_request_context_getter_map_[descriptor] = context; | 298 app_request_context_getter_map_[descriptor] = context; |
302 | 299 |
303 return context; | 300 return context; |
304 } | 301 } |
305 | 302 |
306 scoped_refptr<ChromeURLRequestContextGetter> | 303 scoped_refptr<ChromeURLRequestContextGetter> |
307 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( | 304 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( |
308 const base::FilePath& partition_path, | 305 const base::FilePath& partition_path, |
309 bool in_memory) const { | 306 bool in_memory) const { |
310 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 307 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 394 |
398 if (extensions_request_context_getter_.get()) | 395 if (extensions_request_context_getter_.get()) |
399 context_getters->push_back(extensions_request_context_getter_); | 396 context_getters->push_back(extensions_request_context_getter_); |
400 | 397 |
401 if (media_request_context_getter_.get()) | 398 if (media_request_context_getter_.get()) |
402 context_getters->push_back(media_request_context_getter_); | 399 context_getters->push_back(media_request_context_getter_); |
403 | 400 |
404 if (main_request_context_getter_.get()) | 401 if (main_request_context_getter_.get()) |
405 context_getters->push_back(main_request_context_getter_); | 402 context_getters->push_back(main_request_context_getter_); |
406 | 403 |
407 return context_getters.Pass(); | 404 return context_getters; |
408 } | 405 } |
409 | 406 |
410 ProfileImplIOData::LazyParams::LazyParams() | 407 ProfileImplIOData::LazyParams::LazyParams() |
411 : cache_max_size(0), | 408 : cache_max_size(0), |
412 media_cache_max_size(0), | 409 media_cache_max_size(0), |
413 session_cookie_mode( | 410 session_cookie_mode( |
414 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} | 411 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} |
415 | 412 |
416 ProfileImplIOData::LazyParams::~LazyParams() {} | 413 ProfileImplIOData::LazyParams::~LazyParams() {} |
417 | 414 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 ApplyProfileParamsToContext(main_context); | 460 ApplyProfileParamsToContext(main_context); |
464 | 461 |
465 if (http_server_properties_manager_) | 462 if (http_server_properties_manager_) |
466 http_server_properties_manager_->InitializeOnNetworkThread(); | 463 http_server_properties_manager_->InitializeOnNetworkThread(); |
467 | 464 |
468 main_context->set_transport_security_state(transport_security_state()); | 465 main_context->set_transport_security_state(transport_security_state()); |
469 | 466 |
470 main_context->set_net_log(io_thread->net_log()); | 467 main_context->set_net_log(io_thread->net_log()); |
471 | 468 |
472 network_delegate_ = data_reduction_proxy_io_data()->CreateNetworkDelegate( | 469 network_delegate_ = data_reduction_proxy_io_data()->CreateNetworkDelegate( |
473 chrome_network_delegate.Pass(), true).Pass(); | 470 std::move(chrome_network_delegate), true); |
474 | 471 |
475 main_context->set_network_delegate(network_delegate_.get()); | 472 main_context->set_network_delegate(network_delegate_.get()); |
476 | 473 |
477 main_context->set_http_server_properties(http_server_properties()); | 474 main_context->set_http_server_properties(http_server_properties()); |
478 | 475 |
479 main_context->set_host_resolver( | 476 main_context->set_host_resolver( |
480 io_thread_globals->host_resolver.get()); | 477 io_thread_globals->host_resolver.get()); |
481 | 478 |
482 main_context->set_http_auth_handler_factory( | 479 main_context->set_http_auth_handler_factory( |
483 io_thread_globals->http_auth_handler_factory.get()); | 480 io_thread_globals->http_auth_handler_factory.get()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 521 |
525 scoped_ptr<net::HttpCache::BackendFactory> main_backend( | 522 scoped_ptr<net::HttpCache::BackendFactory> main_backend( |
526 new net::HttpCache::DefaultBackend( | 523 new net::HttpCache::DefaultBackend( |
527 net::DISK_CACHE, | 524 net::DISK_CACHE, |
528 ChooseCacheBackendType(), | 525 ChooseCacheBackendType(), |
529 lazy_params_->cache_path, | 526 lazy_params_->cache_path, |
530 lazy_params_->cache_max_size, | 527 lazy_params_->cache_max_size, |
531 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 528 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
532 http_network_session_ = CreateHttpNetworkSession(*profile_params); | 529 http_network_session_ = CreateHttpNetworkSession(*profile_params); |
533 main_http_factory_ = CreateMainHttpFactory(http_network_session_.get(), | 530 main_http_factory_ = CreateMainHttpFactory(http_network_session_.get(), |
534 main_backend.Pass()); | 531 std::move(main_backend)); |
535 main_context->set_http_transaction_factory(main_http_factory_.get()); | 532 main_context->set_http_transaction_factory(main_http_factory_.get()); |
536 | 533 |
537 #if !defined(DISABLE_FTP_SUPPORT) | 534 #if !defined(DISABLE_FTP_SUPPORT) |
538 ftp_factory_.reset( | 535 ftp_factory_.reset( |
539 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 536 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
540 #endif // !defined(DISABLE_FTP_SUPPORT) | 537 #endif // !defined(DISABLE_FTP_SUPPORT) |
541 | 538 |
542 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 539 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
543 new net::URLRequestJobFactoryImpl()); | 540 new net::URLRequestJobFactoryImpl()); |
544 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 541 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
545 | 542 |
546 // The data reduction proxy interceptor should be as close to the network | 543 // The data reduction proxy interceptor should be as close to the network |
547 // as possible. | 544 // as possible. |
548 request_interceptors.insert( | 545 request_interceptors.insert( |
549 request_interceptors.begin(), | 546 request_interceptors.begin(), |
550 data_reduction_proxy_io_data()->CreateInterceptor().release()); | 547 data_reduction_proxy_io_data()->CreateInterceptor().release()); |
551 main_job_factory_ = SetUpJobFactoryDefaults( | 548 main_job_factory_ = SetUpJobFactoryDefaults( |
552 main_job_factory.Pass(), | 549 std::move(main_job_factory), std::move(request_interceptors), |
553 request_interceptors.Pass(), | 550 std::move(profile_params->protocol_handler_interceptor), |
554 profile_params->protocol_handler_interceptor.Pass(), | 551 main_context->network_delegate(), ftp_factory_.get()); |
555 main_context->network_delegate(), | |
556 ftp_factory_.get()); | |
557 main_context->set_job_factory(main_job_factory_.get()); | 552 main_context->set_job_factory(main_job_factory_.get()); |
558 main_context->set_network_quality_estimator( | 553 main_context->set_network_quality_estimator( |
559 io_thread_globals->network_quality_estimator.get()); | 554 io_thread_globals->network_quality_estimator.get()); |
560 | 555 |
561 #if defined(ENABLE_EXTENSIONS) | 556 #if defined(ENABLE_EXTENSIONS) |
562 InitializeExtensionsRequestContext(profile_params); | 557 InitializeExtensionsRequestContext(profile_params); |
563 #endif | 558 #endif |
564 | 559 |
565 // Setup SDCH for this profile. | 560 // Setup SDCH for this profile. |
566 sdch_manager_.reset(new net::SdchManager); | 561 sdch_manager_.reset(new net::SdchManager); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 | 600 |
606 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 601 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
607 new net::URLRequestJobFactoryImpl()); | 602 new net::URLRequestJobFactoryImpl()); |
608 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 603 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
609 // Without a network_delegate, this protocol handler will never | 604 // Without a network_delegate, this protocol handler will never |
610 // handle file: requests, but as a side effect it makes | 605 // handle file: requests, but as a side effect it makes |
611 // job_factory::IsHandledProtocol return true, which prevents attempts to | 606 // job_factory::IsHandledProtocol return true, which prevents attempts to |
612 // handle the protocol externally. We pass NULL in to | 607 // handle the protocol externally. We pass NULL in to |
613 // SetUpJobFactory() to get this effect. | 608 // SetUpJobFactory() to get this effect. |
614 extensions_job_factory_ = SetUpJobFactoryDefaults( | 609 extensions_job_factory_ = SetUpJobFactoryDefaults( |
615 extensions_job_factory.Pass(), | 610 std::move(extensions_job_factory), |
616 content::URLRequestInterceptorScopedVector(), | 611 content::URLRequestInterceptorScopedVector(), |
617 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(), | 612 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(), NULL, |
618 NULL, | |
619 ftp_factory_.get()); | 613 ftp_factory_.get()); |
620 extensions_context->set_job_factory(extensions_job_factory_.get()); | 614 extensions_context->set_job_factory(extensions_job_factory_.get()); |
621 extensions_context->set_backoff_manager( | 615 extensions_context->set_backoff_manager( |
622 io_thread_globals->url_request_backoff_manager.get()); | 616 io_thread_globals->url_request_backoff_manager.get()); |
623 } | 617 } |
624 | 618 |
625 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( | 619 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( |
626 net::URLRequestContext* main_context, | 620 net::URLRequestContext* main_context, |
627 const StoragePartitionDescriptor& partition_descriptor, | 621 const StoragePartitionDescriptor& partition_descriptor, |
628 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 622 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
(...skipping 15 matching lines...) Expand all Loading... |
644 app_backend = net::HttpCache::DefaultBackend::InMemory(0); | 638 app_backend = net::HttpCache::DefaultBackend::InMemory(0); |
645 } else { | 639 } else { |
646 app_backend.reset(new net::HttpCache::DefaultBackend( | 640 app_backend.reset(new net::HttpCache::DefaultBackend( |
647 net::DISK_CACHE, | 641 net::DISK_CACHE, |
648 ChooseCacheBackendType(), | 642 ChooseCacheBackendType(), |
649 cache_path, | 643 cache_path, |
650 app_cache_max_size_, | 644 app_cache_max_size_, |
651 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 645 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
652 } | 646 } |
653 scoped_ptr<net::HttpCache> app_http_cache = | 647 scoped_ptr<net::HttpCache> app_http_cache = |
654 CreateHttpFactory(http_network_session_.get(), app_backend.Pass()); | 648 CreateHttpFactory(http_network_session_.get(), std::move(app_backend)); |
655 | 649 |
656 scoped_refptr<net::CookieStore> cookie_store = NULL; | 650 scoped_refptr<net::CookieStore> cookie_store = NULL; |
657 if (partition_descriptor.in_memory) { | 651 if (partition_descriptor.in_memory) { |
658 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 652 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
659 } | 653 } |
660 | 654 |
661 // Use an app-specific cookie store. | 655 // Use an app-specific cookie store. |
662 if (!cookie_store.get()) { | 656 if (!cookie_store.get()) { |
663 DCHECK(!cookie_path.empty()); | 657 DCHECK(!cookie_path.empty()); |
664 | 658 |
665 // TODO(creis): We should have a cookie delegate for notifying the cookie | 659 // TODO(creis): We should have a cookie delegate for notifying the cookie |
666 // extensions API, but we need to update it to understand isolated apps | 660 // extensions API, but we need to update it to understand isolated apps |
667 // first. | 661 // first. |
668 content::CookieStoreConfig cookie_config( | 662 content::CookieStoreConfig cookie_config( |
669 cookie_path, | 663 cookie_path, |
670 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, | 664 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
671 NULL, NULL); | 665 NULL, NULL); |
672 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); | 666 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); |
673 cookie_store = content::CreateCookieStore(cookie_config); | 667 cookie_store = content::CreateCookieStore(cookie_config); |
674 } | 668 } |
675 | 669 |
676 // Transfer ownership of the cookies and cache to AppRequestContext. | 670 // Transfer ownership of the cookies and cache to AppRequestContext. |
677 context->SetCookieStore(cookie_store.get()); | 671 context->SetCookieStore(cookie_store.get()); |
678 context->SetHttpTransactionFactory(app_http_cache.Pass()); | 672 context->SetHttpTransactionFactory(std::move(app_http_cache)); |
679 | 673 |
680 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 674 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
681 new net::URLRequestJobFactoryImpl()); | 675 new net::URLRequestJobFactoryImpl()); |
682 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 676 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
683 // The data reduction proxy interceptor should be as close to the network | 677 // The data reduction proxy interceptor should be as close to the network |
684 // as possible. | 678 // as possible. |
685 request_interceptors.insert( | 679 request_interceptors.insert( |
686 request_interceptors.begin(), | 680 request_interceptors.begin(), |
687 data_reduction_proxy_io_data()->CreateInterceptor().release()); | 681 data_reduction_proxy_io_data()->CreateInterceptor().release()); |
688 scoped_ptr<net::URLRequestJobFactory> top_job_factory( | 682 scoped_ptr<net::URLRequestJobFactory> top_job_factory(SetUpJobFactoryDefaults( |
689 SetUpJobFactoryDefaults(job_factory.Pass(), | 683 std::move(job_factory), std::move(request_interceptors), |
690 request_interceptors.Pass(), | 684 std::move(protocol_handler_interceptor), main_context->network_delegate(), |
691 protocol_handler_interceptor.Pass(), | 685 ftp_factory_.get())); |
692 main_context->network_delegate(), | 686 context->SetJobFactory(std::move(top_job_factory)); |
693 ftp_factory_.get())); | |
694 context->SetJobFactory(top_job_factory.Pass()); | |
695 | 687 |
696 return context; | 688 return context; |
697 } | 689 } |
698 | 690 |
699 net::URLRequestContext* | 691 net::URLRequestContext* |
700 ProfileImplIOData::InitializeMediaRequestContext( | 692 ProfileImplIOData::InitializeMediaRequestContext( |
701 net::URLRequestContext* original_context, | 693 net::URLRequestContext* original_context, |
702 const StoragePartitionDescriptor& partition_descriptor) const { | 694 const StoragePartitionDescriptor& partition_descriptor) const { |
703 // Copy most state from the original context. | 695 // Copy most state from the original context. |
704 MediaRequestContext* context = new MediaRequestContext(); | 696 MediaRequestContext* context = new MediaRequestContext(); |
(...skipping 19 matching lines...) Expand all Loading... |
724 | 716 |
725 // Use a separate HTTP disk cache for isolated apps. | 717 // Use a separate HTTP disk cache for isolated apps. |
726 scoped_ptr<net::HttpCache::BackendFactory> media_backend( | 718 scoped_ptr<net::HttpCache::BackendFactory> media_backend( |
727 new net::HttpCache::DefaultBackend( | 719 new net::HttpCache::DefaultBackend( |
728 net::MEDIA_CACHE, | 720 net::MEDIA_CACHE, |
729 ChooseCacheBackendType(), | 721 ChooseCacheBackendType(), |
730 cache_path, | 722 cache_path, |
731 cache_max_size, | 723 cache_max_size, |
732 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 724 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
733 scoped_ptr<net::HttpCache> media_http_cache = | 725 scoped_ptr<net::HttpCache> media_http_cache = |
734 CreateHttpFactory(http_network_session_.get(), media_backend.Pass()); | 726 CreateHttpFactory(http_network_session_.get(), std::move(media_backend)); |
735 | 727 |
736 // Transfer ownership of the cache to MediaRequestContext. | 728 // Transfer ownership of the cache to MediaRequestContext. |
737 context->SetHttpTransactionFactory(media_http_cache.Pass()); | 729 context->SetHttpTransactionFactory(std::move(media_http_cache)); |
738 | 730 |
739 // Note that we do not create a new URLRequestJobFactory because | 731 // Note that we do not create a new URLRequestJobFactory because |
740 // the media context should behave exactly like its parent context | 732 // the media context should behave exactly like its parent context |
741 // in all respects except for cache behavior on media subresources. | 733 // in all respects except for cache behavior on media subresources. |
742 // The CopyFrom() step above means that our media context will use | 734 // The CopyFrom() step above means that our media context will use |
743 // the same URLRequestJobFactory instance that our parent context does. | 735 // the same URLRequestJobFactory instance that our parent context does. |
744 | 736 |
745 return context; | 737 return context; |
746 } | 738 } |
747 | 739 |
748 net::URLRequestContext* | 740 net::URLRequestContext* |
749 ProfileImplIOData::AcquireMediaRequestContext() const { | 741 ProfileImplIOData::AcquireMediaRequestContext() const { |
750 DCHECK(media_request_context_); | 742 DCHECK(media_request_context_); |
751 return media_request_context_.get(); | 743 return media_request_context_.get(); |
752 } | 744 } |
753 | 745 |
754 net::URLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( | 746 net::URLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( |
755 net::URLRequestContext* main_context, | 747 net::URLRequestContext* main_context, |
756 const StoragePartitionDescriptor& partition_descriptor, | 748 const StoragePartitionDescriptor& partition_descriptor, |
757 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 749 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
758 protocol_handler_interceptor, | 750 protocol_handler_interceptor, |
759 content::ProtocolHandlerMap* protocol_handlers, | 751 content::ProtocolHandlerMap* protocol_handlers, |
760 content::URLRequestInterceptorScopedVector request_interceptors) const { | 752 content::URLRequestInterceptorScopedVector request_interceptors) const { |
761 // We create per-app contexts on demand, unlike the others above. | 753 // We create per-app contexts on demand, unlike the others above. |
762 net::URLRequestContext* app_request_context = | 754 net::URLRequestContext* app_request_context = InitializeAppRequestContext( |
763 InitializeAppRequestContext(main_context, | 755 main_context, partition_descriptor, |
764 partition_descriptor, | 756 std::move(protocol_handler_interceptor), protocol_handlers, |
765 protocol_handler_interceptor.Pass(), | 757 std::move(request_interceptors)); |
766 protocol_handlers, | |
767 request_interceptors.Pass()); | |
768 DCHECK(app_request_context); | 758 DCHECK(app_request_context); |
769 return app_request_context; | 759 return app_request_context; |
770 } | 760 } |
771 | 761 |
772 net::URLRequestContext* | 762 net::URLRequestContext* |
773 ProfileImplIOData::AcquireIsolatedMediaRequestContext( | 763 ProfileImplIOData::AcquireIsolatedMediaRequestContext( |
774 net::URLRequestContext* app_context, | 764 net::URLRequestContext* app_context, |
775 const StoragePartitionDescriptor& partition_descriptor) const { | 765 const StoragePartitionDescriptor& partition_descriptor) const { |
776 // We create per-app media contexts on demand, unlike the others above. | 766 // We create per-app media contexts on demand, unlike the others above. |
777 net::URLRequestContext* media_request_context = | 767 net::URLRequestContext* media_request_context = |
778 InitializeMediaRequestContext(app_context, partition_descriptor); | 768 InitializeMediaRequestContext(app_context, partition_descriptor); |
779 DCHECK(media_request_context); | 769 DCHECK(media_request_context); |
780 return media_request_context; | 770 return media_request_context; |
781 } | 771 } |
782 | 772 |
783 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 773 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
784 base::Time time, | 774 base::Time time, |
785 const base::Closure& completion) { | 775 const base::Closure& completion) { |
786 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 776 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
787 DCHECK(initialized()); | 777 DCHECK(initialized()); |
788 | 778 |
789 DCHECK(transport_security_state()); | 779 DCHECK(transport_security_state()); |
790 // Completes synchronously. | 780 // Completes synchronously. |
791 transport_security_state()->DeleteAllDynamicDataSince(time); | 781 transport_security_state()->DeleteAllDynamicDataSince(time); |
792 DCHECK(http_server_properties_manager_); | 782 DCHECK(http_server_properties_manager_); |
793 http_server_properties_manager_->Clear(completion); | 783 http_server_properties_manager_->Clear(completion); |
794 } | 784 } |
OLD | NEW |