| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return io_data_->GetResourceContext(); | 154 return io_data_->GetResourceContext(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 scoped_refptr<ChromeURLRequestContextGetter> | 157 scoped_refptr<ChromeURLRequestContextGetter> |
| 158 ProfileImplIOData::Handle::CreateMainRequestContextGetter( | 158 ProfileImplIOData::Handle::CreateMainRequestContextGetter( |
| 159 content::ProtocolHandlerMap* protocol_handlers, | 159 content::ProtocolHandlerMap* protocol_handlers, |
| 160 PrefService* local_state, | 160 PrefService* local_state, |
| 161 IOThread* io_thread) const { | 161 IOThread* io_thread) const { |
| 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 163 LazyInitialize(); | 163 LazyInitialize(); |
| 164 DCHECK(!main_request_context_getter_); | 164 DCHECK(!main_request_context_getter_.get()); |
| 165 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( | 165 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( |
| 166 profile_, io_data_, protocol_handlers); | 166 profile_, io_data_, protocol_handlers); |
| 167 | 167 |
| 168 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), | 168 io_data_->predictor_ |
| 169 local_state, | 169 ->InitNetworkPredictor(profile_->GetPrefs(), |
| 170 io_thread, | 170 local_state, |
| 171 main_request_context_getter_); | 171 io_thread, |
| 172 main_request_context_getter_.get()); |
| 172 | 173 |
| 173 content::NotificationService::current()->Notify( | 174 content::NotificationService::current()->Notify( |
| 174 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 175 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
| 175 content::Source<Profile>(profile_), | 176 content::Source<Profile>(profile_), |
| 176 content::NotificationService::NoDetails()); | 177 content::NotificationService::NoDetails()); |
| 177 return main_request_context_getter_; | 178 return main_request_context_getter_; |
| 178 } | 179 } |
| 179 | 180 |
| 180 scoped_refptr<ChromeURLRequestContextGetter> | 181 scoped_refptr<ChromeURLRequestContextGetter> |
| 181 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { | 182 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { |
| 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 183 LazyInitialize(); | 184 LazyInitialize(); |
| 184 if (!media_request_context_getter_) { | 185 if (!media_request_context_getter_.get()) { |
| 185 media_request_context_getter_ = | 186 media_request_context_getter_ = |
| 186 ChromeURLRequestContextGetter::CreateOriginalForMedia( | 187 ChromeURLRequestContextGetter::CreateOriginalForMedia(profile_, |
| 187 profile_, io_data_); | 188 io_data_); |
| 188 } | 189 } |
| 189 return media_request_context_getter_; | 190 return media_request_context_getter_; |
| 190 } | 191 } |
| 191 | 192 |
| 192 scoped_refptr<ChromeURLRequestContextGetter> | 193 scoped_refptr<ChromeURLRequestContextGetter> |
| 193 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { | 194 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { |
| 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 195 LazyInitialize(); | 196 LazyInitialize(); |
| 196 if (!extensions_request_context_getter_) { | 197 if (!extensions_request_context_getter_.get()) { |
| 197 extensions_request_context_getter_ = | 198 extensions_request_context_getter_ = |
| 198 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | 199 ChromeURLRequestContextGetter::CreateOriginalForExtensions(profile_, |
| 199 profile_, io_data_); | 200 io_data_); |
| 200 } | 201 } |
| 201 return extensions_request_context_getter_; | 202 return extensions_request_context_getter_; |
| 202 } | 203 } |
| 203 | 204 |
| 204 scoped_refptr<ChromeURLRequestContextGetter> | 205 scoped_refptr<ChromeURLRequestContextGetter> |
| 205 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( | 206 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( |
| 206 const base::FilePath& partition_path, | 207 const base::FilePath& partition_path, |
| 207 bool in_memory, | 208 bool in_memory, |
| 208 content::ProtocolHandlerMap* protocol_handlers) const { | 209 content::ProtocolHandlerMap* protocol_handlers) const { |
| 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 ChromeURLRequestContextGetterMap::iterator iter = | 249 ChromeURLRequestContextGetterMap::iterator iter = |
| 249 isolated_media_request_context_getter_map_.find(descriptor); | 250 isolated_media_request_context_getter_map_.find(descriptor); |
| 250 if (iter != isolated_media_request_context_getter_map_.end()) | 251 if (iter != isolated_media_request_context_getter_map_.end()) |
| 251 return iter->second; | 252 return iter->second; |
| 252 | 253 |
| 253 // Get the app context as the starting point for the media context, so that | 254 // Get the app context as the starting point for the media context, so that |
| 254 // it uses the app's cookie store. | 255 // it uses the app's cookie store. |
| 255 ChromeURLRequestContextGetterMap::const_iterator app_iter = | 256 ChromeURLRequestContextGetterMap::const_iterator app_iter = |
| 256 app_request_context_getter_map_.find(descriptor); | 257 app_request_context_getter_map_.find(descriptor); |
| 257 DCHECK(app_iter != app_request_context_getter_map_.end()); | 258 DCHECK(app_iter != app_request_context_getter_map_.end()); |
| 258 ChromeURLRequestContextGetter* app_context = app_iter->second; | 259 ChromeURLRequestContextGetter* app_context = app_iter->second.get(); |
| 259 ChromeURLRequestContextGetter* context = | 260 ChromeURLRequestContextGetter* context = |
| 260 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( | 261 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( |
| 261 profile_, app_context, io_data_, descriptor); | 262 profile_, app_context, io_data_, descriptor); |
| 262 isolated_media_request_context_getter_map_[descriptor] = context; | 263 isolated_media_request_context_getter_map_[descriptor] = context; |
| 263 | 264 |
| 264 return context; | 265 return context; |
| 265 } | 266 } |
| 266 | 267 |
| 267 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( | 268 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( |
| 268 base::Time time, | 269 base::Time time, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 main_context->set_throttler_manager( | 365 main_context->set_throttler_manager( |
| 365 io_thread_globals->throttler_manager.get()); | 366 io_thread_globals->throttler_manager.get()); |
| 366 | 367 |
| 367 main_context->set_proxy_service(proxy_service()); | 368 main_context->set_proxy_service(proxy_service()); |
| 368 | 369 |
| 369 scoped_refptr<net::CookieStore> cookie_store = NULL; | 370 scoped_refptr<net::CookieStore> cookie_store = NULL; |
| 370 net::ServerBoundCertService* server_bound_cert_service = NULL; | 371 net::ServerBoundCertService* server_bound_cert_service = NULL; |
| 371 if (record_mode || playback_mode) { | 372 if (record_mode || playback_mode) { |
| 372 // Don't use existing cookies and use an in-memory store. | 373 // Don't use existing cookies and use an in-memory store. |
| 373 cookie_store = new net::CookieMonster( | 374 cookie_store = new net::CookieMonster( |
| 374 NULL, profile_params->cookie_monster_delegate); | 375 NULL, profile_params->cookie_monster_delegate.get()); |
| 375 // Don't use existing server-bound certs and use an in-memory store. | 376 // Don't use existing server-bound certs and use an in-memory store. |
| 376 server_bound_cert_service = new net::ServerBoundCertService( | 377 server_bound_cert_service = new net::ServerBoundCertService( |
| 377 new net::DefaultServerBoundCertStore(NULL), | 378 new net::DefaultServerBoundCertStore(NULL), |
| 378 base::WorkerPool::GetTaskRunner(true)); | 379 base::WorkerPool::GetTaskRunner(true)); |
| 379 } | 380 } |
| 380 | 381 |
| 381 // setup cookie store | 382 // setup cookie store |
| 382 if (!cookie_store) { | 383 if (!cookie_store.get()) { |
| 383 DCHECK(!lazy_params_->cookie_path.empty()); | 384 DCHECK(!lazy_params_->cookie_path.empty()); |
| 384 | 385 |
| 385 cookie_store = content::CreatePersistentCookieStore( | 386 cookie_store = content::CreatePersistentCookieStore( |
| 386 lazy_params_->cookie_path, | 387 lazy_params_->cookie_path, |
| 387 lazy_params_->restore_old_session_cookies, | 388 lazy_params_->restore_old_session_cookies, |
| 388 lazy_params_->special_storage_policy, | 389 lazy_params_->special_storage_policy.get(), |
| 389 profile_params->cookie_monster_delegate); | 390 profile_params->cookie_monster_delegate.get()); |
| 390 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); | 391 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); |
| 391 } | 392 } |
| 392 | 393 |
| 393 main_context->set_cookie_store(cookie_store); | 394 main_context->set_cookie_store(cookie_store.get()); |
| 394 | 395 |
| 395 // Setup server bound cert service. | 396 // Setup server bound cert service. |
| 396 if (!server_bound_cert_service) { | 397 if (!server_bound_cert_service) { |
| 397 DCHECK(!lazy_params_->server_bound_cert_path.empty()); | 398 DCHECK(!lazy_params_->server_bound_cert_path.empty()); |
| 398 | 399 |
| 399 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db = | 400 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db = |
| 400 new SQLiteServerBoundCertStore( | 401 new SQLiteServerBoundCertStore( |
| 401 lazy_params_->server_bound_cert_path, | 402 lazy_params_->server_bound_cert_path, |
| 402 lazy_params_->special_storage_policy); | 403 lazy_params_->special_storage_policy.get()); |
| 403 server_bound_cert_service = new net::ServerBoundCertService( | 404 server_bound_cert_service = new net::ServerBoundCertService( |
| 404 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()), | 405 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()), |
| 405 base::WorkerPool::GetTaskRunner(true)); | 406 base::WorkerPool::GetTaskRunner(true)); |
| 406 } | 407 } |
| 407 | 408 |
| 408 set_server_bound_cert_service(server_bound_cert_service); | 409 set_server_bound_cert_service(server_bound_cert_service); |
| 409 main_context->set_server_bound_cert_service(server_bound_cert_service); | 410 main_context->set_server_bound_cert_service(server_bound_cert_service); |
| 410 | 411 |
| 411 net::HttpCache::DefaultBackend* main_backend = | 412 net::HttpCache::DefaultBackend* main_backend = |
| 412 new net::HttpCache::DefaultBackend( | 413 new net::HttpCache::DefaultBackend( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 // Don't use existing cookies and use an in-memory store. | 552 // Don't use existing cookies and use an in-memory store. |
| 552 // TODO(creis): We should have a cookie delegate for notifying the cookie | 553 // TODO(creis): We should have a cookie delegate for notifying the cookie |
| 553 // extensions API, but we need to update it to understand isolated apps | 554 // extensions API, but we need to update it to understand isolated apps |
| 554 // first. | 555 // first. |
| 555 cookie_store = new net::CookieMonster(NULL, NULL); | 556 cookie_store = new net::CookieMonster(NULL, NULL); |
| 556 app_http_cache->set_mode( | 557 app_http_cache->set_mode( |
| 557 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 558 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
| 558 } | 559 } |
| 559 | 560 |
| 560 // Use an app-specific cookie store. | 561 // Use an app-specific cookie store. |
| 561 if (!cookie_store) { | 562 if (!cookie_store.get()) { |
| 562 DCHECK(!cookie_path.empty()); | 563 DCHECK(!cookie_path.empty()); |
| 563 | 564 |
| 564 // TODO(creis): We should have a cookie delegate for notifying the cookie | 565 // TODO(creis): We should have a cookie delegate for notifying the cookie |
| 565 // extensions API, but we need to update it to understand isolated apps | 566 // extensions API, but we need to update it to understand isolated apps |
| 566 // first. | 567 // first. |
| 567 cookie_store = content::CreatePersistentCookieStore( | 568 cookie_store = content::CreatePersistentCookieStore( |
| 568 cookie_path, | 569 cookie_path, |
| 569 false, | 570 false, |
| 570 NULL, | 571 NULL, |
| 571 NULL); | 572 NULL); |
| 572 } | 573 } |
| 573 | 574 |
| 574 // Transfer ownership of the cookies and cache to AppRequestContext. | 575 // Transfer ownership of the cookies and cache to AppRequestContext. |
| 575 context->SetCookieStore(cookie_store); | 576 context->SetCookieStore(cookie_store.get()); |
| 576 context->SetHttpTransactionFactory( | 577 context->SetHttpTransactionFactory( |
| 577 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 578 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); |
| 578 | 579 |
| 579 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 580 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 580 new net::URLRequestJobFactoryImpl()); | 581 new net::URLRequestJobFactoryImpl()); |
| 581 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 582 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
| 582 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 583 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
| 583 // Overwrite the job factory that we inherit from the main context so | 584 // Overwrite the job factory that we inherit from the main context so |
| 584 // that we can later provide our own handlers for storage related protocols. | 585 // that we can later provide our own handlers for storage related protocols. |
| 585 // Install all the usual protocol handlers unless we are in a browser plugin | 586 // Install all the usual protocol handlers unless we are in a browser plugin |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 const base::Closure& completion) { | 690 const base::Closure& completion) { |
| 690 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 691 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 691 DCHECK(initialized()); | 692 DCHECK(initialized()); |
| 692 | 693 |
| 693 DCHECK(transport_security_state()); | 694 DCHECK(transport_security_state()); |
| 694 // Completes synchronously. | 695 // Completes synchronously. |
| 695 transport_security_state()->DeleteAllDynamicDataSince(time); | 696 transport_security_state()->DeleteAllDynamicDataSince(time); |
| 696 DCHECK(http_server_properties_manager_); | 697 DCHECK(http_server_properties_manager_); |
| 697 http_server_properties_manager_->Clear(completion); | 698 http_server_properties_manager_->Clear(completion); |
| 698 } | 699 } |
| OLD | NEW |