| OLD | NEW |
| (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 | |
| OLD | NEW |