| Index: content/child/memory/child_memory_message_filter.cc
|
| diff --git a/content/child/memory/child_memory_message_filter.cc b/content/child/memory/child_memory_message_filter.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2cbe5d4b9e72d9545bc0efe7b73edbc750563b55
|
| --- /dev/null
|
| +++ b/content/child/memory/child_memory_message_filter.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/child/memory/child_memory_message_filter.h"
|
| +
|
| +#include "base/memory/memory_pressure_listener.h"
|
| +#include "content/common/memory_messages.h"
|
| +#include "ipc/ipc_channel.h"
|
| +
|
| +namespace content {
|
| +namespace memory {
|
| +
|
| +ChildMemoryMessageFilter::ChildMemoryMessageFilter() : sender_(nullptr) {}
|
| +
|
| +ChildMemoryMessageFilter::~ChildMemoryMessageFilter() {}
|
| +
|
| +void ChildMemoryMessageFilter::OnFilterAdded(IPC::Sender* sender) {
|
| + DCHECK(sender_ == nullptr);
|
| + sender_ = sender;
|
| +}
|
| +
|
| +void ChildMemoryMessageFilter::OnFilterRemoved() {
|
| + DCHECK(sender_ != nullptr);
|
| + sender_ = nullptr;
|
| +}
|
| +
|
| +bool ChildMemoryMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(ChildMemoryMessageFilter, message)
|
| + IPC_MESSAGE_HANDLER(MemoryMsg_SetPressureNotificationsSuppressed,
|
| + OnSetPressureNotificationsSuppressed)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| + return handled;
|
| +}
|
| +
|
| +void ChildMemoryMessageFilter::OnSetPressureNotificationsSuppressed(
|
| + bool suppressed) {
|
| + // Enable/disable suppressing memory notifications in the child process.
|
| + base::MemoryPressureListener::SetNotificationsSuppressed(suppressed);
|
| + sender_->Send(new MemoryHostMsg_SetPressureNotificationsSuppressedAck);
|
| +}
|
| +
|
| +} // namespace memory
|
| +} // namespace content
|
|
|