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..5313d06b6c9e9c650a17b6d08b081a2098e44d63 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,23 @@ void ChromeAppCacheService::InitializeOnIOThread( |
host_contents_settings_map_ = content_settings_map; |
registrar_.Add( |
this, NotificationType::PURGE_MEMORY, NotificationService::AllSources()); |
+ SetClearLocalStateOnExit(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()) |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableFunction(file_util::Delete, cache_path_, true)); |
michaeln
2011/01/05 00:59:14
I think if this task was posted to the DB thread f
pastarmovj
2011/01/05 10:47:07
After discussing this with Jochen, we decided that
|
} |
void ChromeAppCacheService::SetOriginQuotaInMemory( |
@@ -58,9 +66,9 @@ 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); |
+void ChromeAppCacheService::SetClearLocalStateOnExit(bool clear_local_state) { |
+ AutoLock lock(lock_); |
michaeln
2011/01/05 00:59:14
Instead of a lock, it might be better to post a ta
pastarmovj
2011/01/05 10:47:07
Done.
|
+ clear_local_state_on_exit_ = clear_local_state; |
} |
bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) { |