diff options
34 files changed, 187 insertions, 156 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 4615c72..e580e03 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -2008,8 +2008,14 @@ 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) + 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(); 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 6a7e8ee..512e666 100644 --- a/chrome/browser/browsing_data_appcache_helper.cc +++ b/chrome/browser/browsing_data_appcache_helper.cc @@ -1,4 +1,4 @@ -// 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. @@ -14,8 +14,8 @@ using appcache::AppCacheDatabase; BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) - : request_context_getter_(profile->GetRequestContext()), - is_fetching_(false) { + : is_fetching_(false), + appcache_service_(profile->GetAppCacheService()) { } 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); - GetAppCacheService()->GetAllAppCacheInfo(info_collection_, - appcache_info_callback_); + appcache_service_->GetAllAppCacheInfo(info_collection_, + appcache_info_callback_); } void BrowsingDataAppCacheHelper::CancelNotification() { @@ -58,7 +58,7 @@ void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( manifest_url)); return; } - GetAppCacheService()->DeleteAppCacheGroup(manifest_url, NULL); + appcache_service_->DeleteAppCacheGroup(manifest_url, NULL); } BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} @@ -92,15 +92,6 @@ 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 6dfad26..c40ff48 100644 --- a/chrome/browser/browsing_data_appcache_helper.h +++ b/chrome/browser/browsing_data_appcache_helper.h @@ -10,7 +10,6 @@ #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; @@ -39,10 +38,9 @@ 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 76803ec..1b6b267 100644 --- a/chrome/browser/download/download_file_manager.cc +++ b/chrome/browser/download/download_file_manager.cc @@ -17,6 +17,7 @@ #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 1a94cab..f0b8db9 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -13,6 +13,7 @@ #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/io_thread.cc b/chrome/browser/io_thread.cc index faa9054..1de2126 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -671,6 +671,9 @@ net::SSLConfigService* IOThread::GetSSLConfigService() { void IOThread::InitSystemRequestContext() { if (system_url_request_context_getter_) return; + // If we're in unit_tests, IOThread may not be run. + if (!message_loop()) + return; system_proxy_config_service_.reset( ProxyServiceFactory::CreateProxyConfigService( pref_proxy_config_tracker_)); diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 4c8a7c5..d96fbc0 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -10,16 +10,14 @@ #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" @@ -363,21 +361,17 @@ 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()); } ChromeURLDataManagerBackend* ChromeURLRequestContext::chrome_url_data_manager_backend() const { - return chrome_url_data_manager_backend_; + return chrome_url_data_manager_backend_; } void ChromeURLRequestContext::set_chrome_url_data_manager_backend( - ChromeURLDataManagerBackend* backend) { + ChromeURLDataManagerBackend* backend) { DCHECK(backend); chrome_url_data_manager_backend_ = backend; } @@ -385,9 +379,6 @@ 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 dd716f6..22db34c 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -9,25 +9,16 @@ #include <string> #include <vector> -#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 "base/memory/scoped_ptr.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 { @@ -53,32 +44,12 @@ 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; @@ -86,18 +57,7 @@ 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); @@ -118,13 +78,6 @@ 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 d350829..05d9e80 100644 --- a/chrome/browser/net/pref_proxy_config_service_unittest.cc +++ b/chrome/browser/net/pref_proxy_config_service_unittest.cc @@ -6,12 +6,14 @@ #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 dd955e5..246e618 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.cc +++ b/chrome/browser/net/view_blob_internals_job_factory.cc @@ -4,6 +4,7 @@ #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" @@ -19,10 +20,8 @@ bool ViewBlobInternalsJobFactory::IsSupportedURL(const GURL& url) { // static. net::URLRequestJob* ViewBlobInternalsJobFactory::CreateJobForRequest( - net::URLRequest* request) { - webkit_blob::BlobStorageController* blob_storage_controller = - static_cast<const ChromeURLRequestContext*>(request->context())-> - blob_storage_context()->controller(); + net::URLRequest* request, + webkit_blob::BlobStorageController* blob_storage_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 e2a118b..7cb8fbc 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) 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. @@ -10,13 +10,18 @@ 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); + static net::URLRequestJob* CreateJobForRequest( + net::URLRequest* request, + webkit_blob::BlobStorageController* blob_storage_controller); }; #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 30f9f2c..2995816 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -4,6 +4,7 @@ #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" @@ -12,6 +13,7 @@ #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" @@ -44,7 +46,17 @@ OffTheRecordProfileIOData::Handle::~Handle() { iter->second->CleanupOnUIThread(); } - io_data_->ShutdownOnUIThread(); + 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())); } 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 3904952..5e01c15 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -7,6 +7,7 @@ #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" @@ -36,6 +37,8 @@ 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; @@ -69,7 +72,7 @@ class OffTheRecordProfileIOData : public ProfileIOData { extensions_request_context_getter_; mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_; - const scoped_refptr<OffTheRecordProfileIOData> io_data_; + scoped_refptr<OffTheRecordProfileIOData> io_data_; Profile* const profile_; diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index 763bf86..f82826c 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -18,11 +18,13 @@ #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" @@ -676,7 +678,8 @@ class OffTheRecordProfileImpl : public Profile, virtual ChromeURLDataManager* GetChromeURLDataManager() { if (!chrome_url_data_manager_.get()) - chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); + chrome_url_data_manager_.reset(new ChromeURLDataManager( + io_data_.GetChromeURLDataManagerBackendGetter())); return chrome_url_data_manager_.get(); } diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 3c850a5..aff0315 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -1567,7 +1567,8 @@ ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() { ChromeURLDataManager* ProfileImpl::GetChromeURLDataManager() { if (!chrome_url_data_manager_.get()) - chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); + chrome_url_data_manager_.reset(new ChromeURLDataManager( + io_data_.GetChromeURLDataManagerBackendGetter())); 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 949f14e..ccadce3 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -4,6 +4,7 @@ #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" @@ -13,6 +14,7 @@ #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" @@ -47,7 +49,7 @@ ProfileImplIOData::Handle::~Handle() { iter->second->CleanupOnUIThread(); } - io_data_->ShutdownOnUIThread(); + io_data_.release()->ShutdownOnUIThread(); } void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, @@ -74,6 +76,14 @@ 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 188fa7f..0e122c1 100644 --- a/chrome/browser/profiles/profile_impl_io_data.h +++ b/chrome/browser/profiles/profile_impl_io_data.h @@ -7,6 +7,7 @@ #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" @@ -36,6 +37,8 @@ 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; @@ -72,7 +75,7 @@ class ProfileImplIOData : public ProfileIOData { mutable scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_getter_; mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_; - const scoped_refptr<ProfileImplIOData> io_data_; + 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 01e7bd5..63f0499 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -12,9 +12,11 @@ #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" @@ -33,7 +35,9 @@ #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" @@ -47,6 +51,7 @@ #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" @@ -303,13 +308,7 @@ ProfileIOData::ProfileIOData(bool is_incognito) } ProfileIOData::~ProfileIOData() { - // 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 + if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } @@ -342,6 +341,16 @@ 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(); @@ -389,10 +398,6 @@ ProfileIOData::GetIsolatedAppRequestContext( return context; } -const content::ResourceContext& ProfileIOData::GetResourceContext() const { - return resource_context_; -} - ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { return extension_info_map_; } @@ -469,7 +474,8 @@ void ProfileIOData::LazyInitialize() const { chrome::kChromeUIScheme, ChromeURLDataManagerBackend::CreateProtocolHandler( chrome_url_data_manager_backend_.get(), - profile_params_->appcache_service)); + profile_params_->appcache_service, + profile_params_->blob_storage_context->controller())); DCHECK(set_protocol); set_protocol = job_factory_->SetProtocolHandler( chrome::kChromeDevToolsScheme, @@ -535,10 +541,6 @@ 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() { @@ -546,4 +548,8 @@ 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)); + if (!posted) + Release(); } diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index de505c8..b8478be 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -8,7 +8,6 @@ #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" @@ -80,6 +79,10 @@ 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. @@ -89,7 +92,6 @@ 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 5386fd9..cac255e 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc @@ -10,6 +10,8 @@ #include "base/scoped_temp_dir.h" #include "base/system_monitor/system_monitor.h" #include "base/values.h" +#include "chrome/browser/extensions/extension_event_router_forwarder.h" +#include "chrome/browser/io_thread.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -35,14 +37,18 @@ Profile* g_created_profile; class ProfileManagerTest : public TestingBrowserProcessTest { protected: ProfileManagerTest() - : ui_thread_(BrowserThread::UI, &message_loop_), + : local_state_(testing_browser_process_.get()), + extension_event_router_forwarder_(new ExtensionEventRouterForwarder), + ui_thread_(BrowserThread::UI, &message_loop_), + db_thread_(BrowserThread::DB, &message_loop_), file_thread_(BrowserThread::FILE, &message_loop_), - profile_manager_(new ProfileManagerWithoutInit), - local_state_(testing_browser_process_.get()) { + io_thread_(local_state_.Get(), NULL, extension_event_router_forwarder_), + profile_manager_(new ProfileManagerWithoutInit) { #if defined(OS_MACOSX) base::SystemMonitor::AllocateSystemIOPorts(); #endif system_monitor_dummy_.reset(new base::SystemMonitor); + testing_browser_process_.get()->SetIOThread(&io_thread_); } virtual void SetUp() { @@ -52,6 +58,7 @@ class ProfileManagerTest : public TestingBrowserProcessTest { virtual void TearDown() { profile_manager_.reset(); + message_loop_.RunAllPending(); } class MockObserver : public ProfileManagerObserver { @@ -61,17 +68,20 @@ class ProfileManagerTest : public TestingBrowserProcessTest { // The path to temporary directory used to contain the test operations. ScopedTempDir temp_dir_; + ScopedTestingLocalState local_state_; + scoped_refptr<ExtensionEventRouterForwarder> + extension_event_router_forwarder_; MessageLoopForUI message_loop_; BrowserThread ui_thread_; + BrowserThread db_thread_; BrowserThread file_thread_; + IOThread io_thread_; scoped_ptr<base::SystemMonitor> system_monitor_dummy_; // Also will test profile deletion. scoped_ptr<ProfileManager> profile_manager_; - - ScopedTestingLocalState local_state_; }; TEST_F(ProfileManagerTest, GetProfile) { diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index 6fa5af7..ad0dab2 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -13,6 +13,7 @@ #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" @@ -83,6 +84,7 @@ 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); @@ -298,11 +300,8 @@ 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 = - context->extension_info_map()->extensions().GetByID(extension_id); + extension_info_map_->extensions().GetByID(extension_id); FilePath extension_path; std::string default_locale; if (extension) { @@ -382,10 +381,8 @@ void ChromeRenderMessageFilter::OnExtensionRequestForIOThread( const ExtensionHostMsg_Request_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( - request_context_->GetURLRequestContext()); ExtensionFunctionDispatcher::DispatchOnIOThread( - context->extension_info_map(), profile_, render_process_id_, + extension_info_map_, profile_, render_process_id_, weak_ptr_factory_.GetWeakPtr(), routing_id, params); } @@ -497,22 +494,18 @@ void ChromeRenderMessageFilter::OnGetPluginContentSetting( void ChromeRenderMessageFilter::OnCanTriggerClipboardRead(const GURL& url, bool* allowed) { - ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( - request_context_->GetURLRequestContext()); const Extension* extension = - context->extension_info_map()->extensions().GetByURL(url); + 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 = - context->extension_info_map()->extensions().GetByURL(url); + 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 c5283ef..8aa4cc4 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.h +++ b/chrome/browser/renderer_host/chrome_render_message_filter.h @@ -15,6 +15,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" struct ExtensionHostMsg_Request_Params; +class ExtensionInfoMap; class FilePath; class GURL; class HostContentSettingsMap; @@ -132,6 +133,7 @@ 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/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc index a4b809c..fcd04c3 100644 --- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc +++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc @@ -134,7 +134,8 @@ ResourceHandler* ChromeResourceDispatcherHostDelegate::RequestBeginning( // We check offline first, then check safe browsing so that we still can block // unsafe site after we remove offline page. handler = new OfflineResourceHandler( - handler, child_id, route_id, resource_dispatcher_host_, request); + handler, child_id, route_id, resource_dispatcher_host_, request, + resource_context.appcache_service()); #endif return handler; } diff --git a/chrome/browser/renderer_host/offline_resource_handler.cc b/chrome/browser/renderer_host/offline_resource_handler.cc index 9840917..8c21549 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.cc +++ b/chrome/browser/renderer_host/offline_resource_handler.cc @@ -14,6 +14,7 @@ #include "chrome/browser/chromeos/offline/offline_load_page.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/common/url_constants.h" +#include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" @@ -26,13 +27,16 @@ OfflineResourceHandler::OfflineResourceHandler( int host_id, int route_id, ResourceDispatcherHost* rdh, - net::URLRequest* request) + net::URLRequest* request, + ChromeAppCacheService* appcache_service) : next_handler_(handler), process_host_id_(host_id), render_view_id_(route_id), rdh_(rdh), request_(request), + appcache_service_(appcache_service), deferred_request_id_(-1) { + DCHECK(appcache_service_); } OfflineResourceHandler::~OfflineResourceHandler() { @@ -40,8 +44,8 @@ OfflineResourceHandler::~OfflineResourceHandler() { } bool OfflineResourceHandler::OnUploadProgress(int request_id, - uint64 position, - uint64 size) { + uint64 position, + uint64 size) { return next_handler_->OnUploadProgress(request_id, position, size); } @@ -107,9 +111,7 @@ bool OfflineResourceHandler::OnWillStart(int request_id, appcache_completion_callback_ = new net::CancelableCompletionCallback<OfflineResourceHandler>( this, &OfflineResourceHandler::OnCanHandleOfflineComplete); - const ChromeURLRequestContext* url_request_context = - static_cast<const ChromeURLRequestContext*>(request_->context()); - url_request_context->appcache_service()->CanHandleMainResourceOffline( + appcache_service_->CanHandleMainResourceOffline( url, appcache_completion_callback_); *defer = true; diff --git a/chrome/browser/renderer_host/offline_resource_handler.h b/chrome/browser/renderer_host/offline_resource_handler.h index 4fe61b3..7877536 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.h +++ b/chrome/browser/renderer_host/offline_resource_handler.h @@ -13,6 +13,7 @@ #include "content/browser/renderer_host/resource_handler.h" #include "net/base/completion_callback.h" +class ChromeAppCacheService; class MessageLoop; class ResourceDispatcherHost; @@ -28,7 +29,8 @@ class OfflineResourceHandler : public ResourceHandler, int host_id, int render_view_id, ResourceDispatcherHost* rdh, - net::URLRequest* request); + net::URLRequest* request, + ChromeAppCacheService* appcache_service); virtual ~OfflineResourceHandler(); // ResourceHandler implementation: @@ -71,6 +73,7 @@ class OfflineResourceHandler : public ResourceHandler, int render_view_id_; ResourceDispatcherHost* rdh_; net::URLRequest* request_; + ChromeAppCacheService* const appcache_service_; // The state for deferred load quest. int deferred_request_id_; diff --git a/chrome/browser/ui/webui/chrome_url_data_manager.cc b/chrome/browser/ui/webui/chrome_url_data_manager.cc index 16f8647..43ede09 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager.cc @@ -8,6 +8,7 @@ #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" @@ -31,16 +32,15 @@ ChromeURLDataManager::DataSources* ChromeURLDataManager::data_sources_ = NULL; // Invoked on the IO thread to do the actual adding of the DataSource. static void AddDataSourceOnIOThread( - scoped_refptr<net::URLRequestContextGetter> context_getter, + const base::Callback<ChromeURLDataManagerBackend*(void)>& backend, scoped_refptr<ChromeURLDataManager::DataSource> data_source) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - static_cast<ChromeURLRequestContext*>( - context_getter->GetURLRequestContext())-> - chrome_url_data_manager_backend()->AddDataSource(data_source.get()); + backend.Run()->AddDataSource(data_source.get()); } -ChromeURLDataManager::ChromeURLDataManager(Profile* profile) - : profile_(profile) { +ChromeURLDataManager::ChromeURLDataManager( + const base::Callback<ChromeURLDataManagerBackend*(void)>& backend) + : backend_(backend) { } ChromeURLDataManager::~ChromeURLDataManager() { @@ -51,7 +51,7 @@ void ChromeURLDataManager::AddDataSource(DataSource* source) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableFunction(AddDataSourceOnIOThread, - make_scoped_refptr(profile_->GetRequestContext()), + backend_, 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 9bf894b..7cff56a 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager.h +++ b/chrome/browser/ui/webui/chrome_url_data_manager.h @@ -8,6 +8,7 @@ #include <string> +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/task.h" #include "content/browser/browser_thread.h" @@ -140,7 +141,8 @@ class ChromeURLDataManager { ChromeURLDataManagerBackend* backend_; }; - explicit ChromeURLDataManager(Profile* profile); + explicit ChromeURLDataManager( + const base::Callback<ChromeURLDataManagerBackend*(void)>& backend); ~ChromeURLDataManager(); // Adds a DataSource to the collection of data sources. This *must* be invoked @@ -171,7 +173,10 @@ class ChromeURLDataManager { // was invoked). static bool IsScheduledForDeletion(const DataSource* data_source); - Profile* profile_; + // 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_; // 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 a2344d0..10a0123 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -19,6 +19,7 @@ #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" @@ -227,8 +228,10 @@ bool IsViewAppCacheInternalsURL(const GURL& url) { class ChromeProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - ChromeProtocolHandler(ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service); + ChromeProtocolHandler( + ChromeURLDataManagerBackend* backend, + ChromeAppCacheService* appcache_service, + webkit_blob::BlobStorageController* blob_storage_controller); ~ChromeProtocolHandler(); virtual net::URLRequestJob* MaybeCreateJob( @@ -238,15 +241,18 @@ 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) + ChromeAppCacheService* appcache_service, + webkit_blob::BlobStorageController* blob_storage_controller) : backend_(backend), - appcache_service_(appcache_service) {} + appcache_service_(appcache_service), + blob_storage_controller_(blob_storage_controller) {} ChromeProtocolHandler::~ChromeProtocolHandler() {} @@ -265,7 +271,8 @@ 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); + return ViewBlobInternalsJobFactory::CreateJobForRequest( + request, blob_storage_controller_); // Fall back to using a custom handler return new URLRequestChromeJob(request, backend_); @@ -290,10 +297,13 @@ ChromeURLDataManagerBackend::~ChromeURLDataManagerBackend() { net::URLRequestJobFactory::ProtocolHandler* ChromeURLDataManagerBackend::CreateProtocolHandler( ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service) { + ChromeAppCacheService* appcache_service, + webkit_blob::BlobStorageController* blob_storage_controller) { DCHECK(appcache_service); + DCHECK(blob_storage_controller); DCHECK(backend); - return new ChromeProtocolHandler(backend, appcache_service); + return new ChromeProtocolHandler( + backend, appcache_service, blob_storage_controller); } 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 55ef74a..1f8cd74 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.h +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.h @@ -27,6 +27,9 @@ 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 @@ -42,7 +45,8 @@ class ChromeURLDataManagerBackend { // Invoked to create the protocol handler for chrome://. static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( ChromeURLDataManagerBackend* backend, - ChromeAppCacheService* appcache_service); + ChromeAppCacheService* appcache_service, + webkit_blob::BlobStorageController* blob_storage_controller); // 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 3999c5e..afe8e32 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -4,6 +4,7 @@ #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 2f3b7d3..b2c1c7c 100644 --- a/chrome/browser/ui/webui/options/cookies_view_handler.cc +++ b/chrome/browser/ui/webui/options/cookies_view_handler.cc @@ -14,6 +14,7 @@ #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_browser_process.cc b/chrome/test/testing_browser_process.cc index b3cde66..43188d5 100644 --- a/chrome/test/testing_browser_process.cc +++ b/chrome/test/testing_browser_process.cc @@ -19,7 +19,8 @@ TestingBrowserProcess::TestingBrowserProcess() : module_ref_count_(0), app_locale_("en"), - local_state_(NULL) { + local_state_(NULL), + io_thread_(NULL) { } TestingBrowserProcess::~TestingBrowserProcess() { @@ -38,7 +39,7 @@ MetricsService* TestingBrowserProcess::metrics_service() { } IOThread* TestingBrowserProcess::io_thread() { - return NULL; + return io_thread_; } base::Thread* TestingBrowserProcess::file_thread() { @@ -248,6 +249,10 @@ void TestingBrowserProcess::SetGoogleURLTracker( google_url_tracker_.reset(google_url_tracker); } +void TestingBrowserProcess::SetIOThread(IOThread* io_thread) { + io_thread_ = io_thread; +} + ScopedTestingBrowserProcess::ScopedTestingBrowserProcess() { // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. // ChromeTestSuite sets up a global TestingBrowserProcess diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h index 030fea4..30aac6a 100644 --- a/chrome/test/testing_browser_process.h +++ b/chrome/test/testing_browser_process.h @@ -121,6 +121,7 @@ class TestingBrowserProcess : public BrowserProcess { void SetLocalState(PrefService* local_state); void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker); void SetProfileManager(ProfileManager* profile_manager); + void SetIOThread(IOThread* io_thread); private: NotificationService notification_service_; @@ -136,6 +137,7 @@ class TestingBrowserProcess : public BrowserProcess { scoped_ptr<NotificationUIManager> notification_ui_manager_; scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_; scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; + IOThread* io_thread_; DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); }; diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index dece6f6..8433c50 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -765,7 +765,9 @@ PromoCounter* TestingProfile::GetInstantPromoCounter() { ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { if (!chrome_url_data_manager_.get()) - chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); + chrome_url_data_manager_.reset( + new ChromeURLDataManager( + base::Callback<ChromeURLDataManagerBackend*(void)>())); return chrome_url_data_manager_.get(); } |