summaryrefslogtreecommitdiffstats
path: root/chrome/browser/memory_purger.h
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 18:50:19 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 18:50:19 +0000
commit0dd5dda0318cfbe06bc73f4a24a5e6b6b8e3fc30 (patch)
tree8bff32973fdd833232139ad6ac4bec54137b12a8 /chrome/browser/memory_purger.h
parent83e214c531938502ad094e440f2dfd9a48fb007a (diff)
downloadchromium_src-0dd5dda0318cfbe06bc73f4a24a5e6b6b8e3fc30.zip
chromium_src-0dd5dda0318cfbe06bc73f4a24a5e6b6b8e3fc30.tar.gz
chromium_src-0dd5dda0318cfbe06bc73f4a24a5e6b6b8e3fc30.tar.bz2
Add framework of MemoryPurger, a class to dump memory from everywhere possible. Currently does nothing.
This also adds a "Purge memory" button to the task manager when run with --purge-memory-button, which can be used to test the functionality. BUG=23400 TEST=Run with --purge-memory-button, open the task manager and see a new button. Click it to toggle it to "Reset purge", and click again to toggle back. Review URL: http://codereview.chromium.org/259003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/memory_purger.h')
-rw-r--r--chrome/browser/memory_purger.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/memory_purger.h b/chrome/browser/memory_purger.h
new file mode 100644
index 0000000..1403add
--- /dev/null
+++ b/chrome/browser/memory_purger.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// MemoryPurger is designed to be used a singleton which listens for
+// suspend/resume notifications and purges as much memory as possible before
+// suspend. The hope is that it will be faster to recalculate or manually
+// reload this data on resume than to let the OS page everything out and then
+// fault it back in.
+
+#ifndef CHROME_BROWSER_MEMORY_PURGER_H_
+#define CHROME_BROWSER_MEMORY_PURGER_H_
+
+#include "base/system_monitor.h"
+
+template<typename Type>
+struct DefaultSingletonTraits;
+
+class MemoryPurger : public base::SystemMonitor::PowerObserver {
+public:
+ static MemoryPurger* GetSingleton();
+
+ // PowerObserver
+ virtual void OnSuspend();
+ virtual void OnResume();
+
+ private:
+ MemoryPurger();
+ virtual ~MemoryPurger();
+
+ friend struct DefaultSingletonTraits<MemoryPurger>;
+
+ DISALLOW_COPY_AND_ASSIGN(MemoryPurger);
+};
+
+#endif // CHROME_BROWSER_MEMORY_PURGER_H_