summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/appcache/chrome_appcache_service.cc11
-rw-r--r--chrome/common/appcache/chrome_appcache_service.h11
-rw-r--r--chrome/common/notification_type.h6
3 files changed, 27 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_
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index d88b97e..d021059 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -794,6 +794,12 @@ class NotificationType {
// key of the entry that was affected.
AUTOFILL_ENTRIES_CHANGED,
+ // Purge Memory ------------------------------------------------------------
+
+ // Sent on the IO thread when the system should try to reduce the amount of
+ // memory in use, no source or details are passed. See memory_purger.h .cc.
+ PURGE_MEMORY,
+
// Count (must be last) ----------------------------------------------------
// Used to determine the number of notification types. Not valid as
// a type parameter when registering for or posting notifications.