Chromium Code Reviews| Index: content/browser/memory/memory_pressure_controller_impl.h |
| diff --git a/content/browser/memory/memory_pressure_controller.h b/content/browser/memory/memory_pressure_controller_impl.h |
| similarity index 52% |
| rename from content/browser/memory/memory_pressure_controller.h |
| rename to content/browser/memory/memory_pressure_controller_impl.h |
| index f81540957d7b416f1b268e7e63280b14268ceb31..3a66c683fb93f3b142655d9b84e77e239700fd00 100644 |
| --- a/content/browser/memory/memory_pressure_controller.h |
| +++ b/content/browser/memory/memory_pressure_controller_impl.h |
| @@ -2,8 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ |
| -#define CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ |
| +#ifndef CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_IMPL_H_ |
| +#define CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_IMPL_H_ |
| #include <map> |
| @@ -19,33 +19,55 @@ class BrowserChildProcessHost; |
| class MemoryMessageFilter; |
| class RenderProcessHost; |
| -class CONTENT_EXPORT MemoryPressureController { |
| +// Controller for memory pressure IPC messages. Each child process owns and |
| +// registers a MemoryMessageFilter, which can be used to both suppress and |
| +// simulate memory pressure messages across processes. This controller |
| +// coordinates suppressing and simulation of messages, as well as allows for |
| +// messages to be forward to individual processes. This allows the browser |
|
Charlie Reis
2016/01/29 19:46:56
nit: forwarded
chrisha
2016/01/29 21:12:12
Done.
|
| +// process to control what memory pressure messages are seen in child processes. |
| +// For more details see content/browser/memory/memory_message_filter.h and |
| +// content/child/memory/child_memory_message_filter.h. |
| +class CONTENT_EXPORT MemoryPressureControllerImpl { |
|
Charlie Reis
2016/01/29 19:46:56
It'd be more common to have this derive from Memor
chrisha
2016/01/29 21:12:12
Yeah... I wasn't 100% sure whether or not this was
|
| public: |
| // These methods must be called on the IO thread. |
| void OnMemoryMessageFilterAdded(MemoryMessageFilter* filter); |
| void OnMemoryMessageFilterRemoved(MemoryMessageFilter* filter); |
| // These methods can be called from any thread. |
| + |
| + // Suppresses all memory pressure messages from passing through all attached |
| + // MemoryMessageFilters. Any messages sent through a "suppressed" filter will |
| + // be ignored on the receiving end. |
| void SetPressureNotificationsSuppressedInAllProcesses(bool suppressed); |
| + |
| + // Simulates memory pressure in all processes by invoking |
| + // SimulatePressureNotification on all attached MemoryMessageFilters. These |
| + // messages will be received even if suppression is enabled. |
| void SimulatePressureNotificationInAllProcesses( |
| base::MemoryPressureListener::MemoryPressureLevel level); |
| + |
| + // Sends a memory pressure notification to the specified browser child process |
| + // via its attached MemoryMessageFilter. |
| void SendPressureNotification( |
| const BrowserChildProcessHost* child_process_host, |
| base::MemoryPressureListener::MemoryPressureLevel level); |
| + |
| + // Sends a memory pressure notification to the specified renderer process via |
| + // its attached MemoryMessageFilter. |
| void SendPressureNotification( |
| const RenderProcessHost* render_process_host, |
| base::MemoryPressureListener::MemoryPressureLevel level); |
| // This method can be called from any thread. |
| - static MemoryPressureController* GetInstance(); |
| + static MemoryPressureControllerImpl* GetInstance(); |
|
Charlie Reis
2016/01/29 19:46:56
nit: Move this to be the first public method.
chrisha
2016/01/29 21:12:12
Done.
|
| protected: |
| - virtual ~MemoryPressureController(); |
| + virtual ~MemoryPressureControllerImpl(); |
| private: |
| - friend struct base::DefaultSingletonTraits<MemoryPressureController>; |
| + friend struct base::DefaultSingletonTraits<MemoryPressureControllerImpl>; |
| - MemoryPressureController(); |
| + MemoryPressureControllerImpl(); |
| // Implementation of the various SendPressureNotification methods. |
| void SendPressureNotificationImpl( |
| @@ -58,9 +80,9 @@ class CONTENT_EXPORT MemoryPressureController { |
| MemoryMessageFilterMap; |
| MemoryMessageFilterMap memory_message_filters_; |
| - DISALLOW_COPY_AND_ASSIGN(MemoryPressureController); |
| + DISALLOW_COPY_AND_ASSIGN(MemoryPressureControllerImpl); |
| }; |
| } // namespace content |
| -#endif // CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ |
| +#endif // CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_IMPL_H_ |