| 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/file_util.h" |    9 #include "base/file_util.h" | 
|   10 #include "base/logging.h" |   10 #include "base/logging.h" | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   67   io_data_->ShutdownOnUIThread(); |   67   io_data_->ShutdownOnUIThread(); | 
|   68 } |   68 } | 
|   69  |   69  | 
|   70 void ProfileImplIOData::Handle::Init( |   70 void ProfileImplIOData::Handle::Init( | 
|   71       const base::FilePath& cookie_path, |   71       const base::FilePath& cookie_path, | 
|   72       const base::FilePath& server_bound_cert_path, |   72       const base::FilePath& server_bound_cert_path, | 
|   73       const base::FilePath& cache_path, |   73       const base::FilePath& cache_path, | 
|   74       int cache_max_size, |   74       int cache_max_size, | 
|   75       const base::FilePath& media_cache_path, |   75       const base::FilePath& media_cache_path, | 
|   76       int media_cache_max_size, |   76       int media_cache_max_size, | 
|   77       const base::FilePath& extensions_cookie_path, |   77       const base::FilePath& extension_cookie_path, | 
|   78       const base::FilePath& profile_path, |   78       const base::FilePath& profile_path, | 
|   79       const base::FilePath& infinite_cache_path, |   79       const base::FilePath& infinite_cache_path, | 
|   80       chrome_browser_net::Predictor* predictor, |   80       chrome_browser_net::Predictor* predictor, | 
|   81       bool restore_old_session_cookies, |   81       bool restore_old_session_cookies, | 
|   82       quota::SpecialStoragePolicy* special_storage_policy) { |   82       quota::SpecialStoragePolicy* special_storage_policy) { | 
|   83   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |   83   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
|   84   DCHECK(!io_data_->lazy_params_.get()); |   84   DCHECK(!io_data_->lazy_params_.get()); | 
|   85   DCHECK(predictor); |   85   DCHECK(predictor); | 
|   86  |   86  | 
|   87   LazyParams* lazy_params = new LazyParams; |   87   LazyParams* lazy_params = new LazyParams; | 
|   88  |   88  | 
|   89   lazy_params->cookie_path = cookie_path; |   89   lazy_params->cookie_path = cookie_path; | 
|   90   lazy_params->server_bound_cert_path = server_bound_cert_path; |   90   lazy_params->server_bound_cert_path = server_bound_cert_path; | 
|   91   lazy_params->cache_path = cache_path; |   91   lazy_params->cache_path = cache_path; | 
|   92   lazy_params->cache_max_size = cache_max_size; |   92   lazy_params->cache_max_size = cache_max_size; | 
|   93   lazy_params->media_cache_path = media_cache_path; |   93   lazy_params->media_cache_path = media_cache_path; | 
|   94   lazy_params->media_cache_max_size = media_cache_max_size; |   94   lazy_params->media_cache_max_size = media_cache_max_size; | 
|   95   lazy_params->extensions_cookie_path = extensions_cookie_path; |   95   lazy_params->extension_cookie_path = extension_cookie_path; | 
|   96   lazy_params->infinite_cache_path = infinite_cache_path; |   96   lazy_params->infinite_cache_path = infinite_cache_path; | 
|   97   lazy_params->restore_old_session_cookies = restore_old_session_cookies; |   97   lazy_params->restore_old_session_cookies = restore_old_session_cookies; | 
|   98   lazy_params->special_storage_policy = special_storage_policy; |   98   lazy_params->special_storage_policy = special_storage_policy; | 
|   99  |   99  | 
|  100   io_data_->lazy_params_.reset(lazy_params); |  100   io_data_->lazy_params_.reset(lazy_params); | 
|  101  |  101  | 
|  102   // Keep track of profile path and cache sizes separately so we can use them |  102   // Keep track of profile path and cache sizes separately so we can use them | 
|  103   // on demand when creating storage isolated URLRequestContextGetters. |  103   // on demand when creating storage isolated URLRequestContextGetters. | 
|  104   io_data_->profile_path_ = profile_path; |  104   io_data_->profile_path_ = profile_path; | 
|  105   io_data_->app_cache_max_size_ = cache_max_size; |  105   io_data_->app_cache_max_size_ = cache_max_size; | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  166   LazyInitialize(); |  166   LazyInitialize(); | 
|  167   if (!media_request_context_getter_) { |  167   if (!media_request_context_getter_) { | 
|  168     media_request_context_getter_ = |  168     media_request_context_getter_ = | 
|  169         ChromeURLRequestContextGetter::CreateOriginalForMedia( |  169         ChromeURLRequestContextGetter::CreateOriginalForMedia( | 
|  170             profile_, io_data_); |  170             profile_, io_data_); | 
|  171   } |  171   } | 
|  172   return media_request_context_getter_; |  172   return media_request_context_getter_; | 
|  173 } |  173 } | 
|  174  |  174  | 
|  175 scoped_refptr<ChromeURLRequestContextGetter> |  175 scoped_refptr<ChromeURLRequestContextGetter> | 
|  176 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { |  | 
|  177   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |  | 
|  178   LazyInitialize(); |  | 
|  179   if (!extensions_request_context_getter_) { |  | 
|  180     extensions_request_context_getter_ = |  | 
|  181         ChromeURLRequestContextGetter::CreateOriginalForExtensions( |  | 
|  182             profile_, io_data_); |  | 
|  183   } |  | 
|  184   return extensions_request_context_getter_; |  | 
|  185 } |  | 
|  186  |  | 
|  187 scoped_refptr<ChromeURLRequestContextGetter> |  | 
|  188 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( |  176 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( | 
|  189     const base::FilePath& partition_path, |  177     const base::FilePath& partition_path, | 
|  190     bool in_memory, |  178     bool in_memory, | 
|  191     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |  179     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 
|  192         blob_protocol_handler, |  180         blob_protocol_handler, | 
|  193     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |  181     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 
|  194         file_system_protocol_handler, |  182         file_system_protocol_handler, | 
|  195     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |  183     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 
|  196         developer_protocol_handler, |  184         developer_protocol_handler, | 
|  197     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |  185     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  464       main_job_factory.Pass(), |  452       main_job_factory.Pass(), | 
|  465       profile_params->protocol_handler_interceptor.Pass(), |  453       profile_params->protocol_handler_interceptor.Pass(), | 
|  466       network_delegate(), |  454       network_delegate(), | 
|  467       main_context->ftp_transaction_factory(), |  455       main_context->ftp_transaction_factory(), | 
|  468       main_context->ftp_auth_cache()); |  456       main_context->ftp_auth_cache()); | 
|  469   main_job_factory_.reset(new net::ProtocolInterceptJobFactory( |  457   main_job_factory_.reset(new net::ProtocolInterceptJobFactory( | 
|  470       main_job_factory_.Pass(), developer_protocol_handler.Pass())); |  458       main_job_factory_.Pass(), developer_protocol_handler.Pass())); | 
|  471   main_context->set_job_factory(main_job_factory_.get()); |  459   main_context->set_job_factory(main_job_factory_.get()); | 
|  472  |  460  | 
|  473 #if defined(ENABLE_EXTENSIONS) |  461 #if defined(ENABLE_EXTENSIONS) | 
|  474   InitializeExtensionsRequestContext(profile_params); |  462   extension_cookie_store_ = | 
 |  463     new net::CookieMonster( | 
 |  464         new SQLitePersistentCookieStore( | 
 |  465             lazy_params_->extension_cookie_path, | 
 |  466             BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 
 |  467             BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 
 |  468                 BrowserThread::GetBlockingPool()->GetSequenceToken()), | 
 |  469             lazy_params_->restore_old_session_cookies, NULL), NULL); | 
