Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9886)

Unified Diff: chrome/renderer/chrome_render_process_observer.cc

Issue 7222023: Forward handling of low-mem message to the content renderer client. Add APIs to handle this case. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix constructor Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/chrome_render_process_observer.cc
diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc
index bf65d8633de5ea67572e5ce20ac189d23c237fe3..d31884aa8583fbcd005dfea2fb15d3006d8f32b9 100644
--- a/chrome/renderer/chrome_render_process_observer.cc
+++ b/chrome/renderer/chrome_render_process_observer.cc
@@ -19,6 +19,7 @@
#include "chrome/common/render_messages.h"
#include "chrome/renderer/content_settings_observer.h"
#include "chrome/renderer/security_filter_peer.h"
+#include "content/common/notification_source.h"
#include "content/common/resource_dispatcher.h"
#include "content/common/resource_dispatcher_delegate.h"
#include "content/common/view_messages.h"
@@ -391,6 +392,8 @@ ChromeRenderProcessObserver::ChromeRenderProcessObserver() {
PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path);
if (!media_path.empty())
media::InitializeMediaLibrary(media_path);
+
+ registrar_.Add(this, content::NOTIFICATION_PURGE_MEMORY, Source<void>(NULL));
}
ChromeRenderProcessObserver::~ChromeRenderProcessObserver() {
@@ -413,7 +416,6 @@ bool ChromeRenderProcessObserver::OnControlMessageReceived(
#endif
IPC_MESSAGE_HANDLER(ViewMsg_GetV8HeapStats, OnGetV8HeapStats)
IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats)
- IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -481,7 +483,15 @@ void ChromeRenderProcessObserver::OnGetV8HeapStats() {
heap_stats.used_heap_size()));
}
+void ChromeRenderProcessObserver::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == content::NOTIFICATION_PURGE_MEMORY)
+ OnPurgeMemory();
+}
+
void ChromeRenderProcessObserver::OnPurgeMemory() {
+ LOG(INFO) << "CRPO purging memory!";
// Clear the object cache (as much as possible; some live objects cannot be
// freed).
WebCache::clear();

Powered by Google App Engine
This is Rietveld 408576698