Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // MemoryPurger provides static APIs to purge as much memory as possible from | 5 // MemoryPurger provides static APIs to purge as much memory as possible from |
| 6 // all processes. These can be hooked to various signals to try and balance | 6 // all processes. These can be hooked to various signals to try and balance |
| 7 // memory consumption, speed, page swapping, etc. | 7 // memory consumption, speed, page swapping, etc. |
| 8 // | 8 // |
| 9 // This was implemented in an attempt to speed up suspend-to-disk by throwing | 9 // This was implemented in an attempt to speed up suspend-to-disk by throwing |
| 10 // away any cached data that can be recomputed. Memory use will rapidly | 10 // away any cached data that can be recomputed. Memory use will rapidly |
| 11 // re-expand after this purge is run. | 11 // re-expand after this purge is run. |
| 12 | 12 |
| 13 #ifndef CHROME_BROWSER_MEMORY_PURGER_H_ | 13 #ifndef CHROME_BROWSER_MEMORY_PURGER_H_ |
| 14 #define CHROME_BROWSER_MEMORY_PURGER_H_ | 14 #define CHROME_BROWSER_MEMORY_PURGER_H_ |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class RenderProcessHost; | 19 class RenderProcessHost; |
| 20 } | 20 } |
| 21 | 21 |
| 22 class MemoryPurger { | 22 class MemoryPurger { |
| 23 public: | 23 public: |
| 24 // Call any of these on the UI thread to purge memory from the named places. | 24 // Call any of these on the UI thread to purge memory from the named places. |
| 25 static void PurgeAll(); | 25 static void PurgeAll(); |
| 26 static void PurgeBrowser(); | 26 static void PurgeBrowser(); |
| 27 static void PurgeRenderers(); | 27 static void PurgeRenderers(); |
| 28 static void PurgeRendererForHost(content::RenderProcessHost* host); | 28 static void PurgeRendererForHost(content::RenderProcessHost* host); |
| 29 | 29 |
| 30 // Call this to register for a MemoryPressure listener, so that PurgeAll() | |
| 31 // is called when the underlying platform send a low memory signal. | |
| 32 static void RegisterMemoryPressureListener(); | |
|
joth
2013/06/05 16:51:23
if this is actually useful it should be in cross-p
bulach
2013/06/05 19:02:11
the registration itself? this file itself is cross
| |
| 33 | |
| 30 private: | 34 private: |
| 31 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryPurger); | 35 DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryPurger); |
| 32 }; | 36 }; |
| 33 | 37 |
| 34 #endif // CHROME_BROWSER_MEMORY_PURGER_H_ | 38 #endif // CHROME_BROWSER_MEMORY_PURGER_H_ |
| OLD | NEW |