summaryrefslogtreecommitdiffstats
path: root/chrome/common/appcache
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 22:14:46 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 22:14:46 +0000
commit520cdd71da6f80dfffdd384645792de9a61abc94 (patch)
tree9c299ddab2d1bc22f0cceb9a361cd5b00952d08a /chrome/common/appcache
parentc4a9b44a974e39f23100e9ef1e122648b84470e3 (diff)
downloadchromium_src-520cdd71da6f80dfffdd384645792de9a61abc94.zip
chromium_src-520cdd71da6f80dfffdd384645792de9a61abc94.tar.gz
chromium_src-520cdd71da6f80dfffdd384645792de9a61abc94.tar.bz2
Introduce a notification to trigger memory purging on the IO thread and use it in ChromeAppCacheService.
TEST=manual BUG=none Review URL: http://codereview.chromium.org/547016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/appcache')
-rw-r--r--chrome/common/appcache/chrome_appcache_service.cc11
-rw-r--r--chrome/common/appcache/chrome_appcache_service.h11
2 files changed, 21 insertions, 1 deletions
diff --git a/chrome/common/appcache/chrome_appcache_service.cc b/chrome/common/appcache/chrome_appcache_service.cc
index c1016cb..cb1f7a3 100644
--- a/chrome/common/appcache/chrome_appcache_service.cc
+++ b/chrome/common/appcache/chrome_appcache_service.cc
@@ -7,6 +7,7 @@
#include "base/file_path.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/notification_service.h"
#include "webkit/appcache/appcache_thread.h"
static bool has_initialized_thread_ids;
@@ -20,12 +21,22 @@ ChromeAppCacheService::ChromeAppCacheService(const FilePath& data_directory,
}
Initialize(is_incognito ? FilePath()
: data_directory.Append(chrome::kAppCacheDirname));
+
+ registrar_.Add(
+ this, NotificationType::PURGE_MEMORY, NotificationService::AllSources());
}
ChromeAppCacheService::~ChromeAppCacheService() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
}
+void ChromeAppCacheService::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type == NotificationType::PURGE_MEMORY);
+ PurgeMemory();
+}
+
static ChromeThread::ID ToChromeThreadID(int id) {
DCHECK(has_initialized_thread_ids);
DCHECK(id == ChromeThread::DB || id == ChromeThread::IO);
diff --git a/chrome/common/appcache/chrome_appcache_service.h b/chrome/common/appcache/chrome_appcache_service.h
index 509afd2..a202601 100644
--- a/chrome/common/appcache/chrome_appcache_service.h
+++ b/chrome/common/appcache/chrome_appcache_service.h
@@ -6,6 +6,7 @@
#define CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_
#include "base/ref_counted.h"
+#include "chrome/common/notification_registrar.h"
#include "webkit/appcache/appcache_service.h"
class FilePath;
@@ -20,13 +21,21 @@ class FilePath;
// the IO thread.
class ChromeAppCacheService
: public base::RefCounted<ChromeAppCacheService>,
- public appcache::AppCacheService {
+ public appcache::AppCacheService,
+ public NotificationObserver {
public:
ChromeAppCacheService(const FilePath& data_directory,
bool is_incognito);
private:
friend class base::RefCounted<ChromeAppCacheService>;
virtual ~ChromeAppCacheService();
+
+ // NotificationObserver override
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ NotificationRegistrar registrar_;
};
#endif // CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_