diff options
28 files changed, 140 insertions, 145 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 49acc20..6db9e6e 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -2010,14 +2010,8 @@ int BrowserMain(const MainFunctionParams& parameters) { // If we're running tests (ui_task is non-null), then we don't want to // call FetchLanguageListFromTranslateServer - if (parameters.ui_task == NULL && translate_manager != NULL) { - // TODO(willchan): Get rid of this after TranslateManager doesn't use - // the default request context. http://crbug.com/89396. - // This is necessary to force |default_request_context_| to be - // initialized. - profile->GetRequestContext(); + if (parameters.ui_task == NULL && translate_manager != NULL) translate_manager->FetchLanguageListFromTranslateServer(user_prefs); - } RunUIMessageLoop(browser_process.get()); } diff --git a/chrome/browser/browsing_data_appcache_helper.cc b/chrome/browser/browsing_data_appcache_helper.cc index 512e666..6a7e8ee 100644 --- a/chrome/browser/browsing_data_appcache_helper.cc +++ b/chrome/browser/browsing_data_appcache_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -14,8 +14,8 @@ using appcache::AppCacheDatabase; BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) - : is_fetching_(false), - appcache_service_(profile->GetAppCacheService()) { + : request_context_getter_(profile->GetRequestContext()), + is_fetching_(false) { } void BrowsingDataAppCacheHelper::StartFetching(Callback0::Type* callback) { @@ -34,8 +34,8 @@ void BrowsingDataAppCacheHelper::StartFetching(Callback0::Type* callback) { appcache_info_callback_ = new net::CancelableCompletionCallback<BrowsingDataAppCacheHelper>( this, &BrowsingDataAppCacheHelper::OnFetchComplete); - appcache_service_->GetAllAppCacheInfo(info_collection_, - appcache_info_callback_); + GetAppCacheService()->GetAllAppCacheInfo(info_collection_, + appcache_info_callback_); } void BrowsingDataAppCacheHelper::CancelNotification() { @@ -58,7 +58,7 @@ void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( manifest_url)); return; } - appcache_service_->DeleteAppCacheGroup(manifest_url, NULL); + GetAppCacheService()->DeleteAppCacheGroup(manifest_url, NULL); } BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} @@ -92,6 +92,15 @@ void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { } } +ChromeAppCacheService* BrowsingDataAppCacheHelper::GetAppCacheService() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + ChromeURLRequestContext* request_context = + reinterpret_cast<ChromeURLRequestContext*>( + request_context_getter_->GetURLRequestContext()); + return request_context ? request_context->appcache_service() + : NULL; +} + CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper( Profile* profile) : BrowsingDataAppCacheHelper(profile), diff --git a/chrome/browser/browsing_data_appcache_helper.h b/chrome/browser/browsing_data_appcache_helper.h index c40ff48..6dfad26 100644 --- a/chrome/browser/browsing_data_appcache_helper.h +++ b/chrome/browser/browsing_data_appcache_helper.h @@ -10,6 +10,7 @@ #include "base/task.h" #include "content/browser/appcache/chrome_appcache_service.h" #include "googleurl/src/gurl.h" +#include "net/url_request/url_request_context_getter.h" class Profile; @@ -38,9 +39,10 @@ class BrowsingDataAppCacheHelper private: void OnFetchComplete(int rv); + ChromeAppCacheService* GetAppCacheService(); + scoped_refptr<net::URLRequestContextGetter> request_context_getter_; bool is_fetching_; - scoped_refptr<ChromeAppCacheService> appcache_service_; scoped_refptr<net::CancelableCompletionCallback<BrowsingDataAppCacheHelper> > appcache_info_callback_; diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc index 1b6b267..76803ec 100644 --- a/chrome/browser/download/download_file_manager.cc +++ b/chrome/browser/download/download_file_manager.cc @@ -17,7 +17,6 @@ #include "chrome/browser/download/download_util.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/platform_util.h" -#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/tab_contents/tab_util.h" diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index f0b8db9..1a94cab 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -13,7 +13,6 @@ #include "base/string_util.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" -#include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension.h" diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index b7eea24..4c8a7c5 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -10,14 +10,16 @@ #include "base/synchronization/waitable_event.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/io_thread.h" -#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_io_data.h" +#include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "content/browser/browser_thread.h" #include "content/common/notification_service.h" #include "net/base/cookie_store.h" +#include "net/ftp/ftp_transaction_factory.h" +#include "net/http/http_transaction_factory.h" #include "net/http/http_util.h" #include "webkit/glue/webkit_glue.h" @@ -361,6 +363,10 @@ void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { URLRequestContext::CopyFrom(other); // Copy ChromeURLRequestContext parameters. + set_appcache_service(other->appcache_service()); + set_blob_storage_context(other->blob_storage_context()); + set_file_system_context(other->file_system_context()); + set_extension_info_map(other->extension_info_map_); // ChromeURLDataManagerBackend is unique per context. set_is_incognito(other->is_incognito()); } @@ -379,6 +385,9 @@ void ChromeURLRequestContext::set_chrome_url_data_manager_backend( ChromeURLRequestContext::~ChromeURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + if (appcache_service_.get() && appcache_service_->request_context() == this) + appcache_service_->set_request_context(NULL); + NotificationService::current()->Notify( chrome::NOTIFICATION_URL_REQUEST_CONTEXT_RELEASED, Source<net::URLRequestContext>(this), diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index 05157f7..dd716f6 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -9,16 +9,25 @@ #include <string> #include <vector> -#include "base/memory/scoped_ptr.h" +#include "base/file_path.h" +#include "base/memory/weak_ptr.h" +#include "chrome/browser/extensions/extension_info_map.h" +#include "chrome/browser/extensions/extension_webrequest_api.h" #include "chrome/browser/prefs/pref_change_registrar.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/extensions/extension_icon_set.h" +#include "content/browser/appcache/chrome_appcache_service.h" +#include "content/browser/chrome_blob_storage_context.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" +#include "webkit/fileapi/file_system_context.h" class ChromeURLDataManagerBackend; class ChromeURLRequestContextFactory; class IOThread; +class PrefService; class Profile; class ProfileIOData; namespace base { @@ -44,12 +53,32 @@ class ChromeURLRequestContext : public net::URLRequestContext { return weak_ptr_factory_.GetWeakPtr(); } + // Gets the appcache service to be used for requests in this context. + // May be NULL if requests for this context aren't subject to appcaching. + ChromeAppCacheService* appcache_service() const { + return appcache_service_.get(); + } + + // Gets the blob storage context associated with this context's profile. + ChromeBlobStorageContext* blob_storage_context() const { + return blob_storage_context_.get(); + } + + // Gets the file system host context with this context's profile. + fileapi::FileSystemContext* file_system_context() const { + return file_system_context_.get(); + } + bool is_incognito() const { return is_incognito_; } virtual const std::string& GetUserAgent(const GURL& url) const; + const ExtensionInfoMap* extension_info_map() const { + return extension_info_map_; + } + // TODO(willchan): Get rid of the need for this accessor. Really, this should // move completely to ProfileIOData. ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const; @@ -57,6 +86,18 @@ class ChromeURLRequestContext : public net::URLRequestContext { void set_is_incognito(bool is_incognito) { is_incognito_ = is_incognito; } + void set_appcache_service(ChromeAppCacheService* service) { + appcache_service_ = service; + } + void set_blob_storage_context(ChromeBlobStorageContext* context) { + blob_storage_context_ = context; + } + void set_file_system_context(fileapi::FileSystemContext* context) { + file_system_context_ = context; + } + void set_extension_info_map(ExtensionInfoMap* map) { + extension_info_map_ = map; + } void set_chrome_url_data_manager_backend( ChromeURLDataManagerBackend* backend); @@ -77,6 +118,13 @@ class ChromeURLRequestContext : public net::URLRequestContext { // be added to CopyFrom. // --------------------------------------------------------------------------- + // TODO(willchan): Make these non-refcounted. + scoped_refptr<ChromeAppCacheService> appcache_service_; + scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; + scoped_refptr<fileapi::FileSystemContext> file_system_context_; + // TODO(aa): This should use chrome/common/extensions/extension_set.h. + scoped_refptr<ExtensionInfoMap> extension_info_map_; + ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; bool is_incognito_; diff --git a/chrome/browser/net/pref_proxy_config_service_unittest.cc b/chrome/browser/net/pref_proxy_config_service_unittest.cc index 05d9e80..d350829 100644 --- a/chrome/browser/net/pref_proxy_config_service_unittest.cc +++ b/chrome/browser/net/pref_proxy_config_service_unittest.cc @@ -6,14 +6,12 @@ #include "base/command_line.h" #include "base/file_path.h" -#include "base/message_loop.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/prefs/pref_service_mock_builder.h" #include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_pref_service.h" -#include "content/browser/browser_thread.h" #include "net/proxy/proxy_config_service_common_unittest.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/net/view_blob_internals_job_factory.cc b/chrome/browser/net/view_blob_internals_job_factory.cc index 246e618..dd955e5 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.cc +++ b/chrome/browser/net/view_blob_internals_job_factory.cc @@ -4,7 +4,6 @@ #include "chrome/browser/net/view_blob_internals_job_factory.h" -#include "base/memory/scoped_ptr.h" #include "base/string_util.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/common/url_constants.h" @@ -20,8 +19,10 @@ bool ViewBlobInternalsJobFactory::IsSupportedURL(const GURL& url) { // static. net::URLRequestJob* ViewBlobInternalsJobFactory::CreateJobForRequest( - net::URLRequest* request, - webkit_blob::BlobStorageController* blob_storage_controller) { + net::URLRequest* request) { + webkit_blob::BlobStorageController* blob_storage_controller = + static_cast<const ChromeURLRequestContext*>(request->context())-> + blob_storage_context()->controller(); return new webkit_blob::ViewBlobInternalsJob( request, blob_storage_controller); } diff --git a/chrome/browser/net/view_blob_internals_job_factory.h b/chrome/browser/net/view_blob_internals_job_factory.h index 7cb8fbc..e2a118b 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.h +++ b/chrome/browser/net/view_blob_internals_job_factory.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -10,18 +10,13 @@ namespace net { class URLRequest; class URLRequestJob; } // namespace net -namespace webkit_blob { -class BlobStorageController; -} // webkit_blob class GURL; class ViewBlobInternalsJobFactory { public: static bool IsSupportedURL(const GURL& url); - static net::URLRequestJob* CreateJobForRequest( - net::URLRequest* request, - webkit_blob::BlobStorageController* blob_storage_controller); + static net::URLRequestJob* CreateJobForRequest(net::URLRequest* request); }; #endif // CHROME_BROWSER_NET_VIEW_BLOB_INTERNALS_JOB_FACTORY_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 2995816..30f9f2c 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -4,7 +4,6 @@ #include "chrome/browser/profiles/off_the_record_profile_io_data.h" -#include "base/bind.h" #include "base/logging.h" #include "base/stl_util-inl.h" #include "build/build_config.h" @@ -13,7 +12,6 @@ #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/chrome_network_delegate.h" #include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -46,17 +44,7 @@ OffTheRecordProfileIOData::Handle::~Handle() { iter->second->CleanupOnUIThread(); } - io_data_->AddRef(); - io_data_.release()->ShutdownOnUIThread(); -} - -base::Callback<ChromeURLDataManagerBackend*(void)> -OffTheRecordProfileIOData::Handle:: -GetChromeURLDataManagerBackendGetter() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - LazyInitialize(); - return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, - base::Unretained(io_data_.get())); + io_data_->ShutdownOnUIThread(); } const content::ResourceContext& 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 5e01c15..3904952 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -7,7 +7,6 @@ #pragma once #include "base/basictypes.h" -#include "base/callback.h" #include "base/file_path.h" #include "base/hash_tables.h" #include "base/memory/ref_counted.h" @@ -37,8 +36,6 @@ class OffTheRecordProfileIOData : public ProfileIOData { explicit Handle(Profile* profile); ~Handle(); - base::Callback<ChromeURLDataManagerBackend*(void)> - GetChromeURLDataManagerBackendGetter() const; const content::ResourceContext& GetResourceContext() const; scoped_refptr<ChromeURLRequestContextGetter> GetMainRequestContextGetter() const; @@ -72,7 +69,7 @@ class OffTheRecordProfileIOData : public ProfileIOData { extensions_request_context_getter_; mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_; - scoped_refptr<OffTheRecordProfileIOData> io_data_; + const scoped_refptr<OffTheRecordProfileIOData> io_data_; Profile* const profile_; diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index 174e3a3..f9d095e 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -18,13 +18,11 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/download/download_manager.h" -#include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extension_pref_store.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_special_storage_policy.h" -#include "chrome/browser/extensions/extension_webrequest_api.h" #include "chrome/browser/net/pref_proxy_config_service.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/off_the_record_profile_io_data.h" @@ -681,8 +679,7 @@ class OffTheRecordProfileImpl : public Profile, virtual ChromeURLDataManager* GetChromeURLDataManager() { if (!chrome_url_data_manager_.get()) - chrome_url_data_manager_.reset(new ChromeURLDataManager( - io_data_.GetChromeURLDataManagerBackendGetter())); + chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); return chrome_url_data_manager_.get(); } diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 75fc4e0..0cbc653 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -1518,8 +1518,7 @@ ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() { ChromeURLDataManager* ProfileImpl::GetChromeURLDataManager() { if (!chrome_url_data_manager_.get()) - chrome_url_data_manager_.reset(new ChromeURLDataManager( - io_data_.GetChromeURLDataManagerBackendGetter())); + chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); return chrome_url_data_manager_.get(); } diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index ccadce3..949f14e 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -4,7 +4,6 @@ #include "chrome/browser/profiles/profile_impl_io_data.h" -#include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/logging.h" @@ -14,7 +13,6 @@ #include "chrome/browser/net/chrome_network_delegate.h" #include "chrome/browser/net/sqlite_persistent_cookie_store.h" #include "chrome/browser/prefs/pref_member.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -49,7 +47,7 @@ ProfileImplIOData::Handle::~Handle() { iter->second->CleanupOnUIThread(); } - io_data_.release()->ShutdownOnUIThread(); + io_data_->ShutdownOnUIThread(); } void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, @@ -76,14 +74,6 @@ void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, io_data_->app_path_ = app_path; } -base::Callback<ChromeURLDataManagerBackend*(void)> -ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - LazyInitialize(); - return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, - base::Unretained(io_data_.get())); -} - const content::ResourceContext& ProfileImplIOData::Handle::GetResourceContext() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h index 0e122c1..188fa7f 100644 --- a/chrome/browser/profiles/profile_impl_io_data.h +++ b/chrome/browser/profiles/profile_impl_io_data.h @@ -7,7 +7,6 @@ #pragma once #include "base/basictypes.h" -#include "base/callback.h" #include "base/hash_tables.h" #include "base/memory/ref_counted.h" #include "chrome/browser/profiles/profile_io_data.h" @@ -37,8 +36,6 @@ class ProfileImplIOData : public ProfileIOData { const FilePath& extensions_cookie_path, const FilePath& app_path); - base::Callback<ChromeURLDataManagerBackend*(void)> - GetChromeURLDataManagerBackendGetter() const; const content::ResourceContext& GetResourceContext() const; scoped_refptr<ChromeURLRequestContextGetter> GetMainRequestContextGetter() const; @@ -75,7 +72,7 @@ class ProfileImplIOData : public ProfileIOData { mutable scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_getter_; mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_; - scoped_refptr<ProfileImplIOData> io_data_; + const scoped_refptr<ProfileImplIOData> io_data_; Profile* const profile_; diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index b8c4203..01e7bd5 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -12,11 +12,9 @@ #include "base/logging.h" #include "base/stl_util-inl.h" #include "base/string_number_conversions.h" -#include "base/task.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" -#include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/extensions/extension_protocols.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/media/media_internals.h" @@ -35,9 +33,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" -#include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/browser_thread.h" -#include "content/browser/chrome_blob_storage_context.h" #include "content/browser/host_zoom_map.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" @@ -51,7 +47,6 @@ #include "net/url_request/url_request.h" #include "webkit/blob/blob_data.h" #include "webkit/blob/blob_url_request_job_factory.h" -#include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_url_request_job_factory.h" #include "webkit/database/database_tracker.h" #include "webkit/quota/quota_manager.h" @@ -308,7 +303,14 @@ ProfileIOData::ProfileIOData(bool is_incognito) } ProfileIOData::~ProfileIOData() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + // If we have never initialized ProfileIOData, then Handle may hold the only + // reference to it. The important thing is to make sure it hasn't been + // initialized yet, because the lazily initialized variables are supposed to + // live on the IO thread. + if (BrowserThread::CurrentlyOn(BrowserThread::UI)) + DCHECK(!initialized_); + else + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } // static @@ -340,16 +342,6 @@ bool ProfileIOData::IsHandledURL(const GURL& url) { return IsHandledProtocol(url.scheme()); } -const content::ResourceContext& ProfileIOData::GetResourceContext() const { - return resource_context_; -} - -ChromeURLDataManagerBackend* -ProfileIOData::GetChromeURLDataManagerBackend() const { - LazyInitialize(); - return chrome_url_data_manager_backend_.get(); -} - scoped_refptr<ChromeURLRequestContext> ProfileIOData::GetMainRequestContext() const { LazyInitialize(); @@ -397,6 +389,10 @@ ProfileIOData::GetIsolatedAppRequestContext( return context; } +const content::ResourceContext& ProfileIOData::GetResourceContext() const { + return resource_context_; +} + ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { return extension_info_map_; } @@ -473,8 +469,7 @@ void ProfileIOData::LazyInitialize() const { chrome::kChromeUIScheme, ChromeURLDataManagerBackend::CreateProtocolHandler( chrome_url_data_manager_backend_.get(), - profile_params_->appcache_service, - profile_params_->blob_storage_context->controller())); + profile_params_->appcache_service)); DCHECK(set_protocol); set_protocol = job_factory_->SetProtocolHandler( chrome::kChromeDevToolsScheme, @@ -540,6 +535,10 @@ void ProfileIOData::ApplyProfileParamsToContext( context->set_transport_security_state( 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); } void ProfileIOData::ShutdownOnUIThread() { @@ -547,7 +546,4 @@ void ProfileIOData::ShutdownOnUIThread() { enable_referrers_.Destroy(); clear_local_state_on_exit_.Destroy(); safe_browsing_enabled_.Destroy(); - bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - new ReleaseTask<ProfileIOData>(this)); - DCHECK(posted); } diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index b8478be..de505c8 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -8,6 +8,7 @@ #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" @@ -79,10 +80,6 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { // net::URLRequest. static bool IsHandledURL(const GURL& url); - // Called by Profile. - const content::ResourceContext& GetResourceContext() const; - ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; - // These should only be called at most once each. Ownership is reversed when // they get called, from ProfileIOData owning ChromeURLRequestContext to vice // versa. @@ -92,6 +89,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; // These are useful when the Chrome layer is called from the content layer // with a content::ResourceContext, and they want access to Chrome data for diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 71cf4dd..ee8831f 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc @@ -37,7 +37,6 @@ class ProfileManagerTest : public TestingBrowserProcessTest { ProfileManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_), file_thread_(BrowserThread::FILE, &message_loop_), - io_thread_(BrowserThread::IO, &message_loop_), profile_manager_(new ProfileManagerWithoutInit), local_state_(testing_browser_process_.get()) { #if defined(OS_MACOSX) @@ -53,7 +52,6 @@ class ProfileManagerTest : public TestingBrowserProcessTest { virtual void TearDown() { profile_manager_.reset(); - message_loop_.RunAllPending(); } class MockObserver : public ProfileManagerObserver { @@ -67,7 +65,6 @@ class ProfileManagerTest : public TestingBrowserProcessTest { MessageLoopForUI message_loop_; BrowserThread ui_thread_; BrowserThread file_thread_; - BrowserThread io_thread_; scoped_ptr<base::SystemMonitor> system_monitor_dummy_; diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index ad0dab2..6fa5af7 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -13,7 +13,6 @@ #include "chrome/browser/download/mhtml_generation_manager.h" #include "chrome/browser/extensions/extension_event_router.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" -#include "chrome/browser/extensions/extension_info_map.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/metrics/histogram_synchronizer.h" #include "chrome/browser/nacl_host/nacl_process_host.h" @@ -84,7 +83,6 @@ ChromeRenderMessageFilter::ChromeRenderMessageFilter( : render_process_id_(render_process_id), profile_(profile), request_context_(request_context), - extension_info_map_(profile->GetExtensionInfoMap()), weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated, profile_->GetPrefs(), NULL); @@ -300,8 +298,11 @@ void ChromeRenderMessageFilter::OpenChannelToTabOnUIThread( void ChromeRenderMessageFilter::OnGetExtensionMessageBundle( const std::string& extension_id, IPC::Message* reply_msg) { + ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( + request_context_->GetURLRequestContext()); + const Extension* extension = - extension_info_map_->extensions().GetByID(extension_id); + context->extension_info_map()->extensions().GetByID(extension_id); FilePath extension_path; std::string default_locale; if (extension) { @@ -381,8 +382,10 @@ void ChromeRenderMessageFilter::OnExtensionRequestForIOThread( const ExtensionHostMsg_Request_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( + request_context_->GetURLRequestContext()); ExtensionFunctionDispatcher::DispatchOnIOThread( - extension_info_map_, profile_, render_process_id_, + context->extension_info_map(), profile_, render_process_id_, weak_ptr_factory_.GetWeakPtr(), routing_id, params); } @@ -494,18 +497,22 @@ void ChromeRenderMessageFilter::OnGetPluginContentSetting( void ChromeRenderMessageFilter::OnCanTriggerClipboardRead(const GURL& url, bool* allowed) { + ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( + request_context_->GetURLRequestContext()); const Extension* extension = - extension_info_map_->extensions().GetByURL(url); + context->extension_info_map()->extensions().GetByURL(url); *allowed = extension && extension->HasAPIPermission(ExtensionAPIPermission::kClipboardRead); } void ChromeRenderMessageFilter::OnCanTriggerClipboardWrite(const GURL& url, bool* allowed) { + ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( + request_context_->GetURLRequestContext()); // Since all extensions could historically write to the clipboard, preserve it // for compatibility. const Extension* extension = - extension_info_map_->extensions().GetByURL(url); + context->extension_info_map()->extensions().GetByURL(url); *allowed = url.SchemeIs(chrome::kExtensionScheme) || (extension && extension->HasAPIPermission(ExtensionAPIPermission::kClipboardWrite)); diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h index 8aa4cc4..c5283ef 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.h +++ b/chrome/browser/renderer_host/chrome_render_message_filter.h @@ -15,7 +15,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" struct ExtensionHostMsg_Request_Params; -class ExtensionInfoMap; class FilePath; class GURL; class HostContentSettingsMap; @@ -133,7 +132,6 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { // accessed on the UI thread! Profile* profile_; scoped_refptr<net::URLRequestContextGetter> request_context_; - scoped_refptr<ExtensionInfoMap> extension_info_map_; // Used to look up permissions at database creation time. scoped_refptr<HostContentSettingsMap> host_content_settings_map_; diff --git a/chrome/browser/ui/webui/chrome_url_data_manager.cc b/chrome/browser/ui/webui/chrome_url_data_manager.cc index 43ede09..16f8647 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager.cc @@ -8,7 +8,6 @@ #include "base/i18n/rtl.h" #include "base/memory/ref_counted_memory.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/synchronization/lock.h" @@ -32,15 +31,16 @@ ChromeURLDataManager::DataSources* ChromeURLDataManager::data_sources_ = NULL; // Invoked on the IO thread to do the actual adding of the DataSource. static void AddDataSourceOnIOThread( - const base::Callback<ChromeURLDataManagerBackend*(void)>& backend, + scoped_refptr<net::URLRequestContextGetter> context_getter, scoped_refptr<ChromeURLDataManager::DataSource> data_source) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - backend.Run()->AddDataSource(data_source.get()); + static_cast<ChromeURLRequestContext*>( + context_getter->GetURLRequestContext())-> + chrome_url_data_manager_backend()->AddDataSource(data_source.get()); } -ChromeURLDataManager::ChromeURLDataManager( - const base::Callback<ChromeURLDataManagerBackend*(void)>& backend) - : backend_(backend) { +ChromeURLDataManager::ChromeURLDataManager(Profile* profile) + : profile_(profile) { } ChromeURLDataManager::~ChromeURLDataManager() { @@ -51,7 +51,7 @@ void ChromeURLDataManager::AddDataSource(DataSource* source) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableFunction(AddDataSourceOnIOThread, - backend_, + make_scoped_refptr(profile_->GetRequestContext()), make_scoped_refptr(source))); } diff --git a/chrome/browser/ui/webui/chrome_url_data_manager.h b/chrome/browser/ui/webui/chrome_url_data_manager.h index 7cff56a..9bf894b 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager.h +++ b/chrome/browser/ui/webui/chrome_url_data_manager.h @@ -8,7 +8,6 @@ #include <string> -#include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/task.h" #include "content/browser/browser_thread.h" @@ -141,8 +140,7 @@ class ChromeURLDataManager { ChromeURLDataManagerBackend* backend_; }; - explicit ChromeURLDataManager( - const base::Callback<ChromeURLDataManagerBackend*(void)>& backend); + explicit ChromeURLDataManager(Profile* profile); ~ChromeURLDataManager(); // Adds a DataSource to the collection of data sources. This *must* be invoked @@ -173,10 +171,7 @@ class ChromeURLDataManager { // was invoked). static bool IsScheduledForDeletion(const DataSource* data_source); - // A callback that returns the ChromeURLDataManagerBackend. Only accessible on - // the IO thread. This is necessary because ChromeURLDataManager is created on - // the UI thread, but ChromeURLDataManagerBackend lives on the IO thread. - const base::Callback<ChromeURLDataManagerBackend*(void)> backend_; + Profile* profile_; // Lock used when accessing |data_sources_|. static base::Lock delete_lock_; diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc index 10a0123..a2344d0 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -19,7 +19,6 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" -#include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/browser_thread.h" #include "googleurl/src/url_util.h" #include "grit/platform_locale_settings.h" @@ -228,10 +227,8 @@ bool IsViewAppCacheInternalsURL(const GURL& url) { class ChromeProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - ChromeProtocolHandler( - ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service, - webkit_blob::BlobStorageController* blob_storage_controller); + ChromeProtocolHandler(ChromeURLDataManagerBackend* backend, + ChromeAppCacheService* appcache_service); ~ChromeProtocolHandler(); virtual net::URLRequestJob* MaybeCreateJob( @@ -241,18 +238,15 @@ class ChromeProtocolHandler // These members are owned by ProfileIOData, which owns this ProtocolHandler. ChromeURLDataManagerBackend* const backend_; ChromeAppCacheService* const appcache_service_; - webkit_blob::BlobStorageController* const blob_storage_controller_; DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler); }; ChromeProtocolHandler::ChromeProtocolHandler( ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service, - webkit_blob::BlobStorageController* blob_storage_controller) + ChromeAppCacheService* appcache_service) : backend_(backend), - appcache_service_(appcache_service), - blob_storage_controller_(blob_storage_controller) {} + appcache_service_(appcache_service) {} ChromeProtocolHandler::~ChromeProtocolHandler() {} @@ -271,8 +265,7 @@ net::URLRequestJob* ChromeProtocolHandler::MaybeCreateJob( // Next check for chrome://blob-internals/, which uses its own job type. if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) - return ViewBlobInternalsJobFactory::CreateJobForRequest( - request, blob_storage_controller_); + return ViewBlobInternalsJobFactory::CreateJobForRequest(request); // Fall back to using a custom handler return new URLRequestChromeJob(request, backend_); @@ -297,13 +290,10 @@ ChromeURLDataManagerBackend::~ChromeURLDataManagerBackend() { net::URLRequestJobFactory::ProtocolHandler* ChromeURLDataManagerBackend::CreateProtocolHandler( ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service, - webkit_blob::BlobStorageController* blob_storage_controller) { + ChromeAppCacheService* appcache_service) { DCHECK(appcache_service); - DCHECK(blob_storage_controller); DCHECK(backend); - return new ChromeProtocolHandler( - backend, appcache_service, blob_storage_controller); + return new ChromeProtocolHandler(backend, appcache_service); } void ChromeURLDataManagerBackend::AddDataSource( diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.h b/chrome/browser/ui/webui/chrome_url_data_manager_backend.h index 1f8cd74..55ef74a 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.h +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.h @@ -27,9 +27,6 @@ namespace net { class URLRequest; class URLRequestJob; } -namespace webkit_blob { -class BlobStorageController; -} // ChromeURLDataManagerBackend is used internally by ChromeURLDataManager on the // IO thread. In most cases you can use the API in ChromeURLDataManager and @@ -45,8 +42,7 @@ class ChromeURLDataManagerBackend { // Invoked to create the protocol handler for chrome://. static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service, - webkit_blob::BlobStorageController* blob_storage_controller); + ChromeAppCacheService* appcache_service); // Adds a DataSource to the collection of data sources. void AddDataSource(ChromeURLDataManager::DataSource* source); diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index afe8e32..3999c5e 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/webui/devtools_ui.h" -#include "base/memory/scoped_ptr.h" #include "base/string_util.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" diff --git a/chrome/browser/ui/webui/options/cookies_view_handler.cc b/chrome/browser/ui/webui/options/cookies_view_handler.cc index b2c1c7c..2f3b7d3 100644 --- a/chrome/browser/ui/webui/options/cookies_view_handler.cc +++ b/chrome/browser/ui/webui/options/cookies_view_handler.cc @@ -14,7 +14,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/cookies_tree_model_util.h" #include "grit/generated_resources.h" -#include "net/url_request/url_request_context_getter.h" #include "ui/base/l10n/l10n_util.h" CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 8433c50..dece6f6 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -765,9 +765,7 @@ PromoCounter* TestingProfile::GetInstantPromoCounter() { ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { if (!chrome_url_data_manager_.get()) - chrome_url_data_manager_.reset( - new ChromeURLDataManager( - base::Callback<ChromeURLDataManagerBackend*(void)>())); + chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); return chrome_url_data_manager_.get(); } |