Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: chrome/browser/appcache/chrome_appcache_service.cc

Issue 6077005: Refactored app cache clear on exit code to happen in the object owning the files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved clean up code to ChromeAppCacheService class. Created 9 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/appcache/chrome_appcache_service.cc
diff --git a/chrome/browser/appcache/chrome_appcache_service.cc b/chrome/browser/appcache/chrome_appcache_service.cc
index c01b1d7d36cff67b7171ac9f09885cc7d73dd386..f73bf887c9dda9d66876fbb1d2c7a613284d5d57 100644
--- a/chrome/browser/appcache/chrome_appcache_service.cc
+++ b/chrome/browser/appcache/chrome_appcache_service.cc
@@ -22,7 +22,8 @@ ChromeAppCacheService::ChromeAppCacheService() {
void ChromeAppCacheService::InitializeOnIOThread(
const FilePath& profile_path, bool is_incognito,
- scoped_refptr<HostContentSettingsMap> content_settings_map) {
+ scoped_refptr<HostContentSettingsMap> content_settings_map,
+ bool clear_local_state_on_exit) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!has_initialized_thread_ids) {
@@ -33,16 +34,21 @@ void ChromeAppCacheService::InitializeOnIOThread(
host_contents_settings_map_ = content_settings_map;
registrar_.Add(
this, NotificationType::PURGE_MEMORY, NotificationService::AllSources());
+ clear_local_state_on_exit_ = clear_local_state_on_exit;
+ if (!is_incognito)
+ cache_path_ = profile_path.Append(chrome::kAppCacheDirname);
// Init our base class.
- Initialize(
- is_incognito ? FilePath() : profile_path.Append(chrome::kAppCacheDirname),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
+ Initialize(cache_path_ ,
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
set_appcache_policy(this);
}
ChromeAppCacheService::~ChromeAppCacheService() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ if (clear_local_state_on_exit_ && !cache_path_.empty())
+ file_util::Delete(cache_path_, true);
jochen (gone - plz use gerrit) 2011/01/04 14:32:53 this should happen on the FILE thread
}
void ChromeAppCacheService::SetOriginQuotaInMemory(
@@ -58,11 +64,6 @@ void ChromeAppCacheService::ResetOriginQuotaInMemory(const GURL& origin) {
storage()->ResetOriginQuotaInMemory(origin);
}
-// static
-void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) {
- file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true);
-}
-
bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ContentSetting setting = host_contents_settings_map_->GetContentSetting(

Powered by Google App Engine
This is Rietveld 408576698