diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 1 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 10 | ||||
-rw-r--r-- | chrome/browser/net/view_blob_internals_job_factory.cc | 3 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.cc | 31 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.h | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.cc | 8 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.h | 6 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.h | 1 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.cc | 42 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.h | 7 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 67 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.h | 35 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 15 | ||||
-rw-r--r-- | chrome/browser/web_resource/web_resource_service.h | 1 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/test/testing_profile.cc | 5 | ||||
-rw-r--r-- | chrome/test/testing_profile.h | 6 |
18 files changed, 160 insertions, 88 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 400e8a4..53d8490 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -374,7 +374,6 @@ void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { // Copy ChromeURLRequestContext parameters. set_user_script_dir_path(other->user_script_dir_path()); set_appcache_service(other->appcache_service()); - set_database_tracker(other->database_tracker()); set_host_content_settings_map(other->host_content_settings_map()); set_host_zoom_map(other->host_zoom_map_); set_blob_storage_context(other->blob_storage_context()); diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index a511ced..95bc71b 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -23,7 +23,6 @@ #include "net/base/cookie_policy.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" -#include "webkit/database/database_tracker.h" #include "webkit/fileapi/file_system_context.h" class ChromeURLDataManagerBackend; @@ -60,11 +59,6 @@ class ChromeURLRequestContext : public net::URLRequestContext { return appcache_service_.get(); } - // Gets the database tracker associated with this context's profile. - webkit_database::DatabaseTracker* database_tracker() const { - return database_tracker_.get(); - } - // Gets the blob storage context associated with this context's profile. ChromeBlobStorageContext* blob_storage_context() const { return blob_storage_context_.get(); @@ -114,9 +108,6 @@ class ChromeURLRequestContext : public net::URLRequestContext { void set_appcache_service(ChromeAppCacheService* service) { appcache_service_ = service; } - void set_database_tracker(webkit_database::DatabaseTracker* tracker) { - database_tracker_ = tracker; - } void set_blob_storage_context(ChromeBlobStorageContext* context) { blob_storage_context_ = context; } @@ -150,7 +141,6 @@ class ChromeURLRequestContext : public net::URLRequestContext { // TODO(willchan): Make these non-refcounted. scoped_refptr<ChromeAppCacheService> appcache_service_; - scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; scoped_refptr<HostContentSettingsMap> host_content_settings_map_; scoped_refptr<HostZoomMap> host_zoom_map_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; diff --git a/chrome/browser/net/view_blob_internals_job_factory.cc b/chrome/browser/net/view_blob_internals_job_factory.cc index c5fffef..1498934 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.cc +++ b/chrome/browser/net/view_blob_internals_job_factory.cc @@ -1,9 +1,10 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/net/view_blob_internals_job_factory.h" +#include "base/string_util.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/common/url_constants.h" #include "content/browser/chrome_blob_storage_context.h" diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index af07f6b..aa91112 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -19,8 +19,10 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" +#include "content/browser/resource_context.h" #include "net/ftp/ftp_network_layer.h" #include "net/http/http_cache.h" +#include "webkit/database/database_tracker.h" OffTheRecordProfileIOData::Handle::Handle(Profile* profile) : io_data_(new OffTheRecordProfileIOData), @@ -52,6 +54,13 @@ OffTheRecordProfileIOData::Handle::~Handle() { io_data_->ShutdownOnUIThread(); } +const content::ResourceContext& +OffTheRecordProfileIOData::Handle::GetResourceContext() const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + LazyInitialize(); + return io_data_->GetResourceContext(); +} + scoped_refptr<ChromeURLRequestContextGetter> OffTheRecordProfileIOData::Handle::GetMainRequestContextGetter() const { // TODO(oshima): Re-enable when ChromeOS only accesses the profile on the UI @@ -102,7 +111,7 @@ OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter( void OffTheRecordProfileIOData::Handle::LazyInitialize() const { if (!initialized_) { - InitializeProfileParams(profile_, &io_data_->lazy_params_->profile_params); + io_data_->InitializeProfileParams(profile_); ChromeNetworkDelegate::InitializeReferrersEnabled( io_data_->enable_referrers(), profile_->GetPrefs()); initialized_ = true; @@ -119,21 +128,21 @@ OffTheRecordProfileIOData::~OffTheRecordProfileIOData() { STLDeleteValues(&app_http_factory_map_); } -void OffTheRecordProfileIOData::LazyInitializeInternal() const { +void OffTheRecordProfileIOData::LazyInitializeInternal( + ProfileParams* profile_params) const { main_request_context_ = new RequestContext; extensions_request_context_ = new RequestContext; IOThread* const io_thread = lazy_params_->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); - const ProfileParams& profile_params = lazy_params_->profile_params; const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - ApplyProfileParamsToContext(profile_params, main_request_context_); - ApplyProfileParamsToContext(profile_params, extensions_request_context_); - profile_params.appcache_service->set_request_context(main_request_context_); + ApplyProfileParamsToContext(main_request_context_); + ApplyProfileParamsToContext(extensions_request_context_); + profile_params->appcache_service->set_request_context(main_request_context_); cookie_policy_.reset( - new ChromeCookiePolicy(profile_params.host_content_settings_map)); + new ChromeCookiePolicy(profile_params->host_content_settings_map)); main_request_context_->set_cookie_policy(cookie_policy_.get()); extensions_request_context_->set_cookie_policy(cookie_policy_.get()); @@ -142,9 +151,9 @@ void OffTheRecordProfileIOData::LazyInitializeInternal() const { network_delegate_.reset(new ChromeNetworkDelegate( io_thread_globals->extension_event_router_forwarder.get(), - profile_params.profile_id, + profile_params->profile_id, enable_referrers(), - profile_params.protocol_handler_registry)); + profile_params->protocol_handler_registry)); main_request_context_->set_network_delegate(network_delegate_.get()); main_request_context_->set_host_resolver( @@ -165,11 +174,11 @@ void OffTheRecordProfileIOData::LazyInitializeInternal() const { ProxyServiceFactory::CreateProxyService( io_thread->net_log(), io_thread_globals->proxy_script_fetcher_context.get(), - lazy_params_->profile_params.proxy_config_service.release(), + profile_params->proxy_config_service.release(), command_line)); main_request_context_->set_cookie_store( - new net::CookieMonster(NULL, profile_params.cookie_monster_delegate)); + new net::CookieMonster(NULL, profile_params->cookie_monster_delegate)); // All we care about for extensions is the cookie store. For incognito, we // use a non-persistent cookie store. diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h index 848e73a..18f0aef 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -37,6 +37,7 @@ class OffTheRecordProfileIOData : public ProfileIOData { explicit Handle(Profile* profile); ~Handle(); + const content::ResourceContext& GetResourceContext() const; scoped_refptr<ChromeURLRequestContextGetter> GetMainRequestContextGetter() const; scoped_refptr<ChromeURLRequestContextGetter> @@ -86,7 +87,6 @@ class OffTheRecordProfileIOData : public ProfileIOData { ~LazyParams(); IOThread* io_thread; - ProfileParams profile_params; }; typedef base::hash_map<std::string, net::HttpTransactionFactory* > @@ -96,7 +96,7 @@ class OffTheRecordProfileIOData : public ProfileIOData { ~OffTheRecordProfileIOData(); // Lazily initializes ProfileIOData. - virtual void LazyInitializeInternal() const; + virtual void LazyInitializeInternal(ProfileParams* profile_params) const; virtual scoped_refptr<RequestContext> InitializeAppRequestContext( scoped_refptr<ChromeURLRequestContext> main_context, const std::string& app_id) const; diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index 57118af..5fc6a13 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -422,15 +422,19 @@ class OffTheRecordProfileImpl : public Profile, return io_data_.GetMainRequestContextGetter(); } - net::URLRequestContextGetter* GetRequestContextForExtensions() { + virtual net::URLRequestContextGetter* GetRequestContextForExtensions() { return io_data_.GetExtensionsRequestContextGetter(); } - net::URLRequestContextGetter* GetRequestContextForIsolatedApp( + virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( const std::string& app_id) { return io_data_.GetIsolatedAppRequestContextGetter(app_id); } + virtual const content::ResourceContext& GetResourceContext() { + return io_data_.GetResourceContext(); + } + virtual net::SSLConfigService* GetSSLConfigService() { return profile_->GetSSLConfigService(); } diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 71ea976e..8d23838 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -15,6 +15,10 @@ namespace base { class Time; } +namespace content { +class ResourceContext; +} + namespace fileapi { class FileSystemContext; class SandboxedFileSystemContext; @@ -340,6 +344,8 @@ class Profile { virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( const std::string& app_id) = 0; + virtual const content::ResourceContext& GetResourceContext() = 0; + // Called by the ExtensionService that lives in this profile. Gives the // profile a chance to react to the load event before the EXTENSION_LOADED // notification has fired. The purpose for handling this event first is to diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 64b2fe0..85968d4 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -822,6 +822,10 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { return io_data_.GetMediaRequestContextGetter(); } +const content::ResourceContext& ProfileImpl::GetResourceContext() { + return io_data_.GetResourceContext(); +} + FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { if (!favicon_service_created_) { favicon_service_created_ = true; diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index de95edd..cb65b63 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -86,6 +86,7 @@ class ProfileImpl : public Profile, virtual net::URLRequestContextGetter* GetRequestContextForExtensions(); virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( const std::string& app_id); + virtual const content::ResourceContext& GetResourceContext(); virtual void RegisterExtensionWithRequestContexts(const Extension* extension); virtual void UnregisterExtensionWithRequestContexts( const Extension* extension); diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index 2bce373..feb5223 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -21,6 +21,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" +#include "content/browser/resource_context.h" #include "net/ftp/ftp_network_layer.h" #include "net/http/http_cache.h" @@ -78,6 +79,13 @@ void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, io_data_->app_path_ = app_path; } +const content::ResourceContext& +ProfileImplIOData::Handle::GetResourceContext() const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + LazyInitialize(); + return io_data_->GetResourceContext(); +} + scoped_refptr<ChromeURLRequestContextGetter> ProfileImplIOData::Handle::GetMainRequestContextGetter() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -137,10 +145,7 @@ ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter( void ProfileImplIOData::Handle::LazyInitialize() const { if (!initialized_) { - InitializeProfileParams(profile_, &io_data_->lazy_params_->profile_params); - // Keep track of clear_local_state_on_exit for isolated apps. - io_data_->clear_local_state_on_exit_ = - io_data_->lazy_params_->profile_params.clear_local_state_on_exit; + io_data_->InitializeProfileParams(profile_); ChromeNetworkDelegate::InitializeReferrersEnabled( io_data_->enable_referrers(), profile_->GetPrefs()); initialized_ = true; @@ -160,14 +165,17 @@ ProfileImplIOData::~ProfileImplIOData() { STLDeleteValues(&app_http_factory_map_); } -void ProfileImplIOData::LazyInitializeInternal() const { +void ProfileImplIOData::LazyInitializeInternal( + ProfileParams* profile_params) const { + // Keep track of clear_local_state_on_exit for isolated apps. + clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; + main_request_context_ = new RequestContext; media_request_context_ = new RequestContext; extensions_request_context_ = new RequestContext; IOThread* const io_thread = lazy_params_->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); - const ProfileParams& profile_params = lazy_params_->profile_params; const CommandLine& command_line = *CommandLine::ForCurrentProcess(); bool record_mode = chrome::kRecordModeEnabled && command_line.HasSwitch(switches::kRecordMode); @@ -175,13 +183,13 @@ void ProfileImplIOData::LazyInitializeInternal() const { // Initialize context members. - ApplyProfileParamsToContext(profile_params, main_request_context_); - ApplyProfileParamsToContext(profile_params, media_request_context_); - ApplyProfileParamsToContext(profile_params, extensions_request_context_); - profile_params.appcache_service->set_request_context(main_request_context_); + ApplyProfileParamsToContext(main_request_context_); + ApplyProfileParamsToContext(media_request_context_); + ApplyProfileParamsToContext(extensions_request_context_); + profile_params->appcache_service->set_request_context(main_request_context_); cookie_policy_.reset( - new ChromeCookiePolicy(profile_params.host_content_settings_map)); + new ChromeCookiePolicy(profile_params->host_content_settings_map)); main_request_context_->set_cookie_policy(cookie_policy_.get()); media_request_context_->set_cookie_policy(cookie_policy_.get()); extensions_request_context_->set_cookie_policy(cookie_policy_.get()); @@ -192,9 +200,9 @@ void ProfileImplIOData::LazyInitializeInternal() const { network_delegate_.reset(new ChromeNetworkDelegate( io_thread_globals->extension_event_router_forwarder.get(), - profile_params.profile_id, + profile_params->profile_id, enable_referrers(), - profile_params.protocol_handler_registry)); + profile_params->protocol_handler_registry)); main_request_context_->set_network_delegate(network_delegate_.get()); media_request_context_->set_network_delegate(network_delegate_.get()); @@ -225,7 +233,7 @@ void ProfileImplIOData::LazyInitializeInternal() const { ProxyServiceFactory::CreateProxyService( io_thread->net_log(), io_thread_globals->proxy_script_fetcher_context.get(), - lazy_params_->profile_params.proxy_config_service.release(), + profile_params->proxy_config_service.release(), command_line); main_request_context_->set_proxy_service(proxy_service); media_request_context_->set_proxy_service(proxy_service); @@ -261,7 +269,7 @@ void ProfileImplIOData::LazyInitializeInternal() const { if (record_mode || playback_mode) { // Don't use existing cookies and use an in-memory store. cookie_store = new net::CookieMonster( - NULL, profile_params.cookie_monster_delegate); + NULL, profile_params->cookie_monster_delegate); main_cache->set_mode( record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); } @@ -273,10 +281,10 @@ void ProfileImplIOData::LazyInitializeInternal() const { scoped_refptr<SQLitePersistentCookieStore> cookie_db = new SQLitePersistentCookieStore(lazy_params_->cookie_path); cookie_db->SetClearLocalStateOnExit( - profile_params.clear_local_state_on_exit); + profile_params->clear_local_state_on_exit); cookie_store = new net::CookieMonster(cookie_db.get(), - profile_params.cookie_monster_delegate); + profile_params->cookie_monster_delegate); } net::CookieMonster* extensions_cookie_store = diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h index 4210040..08dc205 100644 --- a/chrome/browser/profiles/profile_impl_io_data.h +++ b/chrome/browser/profiles/profile_impl_io_data.h @@ -39,6 +39,7 @@ class ProfileImplIOData : public ProfileIOData { const FilePath& extensions_cookie_path, const FilePath& app_path); + const content::ResourceContext& GetResourceContext() const; scoped_refptr<ChromeURLRequestContextGetter> GetMainRequestContextGetter() const; scoped_refptr<ChromeURLRequestContextGetter> @@ -98,8 +99,6 @@ class ProfileImplIOData : public ProfileIOData { int media_cache_max_size; FilePath extensions_cookie_path; IOThread* io_thread; - - ProfileParams profile_params; }; typedef base::hash_map<std::string, net::HttpTransactionFactory* > @@ -109,7 +108,7 @@ class ProfileImplIOData : public ProfileIOData { virtual ~ProfileImplIOData(); // Lazily initializes ProfileImplIOData. - virtual void LazyInitializeInternal() const; + virtual void LazyInitializeInternal(ProfileParams* profile_params) const; virtual scoped_refptr<RequestContext> InitializeAppRequestContext( scoped_refptr<ChromeURLRequestContext> main_context, const std::string& app_id) const; @@ -142,7 +141,7 @@ class ProfileImplIOData : public ProfileIOData { // Parameters needed for isolated apps. FilePath app_path_; - bool clear_local_state_on_exit_; + mutable bool clear_local_state_on_exit_; DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData); }; diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index aade3dc..1502bb7 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -8,7 +8,9 @@ #include "base/basictypes.h" #include "base/command_line.h" +#include "base/compiler_specific.h" #include "base/logging.h" +#include "base/stl_util-inl.h" #include "base/string_number_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" @@ -23,11 +25,13 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "content/browser/browser_thread.h" +#include "content/browser/resource_context.h" #include "content/common/notification_service.h" #include "net/http/http_util.h" #include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_script_fetcher_impl.h" #include "net/proxy/proxy_service.h" +#include "webkit/database/database_tracker.h" namespace { @@ -121,12 +125,11 @@ class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { } // namespace -// static -void ProfileIOData::InitializeProfileParams(Profile* profile, - ProfileParams* params) { +void ProfileIOData::InitializeProfileParams(Profile* profile) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PrefService* pref_service = profile->GetPrefs(); + scoped_ptr<ProfileParams> params(new ProfileParams); params->is_incognito = profile->IsOffTheRecord(); params->clear_local_state_on_exit = pref_service->GetBoolean(prefs::kClearSiteDataOnExit); @@ -177,6 +180,7 @@ void ProfileIOData::InitializeProfileParams(Profile* profile, ProxyServiceFactory::CreateProxyConfigService( profile->GetProxyConfigTracker())); params->profile_id = profile->GetRuntimeId(); + profile_params_.reset(params.release()); } ProfileIOData::RequestContext::RequestContext() {} @@ -189,7 +193,8 @@ ProfileIOData::ProfileParams::ProfileParams() ProfileIOData::ProfileParams::~ProfileParams() {} ProfileIOData::ProfileIOData(bool is_incognito) - : initialized_(false) { + : initialized_(false), + ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } @@ -242,35 +247,51 @@ ProfileIOData::GetIsolatedAppRequestContext( return context; } +const content::ResourceContext& ProfileIOData::GetResourceContext() const { + return resource_context_; +} + +ProfileIOData::ResourceContext::ResourceContext(const ProfileIOData* io_data) + : io_data_(io_data) { + DCHECK(io_data); +} + +ProfileIOData::ResourceContext::~ResourceContext() {} + +void ProfileIOData::ResourceContext::EnsureInitialized() const { + io_data_->LazyInitialize(); +} + void ProfileIOData::LazyInitialize() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (initialized_) return; - LazyInitializeInternal(); + DCHECK(profile_params_.get()); + database_tracker_ = profile_params_->database_tracker; + resource_context_.set_database_tracker(database_tracker_); + LazyInitializeInternal(profile_params_.get()); + profile_params_.reset(); initialized_ = true; } -// static void ProfileIOData::ApplyProfileParamsToContext( - const ProfileParams& profile_params, - ChromeURLRequestContext* context) { - context->set_is_incognito(profile_params.is_incognito); - context->set_accept_language(profile_params.accept_language); - context->set_accept_charset(profile_params.accept_charset); - context->set_referrer_charset(profile_params.referrer_charset); - context->set_user_script_dir_path(profile_params.user_script_dir_path); + ChromeURLRequestContext* context) const { + context->set_is_incognito(profile_params_->is_incognito); + context->set_accept_language(profile_params_->accept_language); + context->set_accept_charset(profile_params_->accept_charset); + context->set_referrer_charset(profile_params_->referrer_charset); + context->set_user_script_dir_path(profile_params_->user_script_dir_path); context->set_host_content_settings_map( - profile_params.host_content_settings_map); - context->set_host_zoom_map(profile_params.host_zoom_map); + profile_params_->host_content_settings_map); + context->set_host_zoom_map(profile_params_->host_zoom_map); context->set_transport_security_state( - profile_params.transport_security_state); - context->set_ssl_config_service(profile_params.ssl_config_service); - context->set_database_tracker(profile_params.database_tracker); - context->set_appcache_service(profile_params.appcache_service); - context->set_blob_storage_context(profile_params.blob_storage_context); - context->set_file_system_context(profile_params.file_system_context); - context->set_extension_info_map(profile_params.extension_info_map); - context->set_prerender_manager(profile_params.prerender_manager); + profile_params_->transport_security_state); + context->set_ssl_config_service(profile_params_->ssl_config_service); + context->set_appcache_service(profile_params_->appcache_service); + context->set_blob_storage_context(profile_params_->blob_storage_context); + context->set_file_system_context(profile_params_->file_system_context); + context->set_extension_info_map(profile_params_->extension_info_map); + context->set_prerender_manager(profile_params_->prerender_manager); } void ProfileIOData::ShutdownOnUIThread() { diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index 739ba4b..b846987 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -6,24 +6,26 @@ #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ #pragma once +#include <set> #include "base/basictypes.h" +#include "base/debug/stack_trace.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/synchronization/lock.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/profiles/profile.h" +#include "content/browser/resource_context.h" #include "net/base/cookie_monster.h" class CommandLine; class ChromeAppCacheService; class ChromeBlobStorageContext; -class ChromeURLRequestContext; -class ChromeURLRequestContextGetter; class ExtensionInfoMap; namespace fileapi { class FileSystemContext; -} +} // namespace fileapi class HostContentSettingsMap; class HostZoomMap; class IOThread; @@ -67,6 +69,7 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( scoped_refptr<ChromeURLRequestContext> main_context, const std::string& app_id) const; + const content::ResourceContext& GetResourceContext() const; protected: friend class base::RefCountedThreadSafe<ProfileIOData>; @@ -120,12 +123,8 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { explicit ProfileIOData(bool is_incognito); virtual ~ProfileIOData(); - // Static helper functions to assist in common operations executed by - // subtypes. - - static void InitializeProfileParams(Profile* profile, ProfileParams* params); - static void ApplyProfileParamsToContext(const ProfileParams& profile_params, - ChromeURLRequestContext* context); + void InitializeProfileParams(Profile* profile); + void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; // Lazy initializes the ProfileIOData object the first time a request context // is requested. The lazy logic is implemented here. The actual initialization @@ -141,13 +140,24 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { } private: + class ResourceContext : public content::ResourceContext { + public: + explicit ResourceContext(const ProfileIOData* io_data); + virtual ~ResourceContext(); + + private: + virtual void EnsureInitialized() const; + + const ProfileIOData* const io_data_; + }; + // -------------------------------------------- // Virtual interface for subtypes to implement: // -------------------------------------------- // Does the actual initialization of the ProfileIOData subtype. Subtypes // should use the static helper functions above to implement this. - virtual void LazyInitializeInternal() const = 0; + virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; // Does an on-demand initialization of a RequestContext for the given // isolated app. @@ -168,8 +178,11 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { scoped_refptr<ChromeURLRequestContext> main_context, const std::string& app_id) const = 0; - mutable BooleanPrefMember enable_referrers_; mutable bool initialized_; + mutable scoped_ptr<ProfileParams> profile_params_; + mutable BooleanPrefMember enable_referrers_; + mutable scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; + mutable ResourceContext resource_context_; DISALLOW_COPY_AND_ASSIGN(ProfileIOData); }; diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 951b5f7..6a5364d 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -465,6 +465,7 @@ void BrowserRenderProcessHost::CreateMessageFilters() { ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( id(), ChildProcessInfo::RENDER_PROCESS, + &profile()->GetResourceContext(), g_browser_process->resource_dispatcher_host()); resource_message_filter->set_url_request_context_override( url_request_context_override); @@ -507,12 +508,14 @@ void BrowserRenderProcessHost::CreateMessageFilters() { channel_->AddFilter(socket_stream_dispatcher_host); channel_->AddFilter(new SpellCheckMessageFilter()); - channel_->AddFilter(new WorkerMessageFilter( - id(), - profile()->GetRequestContext(), - g_browser_process->resource_dispatcher_host(), - NewCallbackWithReturnValue( - widget_helper_.get(), &RenderWidgetHelper::GetNextRoutingID))); + channel_->AddFilter( + new WorkerMessageFilter( + id(), + profile()->GetRequestContext(), + &profile()->GetResourceContext(), + g_browser_process->resource_dispatcher_host(), + NewCallbackWithReturnValue( + widget_helper_.get(), &RenderWidgetHelper::GetNextRoutingID))); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableP2PApi)) channel_->AddFilter(new P2PSocketDispatcherHost()); diff --git a/chrome/browser/web_resource/web_resource_service.h b/chrome/browser/web_resource/web_resource_service.h index 32f31e4..6746d79 100644 --- a/chrome/browser/web_resource/web_resource_service.h +++ b/chrome/browser/web_resource/web_resource_service.h @@ -13,6 +13,7 @@ class PrefService; class Profile; +class ResourceDispatcherHost; // A WebResourceService fetches data from a web resource server and store // locally as user preference. diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index d4fb492..8635ee9 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -177,6 +177,8 @@ '../content/browser/geolocation/arbitrator_dependency_factories_for_test.h', '../content/browser/geolocation/mock_location_provider.cc', '../content/browser/geolocation/mock_location_provider.h', + '../content/browser/mock_resource_context.cc', + '../content/browser/mock_resource_context.h', '../content/browser/renderer_host/mock_render_process_host.cc', '../content/browser/renderer_host/mock_render_process_host.h', '../content/browser/renderer_host/test_backing_store.cc', diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index ce16f43..09b91ab 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -48,6 +48,7 @@ #include "content/browser/browser_thread.h" #include "content/browser/geolocation/geolocation_permission_context.h" #include "content/browser/in_process_webkit/webkit_context.h" +#include "content/browser/mock_resource_context.h" #include "content/common/notification_service.h" #include "net/base/cookie_monster.h" #include "net/url_request/url_request_context.h" @@ -593,6 +594,10 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContextForIsolatedApp( return GetRequestContext(); } +const content::ResourceContext& TestingProfile::GetResourceContext() { + return content::MockResourceContext::GetInstance(); +} + FindBarState* TestingProfile::GetFindBarState() { if (!find_bar_state_.get()) find_bar_state_.reset(new FindBarState()); diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index f43a87f..13c252f 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -12,6 +12,10 @@ #include "base/timer.h" #include "chrome/browser/profiles/profile.h" +namespace content { +class ResourceContextGetter; +} + namespace history { class TopSites; } @@ -207,6 +211,8 @@ class TestingProfile : public Profile { virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( const std::string& app_id); + virtual const content::ResourceContext& GetResourceContext(); + virtual net::SSLConfigService* GetSSLConfigService(); virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher(); virtual FindBarState* GetFindBarState(); |