summaryrefslogtreecommitdiff
path: root/chromium/content/browser/memory/memory_message_filter.cc
blob: 110f8396aaef66833cdb05c640879fdb7811bd1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 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/browser/memory/memory_message_filter.h"

#include "content/browser/memory/memory_pressure_controller.h"
#include "content/common/memory_messages.h"

namespace content {

MemoryMessageFilter::MemoryMessageFilter(
    const BrowserChildProcessHost* child_process_host,
    ProcessType process_type)
    : BrowserMessageFilter(MemoryMsgStart),
      process_host_(child_process_host),
      process_type_(process_type) {
  DCHECK_NE(process_type_, PROCESS_TYPE_RENDERER);
}

MemoryMessageFilter::MemoryMessageFilter(
    const RenderProcessHost* render_process_host)
    : BrowserMessageFilter(MemoryMsgStart),
      process_host_(render_process_host),
      process_type_(PROCESS_TYPE_RENDERER) {}

MemoryMessageFilter::~MemoryMessageFilter() {}

void MemoryMessageFilter::OnFilterAdded(IPC::Sender* sender) {
  MemoryPressureController::GetInstance()->OnMemoryMessageFilterAdded(this);
}

void MemoryMessageFilter::OnChannelClosing() {
  MemoryPressureController::GetInstance()->OnMemoryMessageFilterRemoved(this);
}

bool MemoryMessageFilter::OnMessageReceived(const IPC::Message& message) {
  return false;
}

void MemoryMessageFilter::SendSetPressureNotificationsSuppressed(
    bool suppressed) {
  Send(new MemoryMsg_SetPressureNotificationsSuppressed(suppressed));
}

void MemoryMessageFilter::SendSimulatePressureNotification(
    base::MemoryPressureListener::MemoryPressureLevel level) {
  Send(new MemoryMsg_SimulatePressureNotification(level));
}

void MemoryMessageFilter::SendPressureNotification(
    base::MemoryPressureListener::MemoryPressureLevel level) {
  Send(new MemoryMsg_PressureNotification(level));
}

}  // namespace content