Index: content/browser/memory/memory_pressure_controller.cc |
diff --git a/content/browser/memory/memory_pressure_controller.cc b/content/browser/memory/memory_pressure_controller.cc |
index 41738e5206a8e26f2629d131dda05d3bdd63f492..a93302c312d2819d3bd038b8dda7ac3232256f0a 100644 |
--- a/content/browser/memory/memory_pressure_controller.cc |
+++ b/content/browser/memory/memory_pressure_controller.cc |
@@ -5,7 +5,6 @@ |
#include "content/browser/memory/memory_pressure_controller.h" |
#include "base/bind.h" |
-#include "base/memory/memory_pressure_listener.h" |
#include "content/browser/memory/memory_message_filter.h" |
#include "content/public/browser/browser_thread.h" |
@@ -70,4 +69,29 @@ void MemoryPressureController::SetPressureNotificationsSuppressedInAllProcesses( |
} |
} |
+void MemoryPressureController::SimulatePressureNotificationInAllProcesses( |
+ MemoryPressureLevel level) { |
+ DCHECK_NE(level, MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_NONE); |
+ |
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
+ // Note that passing base::Unretained(this) is safe here because the |
+ // controller is a leaky singleton (i.e. it is never deleted). |
Primiano Tucci (use gerrit)
2015/09/28 12:47:31
the i.e. part in parenthesis is really superfluos
petrcermak
2015/09/28 15:39:32
Done (removed in both methods).
|
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&MemoryPressureController:: |
+ SimulatePressureNotificationInAllProcesses, |
+ base::Unretained(this), level)); |
+ return; |
+ } |
+ |
+ // Simulate memory pressure notification in the browser process. |
+ base::MemoryPressureListener::SimulatePressureNotification(level); |
+ |
+ // Simulate memory pressure notification in all child processes. |
+ for (MemoryMessageFilterSet::iterator it = memory_message_filters_.begin(); |
Primiano Tucci (use gerrit)
2015/09/28 12:47:31
you could use a one-line C++11 style foreach here
petrcermak
2015/09/28 15:39:32
Done (in both methods).
|
+ it != memory_message_filters_.end(); ++it) { |
+ it->get()->SendSimulatePressureNotification(level); |
Primiano Tucci (use gerrit)
2015/09/28 12:47:32
..and that will avoid you to use the ->get()
What
petrcermak
2015/09/28 15:39:32
Done.
|
+ } |
+} |
+ |
} // namespace content |