| 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 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_MESSAGE_FILTER_H_ | |
| 6 #define CONTENT_BROWSER_MEMORY_MEMORY_MESSAGE_FILTER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/memory_pressure_listener.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "content/public/browser/browser_message_filter.h" | |
| 12 #include "content/public/common/process_type.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class BrowserChildProcessHost; | |
| 17 class RenderProcessHost; | |
| 18 | |
| 19 // This class sends memory messages from the browser process. | |
| 20 // See also: child_memory_message_filter.h | |
| 21 class CONTENT_EXPORT MemoryMessageFilter : public BrowserMessageFilter { | |
| 22 public: | |
| 23 MemoryMessageFilter(const BrowserChildProcessHost* child_process_host, | |
| 24 ProcessType process_type); | |
| 25 MemoryMessageFilter(const RenderProcessHost* render_process_host); | |
| 26 | |
| 27 // BrowserMessageFilter implementation. | |
| 28 void OnFilterAdded(IPC::Channel* channel) override; | |
| 29 void OnChannelClosing() override; | |
| 30 bool OnMessageReceived(const IPC::Message& message) override; | |
| 31 | |
| 32 void SendSetPressureNotificationsSuppressed(bool suppressed); | |
| 33 void SendSimulatePressureNotification( | |
| 34 base::MemoryPressureListener::MemoryPressureLevel level); | |
| 35 void SendPressureNotification( | |
| 36 base::MemoryPressureListener::MemoryPressureLevel level); | |
| 37 | |
| 38 protected: | |
| 39 friend class MemoryPressureControllerImpl; | |
| 40 | |
| 41 ~MemoryMessageFilter() override; | |
| 42 | |
| 43 const void* process_host() const { return process_host_; } | |
| 44 ProcessType process_type() const { return process_type_; } | |
| 45 | |
| 46 private: | |
| 47 // The untyped process host and ProcessType associated with this filter | |
| 48 // instance. The process host is stored as untyped because it is only used as | |
| 49 // a key in MemoryPressureControllerImpl; at no point is it ever deferenced to | |
| 50 // invoke any members on a process host. | |
| 51 const void* process_host_; | |
| 52 ProcessType process_type_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(MemoryMessageFilter); | |
| 55 }; | |
| 56 | |
| 57 } // namespace content | |
| 58 | |
| 59 #endif // CONTENT_BROWSER_MEMORY_MEMORY_MESSAGE_FILTER_H_ | |
| OLD | NEW |