|  475 #endif |  470 #endif | 
|  476  |  471  | 
|  477   // Create a media request context based on the main context, but using a |  472   // Create a media request context based on the main context, but using a | 
|  478   // media cache.  It shares the same job factory as the main context. |  473   // media cache.  It shares the same job factory as the main context. | 
|  479   StoragePartitionDescriptor details(profile_path_, false); |  474   StoragePartitionDescriptor details(profile_path_, false); | 
|  480   media_request_context_.reset(InitializeMediaRequestContext(main_context, |  475   media_request_context_.reset(InitializeMediaRequestContext(main_context, | 
|  481                                                              details)); |  476                                                              details)); | 
|  482  |  477  | 
|  483   lazy_params_.reset(); |  478   lazy_params_.reset(); | 
|  484 } |  479 } | 
|  485  |  480  | 
|  486 void ProfileImplIOData:: |  | 
|  487     InitializeExtensionsRequestContext(ProfileParams* profile_params) const { |  | 
|  488   ChromeURLRequestContext* extensions_context = extensions_request_context(); |  | 
|  489   IOThread* const io_thread = profile_params->io_thread; |  | 
|  490   IOThread::Globals* const io_thread_globals = io_thread->globals(); |  | 
|  491   ApplyProfileParamsToContext(extensions_context); |  | 
|  492  |  | 
|  493   extensions_context->set_transport_security_state(transport_security_state()); |  | 
|  494  |  | 
|  495   extensions_context->set_net_log(io_thread->net_log()); |  | 
|  496  |  | 
|  497   extensions_context->set_throttler_manager( |  | 
|  498       io_thread_globals->throttler_manager.get()); |  | 
|  499  |  | 
|  500   net::CookieMonster* extensions_cookie_store = |  | 
|  501       new net::CookieMonster( |  | 
|  502           new SQLitePersistentCookieStore( |  | 
|  503               lazy_params_->extensions_cookie_path, |  | 
|  504               BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |  | 
|  505               BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |  | 
|  506                   BrowserThread::GetBlockingPool()->GetSequenceToken()), |  | 
|  507               lazy_params_->restore_old_session_cookies, NULL), NULL); |  | 
|  508   // Enable cookies for devtools and extension URLs. |  | 
|  509   const char* schemes[] = {chrome::kChromeDevToolsScheme, |  | 
|  510                            extensions::kExtensionScheme}; |  | 
|  511   extensions_cookie_store->SetCookieableSchemes(schemes, 2); |  | 
|  512   extensions_context->set_cookie_store(extensions_cookie_store); |  | 
|  513  |  | 
|  514 #if !defined(DISABLE_FTP_SUPPORT) |  | 
|  515   DCHECK(ftp_factory_.get()); |  | 
|  516   extensions_context->set_ftp_transaction_factory(ftp_factory_.get()); |  | 
|  517 #endif  // !defined(DISABLE_FTP_SUPPORT) |  | 
|  518  |  | 
|  519   scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |  | 
|  520       new net::URLRequestJobFactoryImpl()); |  | 
|  521   // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |  | 
|  522   // Without a network_delegate, this protocol handler will never |  | 
|  523   // handle file: requests, but as a side effect it makes |  | 
|  524   // job_factory::IsHandledProtocol return true, which prevents attempts to |  | 
|  525   // handle the protocol externally. We pass NULL in to |  | 
|  526   // SetUpJobFactory() to get this effect. |  | 
|  527   extensions_job_factory_ = SetUpJobFactoryDefaults( |  | 
|  528       extensions_job_factory.Pass(), |  | 
|  529       scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), |  | 
|  530       NULL, |  | 
|  531       extensions_context->ftp_transaction_factory(), |  | 
|  532       extensions_context->ftp_auth_cache()); |  | 
|  533   extensions_context->set_job_factory(extensions_job_factory_.get()); |  | 
|  534 } |  | 
|  535  |  | 
|  536 ChromeURLRequestContext* |  481 ChromeURLRequestContext* | 
|  537 ProfileImplIOData::InitializeAppRequestContext( |  482 ProfileImplIOData::InitializeAppRequestContext( | 
|  538     ChromeURLRequestContext* main_context, |  483     ChromeURLRequestContext* main_context, | 
|  539     const StoragePartitionDescriptor& partition_descriptor, |  484     const StoragePartitionDescriptor& partition_descriptor, | 
|  540     scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |  485     scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 
|  541         protocol_handler_interceptor, |  486         protocol_handler_interceptor, | 
|  542     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |  487     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 
|  543         blob_protocol_handler, |  488         blob_protocol_handler, | 
|  544     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |  489     scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 
|  545         file_system_protocol_handler, |  490         file_system_protocol_handler, | 
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  758     const base::Closure& completion) { |  703     const base::Closure& completion) { | 
|  759   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |  704   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
|  760   DCHECK(initialized()); |  705   DCHECK(initialized()); | 
|  761  |  706  | 
|  762   DCHECK(transport_security_state()); |  707   DCHECK(transport_security_state()); | 
|  763   // Completes synchronously. |  708   // Completes synchronously. | 
|  764   transport_security_state()->DeleteAllDynamicDataSince(time); |  709   transport_security_state()->DeleteAllDynamicDataSince(time); | 
|  765   DCHECK(http_server_properties_manager_); |  710   DCHECK(http_server_properties_manager_); | 
|  766   http_server_properties_manager_->Clear(completion); |  711   http_server_properties_manager_->Clear(completion); | 
|  767 } |  712 } | 
| OLD | NEW |