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

Side by Side Diff: content/child/memory/child_memory_message_filter.cc

Issue 2882513004: Remove renderer notifications of memory pressure. (Closed)
Patch Set: Merge Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « content/child/memory/child_memory_message_filter.h ('k') | content/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/child/memory/child_memory_message_filter.h"
6
7 #include "content/common/memory_messages.h"
8
9 namespace content {
10
11 ChildMemoryMessageFilter::ChildMemoryMessageFilter() {}
12
13 ChildMemoryMessageFilter::~ChildMemoryMessageFilter() {}
14
15 bool ChildMemoryMessageFilter::OnMessageReceived(const IPC::Message& message) {
16 bool handled = true;
17 IPC_BEGIN_MESSAGE_MAP(ChildMemoryMessageFilter, message)
18 IPC_MESSAGE_HANDLER(MemoryMsg_SetPressureNotificationsSuppressed,
19 OnSetPressureNotificationsSuppressed)
20 IPC_MESSAGE_HANDLER(MemoryMsg_SimulatePressureNotification,
21 OnSimulatePressureNotification)
22 IPC_MESSAGE_HANDLER(MemoryMsg_PressureNotification, OnPressureNotification)
23 IPC_MESSAGE_UNHANDLED(handled = false)
24 IPC_END_MESSAGE_MAP()
25 return handled;
26 }
27
28 void ChildMemoryMessageFilter::OnSetPressureNotificationsSuppressed(
29 bool suppressed) {
30 // Enable/disable suppressing memory notifications in the child process.
31 base::MemoryPressureListener::SetNotificationsSuppressed(suppressed);
32 }
33
34 void ChildMemoryMessageFilter::OnSimulatePressureNotification(
35 base::MemoryPressureListener::MemoryPressureLevel level) {
36 // Pass the message to SimulatePressureNotification. This will emit the
37 // message to all listeners even if notifications are suppressed.
38 base::MemoryPressureListener::SimulatePressureNotification(level);
39 }
40
41 void ChildMemoryMessageFilter::OnPressureNotification(
42 base::MemoryPressureListener::MemoryPressureLevel level) {
43 // Forward the message along the normal notification path. If notifications
44 // are suppressed then the notification will be swallowed.
45 base::MemoryPressureListener::NotifyMemoryPressure(level);
46 }
47
48 } // namespace content
OLDNEW
« no previous file with comments | « content/child/memory/child_memory_message_filter.h ('k') | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698