summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-15 14:34:50 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-15 14:34:50 +0000
commit92a4769c7cff24906ffa52fb3ee5e37753889a96 (patch)
treebb3ebe27a853bb3fdca8ab1e391298f89ba4d155 /chrome/browser/profiles
parent27861447e9b9f359cf893065ef07186589791333 (diff)
downloadchromium_src-92a4769c7cff24906ffa52fb3ee5e37753889a96.zip
chromium_src-92a4769c7cff24906ffa52fb3ee5e37753889a96.tar.gz
chromium_src-92a4769c7cff24906ffa52fb3ee5e37753889a96.tar.bz2
Remove more unnecessary ChromeURLRequestContext members.
ProfileIOData is now always deleted on the IO thread. Replaces a use of ChromeURLRequestContextGetter with a ChromeURLDataManagerBackend getter callback. Also gets rid of ExtensionInfoMap from ChromeURLRequestContext by directly passing it into the places that need it. Gets rid of the HTML5 storage objects from ChromeURLRequestContext too. Adds a workaround for TranslateManager's Profile::GetDefaultRequestContext() use, since after this refactoring (by not requiring ChromeURLRequestContextGetter for ChromeURLDataManagerBackend), it prevents having to initialize the ChromeURLRequestContextGetter in most tests since they don't actually use it. This means |default_request_context_| doesn't always get initialized in BrowserMain(), which causes TranslateManager to crash on startup since it requires |default_request_context_| to be initialized. So we forcibly initialize |default_request_context_| until TranslateManager stops depending on this. BUG=89396 TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=92668 Review URL: http://codereview.chromium.org/7282054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r--chrome/browser/profiles/off_the_record_profile_io_data.cc14
-rw-r--r--chrome/browser/profiles/off_the_record_profile_io_data.h5
-rw-r--r--chrome/browser/profiles/profile.cc5
-rw-r--r--chrome/browser/profiles/profile_impl.cc3
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc12
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.h5
-rw-r--r--chrome/browser/profiles/profile_io_data.cc38
-rw-r--r--chrome/browser/profiles/profile_io_data.h6
-rw-r--r--chrome/browser/profiles/profile_manager_unittest.cc3
9 files changed, 66 insertions, 25 deletions
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 f9d095e..174e3a3 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"
@@ -679,7 +681,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 0cbc653..75fc4e0 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -1518,7 +1518,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..b8c4203 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,14 +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
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
// static
@@ -342,6 +340,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 +397,6 @@ ProfileIOData::GetIsolatedAppRequestContext(
return context;
}
-const content::ResourceContext& ProfileIOData::GetResourceContext() const {
- return resource_context_;
-}
-
ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const {
return extension_info_map_;
}
@@ -469,7 +473,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 +540,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 +547,7 @@ 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 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 ee8831f..71cf4dd 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -37,6 +37,7 @@ 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)
@@ -52,6 +53,7 @@ class ProfileManagerTest : public TestingBrowserProcessTest {
virtual void TearDown() {
profile_manager_.reset();
+ message_loop_.RunAllPending();
}
class MockObserver : public ProfileManagerObserver {
@@ -65,6 +67,7 @@ class ProfileManagerTest : public TestingBrowserProcessTest {
MessageLoopForUI message_loop_;
BrowserThread ui_thread_;
BrowserThread file_thread_;
+ BrowserThread io_thread_;
scoped_ptr<base::SystemMonitor> system_monitor_dummy_;