| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/memory/memory_message_filter.h" | 5 #include "content/browser/memory/memory_message_filter.h" |
| 6 | 6 |
| 7 #include "content/browser/memory/memory_pressure_controller_impl.h" | 7 #include "content/browser/memory/memory_pressure_controller_impl.h" |
| 8 #include "content/common/memory_messages.h" | 8 #include "content/common/memory_messages.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 MemoryMessageFilter::MemoryMessageFilter( | 12 MemoryMessageFilter::MemoryMessageFilter( |
| 13 const BrowserChildProcessHost* child_process_host, | 13 const BrowserChildProcessHost* child_process_host, |
| 14 ProcessType process_type) | 14 ProcessType process_type) |
| 15 : BrowserMessageFilter(MemoryMsgStart), | 15 : BrowserMessageFilter(MemoryMsgStart), |
| 16 process_host_(child_process_host), | 16 process_host_(child_process_host), |
| 17 process_type_(process_type) { | 17 process_type_(process_type) { |
| 18 DCHECK_NE(process_type_, PROCESS_TYPE_RENDERER); | 18 DCHECK_NE(process_type_, PROCESS_TYPE_RENDERER); |
| 19 } | 19 } |
| 20 | 20 |
| 21 MemoryMessageFilter::MemoryMessageFilter( | 21 MemoryMessageFilter::MemoryMessageFilter( |
| 22 const RenderProcessHost* render_process_host) | 22 const RenderProcessHost* render_process_host) |
| 23 : BrowserMessageFilter(MemoryMsgStart), | 23 : BrowserMessageFilter(MemoryMsgStart), |
| 24 process_host_(render_process_host), | 24 process_host_(render_process_host), |
| 25 process_type_(PROCESS_TYPE_RENDERER) {} | 25 process_type_(PROCESS_TYPE_RENDERER) {} |
| 26 | 26 |
| 27 MemoryMessageFilter::~MemoryMessageFilter() {} | 27 MemoryMessageFilter::~MemoryMessageFilter() {} |
| 28 | 28 |
| 29 void MemoryMessageFilter::OnFilterAdded(IPC::Sender* sender) { | 29 void MemoryMessageFilter::OnFilterAdded(IPC::Channel* channel) { |
| 30 MemoryPressureControllerImpl::GetInstance()->OnMemoryMessageFilterAdded(this); | 30 MemoryPressureControllerImpl::GetInstance()->OnMemoryMessageFilterAdded(this); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void MemoryMessageFilter::OnChannelClosing() { | 33 void MemoryMessageFilter::OnChannelClosing() { |
| 34 MemoryPressureControllerImpl::GetInstance() | 34 MemoryPressureControllerImpl::GetInstance() |
| 35 ->OnMemoryMessageFilterRemoved(this); | 35 ->OnMemoryMessageFilterRemoved(this); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool MemoryMessageFilter::OnMessageReceived(const IPC::Message& message) { | 38 bool MemoryMessageFilter::OnMessageReceived(const IPC::Message& message) { |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void MemoryMessageFilter::SendSetPressureNotificationsSuppressed( | 42 void MemoryMessageFilter::SendSetPressureNotificationsSuppressed( |
| 43 bool suppressed) { | 43 bool suppressed) { |
| 44 Send(new MemoryMsg_SetPressureNotificationsSuppressed(suppressed)); | 44 Send(new MemoryMsg_SetPressureNotificationsSuppressed(suppressed)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void MemoryMessageFilter::SendSimulatePressureNotification( | 47 void MemoryMessageFilter::SendSimulatePressureNotification( |
| 48 base::MemoryPressureListener::MemoryPressureLevel level) { | 48 base::MemoryPressureListener::MemoryPressureLevel level) { |
| 49 Send(new MemoryMsg_SimulatePressureNotification(level)); | 49 Send(new MemoryMsg_SimulatePressureNotification(level)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void MemoryMessageFilter::SendPressureNotification( | 52 void MemoryMessageFilter::SendPressureNotification( |
| 53 base::MemoryPressureListener::MemoryPressureLevel level) { | 53 base::MemoryPressureListener::MemoryPressureLevel level) { |
| 54 Send(new MemoryMsg_PressureNotification(level)); | 54 Send(new MemoryMsg_PressureNotification(level)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace content | 57 } // namespace content |
| OLD | NEW |