summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data_remover.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 08:58:16 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 08:58:16 +0000
commit3d04ea5e909d831ddc40c1e8d89b21f80cbd353c (patch)
tree23ffc3eb4eac8ff73eab2dde50caea7dc947a329 /chrome/browser/browsing_data_remover.cc
parent8de85a60ef3c615360d0c644f7f16f9a13103865 (diff)
downloadchromium_src-3d04ea5e909d831ddc40c1e8d89b21f80cbd353c.zip
chromium_src-3d04ea5e909d831ddc40c1e8d89b21f80cbd353c.tar.gz
chromium_src-3d04ea5e909d831ddc40c1e8d89b21f80cbd353c.tar.bz2
Remove an access to Profile from the IO thread.
Also explicitly hold a reference to the URLRequestContextGetter as long as the task is outstanding on the IO thread. BUG=26893 Review URL: http://codereview.chromium.org/371016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31215 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r--chrome/browser/browsing_data_remover.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 6db8543..0a646fa 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -134,12 +134,23 @@ void BrowsingDataRemover::Remove(int remove_mask) {
// Invoke ClearBrowsingDataView::ClearCache on the IO thread.
waiting_for_clear_cache_ = true;
UserMetrics::RecordAction(L"ClearBrowsingData_Cache", profile_);
+
+ URLRequestContextGetter* main_context_getter =
+ profile_->GetRequestContext();
+ URLRequestContextGetter* media_context_getter =
+ profile_->GetRequestContextForMedia();
+
+ // Balanced in ClearCacheOnIOThread().
+ main_context_getter->AddRef();
+ media_context_getter->AddRef();
+
ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this,
&BrowsingDataRemover::ClearCacheOnIOThread,
- profile_->GetRequestContext(),
+ main_context_getter,
+ media_context_getter,
delete_begin_,
delete_end_));
}
@@ -219,7 +230,8 @@ void BrowsingDataRemover::ClearedCache() {
}
void BrowsingDataRemover::ClearCacheOnIOThread(
- URLRequestContextGetter* context_getter,
+ URLRequestContextGetter* main_context_getter,
+ URLRequestContextGetter* media_context_getter,
base::Time delete_begin,
base::Time delete_end) {
// This function should be called on the IO thread.
@@ -227,7 +239,7 @@ void BrowsingDataRemover::ClearCacheOnIOThread(
// Get a pointer to the cache.
net::HttpTransactionFactory* factory =
- context_getter->GetURLRequestContext()->http_transaction_factory();
+ main_context_getter->GetURLRequestContext()->http_transaction_factory();
disk_cache::Backend* cache = factory->GetCache()->disk_cache();
// |cache| can be null since it is lazily initialized, in this case we do
@@ -240,7 +252,7 @@ void BrowsingDataRemover::ClearCacheOnIOThread(
}
// Get a pointer to the media cache.
- factory = profile_->GetRequestContextForMedia()->GetURLRequestContext()->
+ factory = media_context_getter->GetURLRequestContext()->
http_transaction_factory();
cache = factory->GetCache()->disk_cache();
@@ -253,6 +265,10 @@ void BrowsingDataRemover::ClearCacheOnIOThread(
cache->DoomEntriesBetween(delete_begin, delete_end);
}
+ // Balance the AddRef()s done on the UI thread by Remove().
+ main_context_getter->Release();
+ media_context_getter->Release();
+
// Notify the UI thread that we are done.
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,