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/browser/memory/memory_message_filter.h" | |
6 | |
7 #include "content/browser/memory/memory_pressure_controller_impl.h" | |
8 #include "content/common/memory_messages.h" | |
9 | |
10 namespace content { | |
11 | |
12 MemoryMessageFilter::MemoryMessageFilter( | |
13 const BrowserChildProcessHost* child_process_host, | |
14 ProcessType process_type) | |
15 : BrowserMessageFilter(MemoryMsgStart), | |
16 process_host_(child_process_host), | |
17 process_type_(process_type) { | |
18 DCHECK_NE(process_type_, PROCESS_TYPE_RENDERER); | |
19 } | |
20 | |
21 MemoryMessageFilter::MemoryMessageFilter( | |
22 const RenderProcessHost* render_process_host) | |
23 : BrowserMessageFilter(MemoryMsgStart), | |
24 process_host_(render_process_host), | |
25 process_type_(PROCESS_TYPE_RENDERER) {} | |
26 | |
27 MemoryMessageFilter::~MemoryMessageFilter() {} | |
28 | |
29 void MemoryMessageFilter::OnFilterAdded(IPC::Channel* channel) { | |
30 MemoryPressureControllerImpl::GetInstance()->OnMemoryMessageFilterAdded(this); | |
31 } | |
32 | |
33 void MemoryMessageFilter::OnChannelClosing() { | |
34 MemoryPressureControllerImpl::GetInstance() | |
35 ->OnMemoryMessageFilterRemoved(this); | |
36 } | |
37 | |
38 bool MemoryMessageFilter::OnMessageReceived(const IPC::Message& message) { | |
39 return false; | |
40 } | |
41 | |
42 void MemoryMessageFilter::SendSetPressureNotificationsSuppressed( | |
43 bool suppressed) { | |
44 Send(new MemoryMsg_SetPressureNotificationsSuppressed(suppressed)); | |
45 } | |
46 | |
47 void MemoryMessageFilter::SendSimulatePressureNotification( | |
48 base::MemoryPressureListener::MemoryPressureLevel level) { | |
49 Send(new MemoryMsg_SimulatePressureNotification(level)); | |
50 } | |
51 | |
52 void MemoryMessageFilter::SendPressureNotification( | |
53 base::MemoryPressureListener::MemoryPressureLevel level) { | |
54 Send(new MemoryMsg_PressureNotification(level)); | |
55 } | |
56 | |
57 } // namespace content | |
OLD | NEW |