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_PRESSURE_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/callback.h" |
| 11 |
| 12 namespace content { |
| 13 namespace memory { |
| 14 |
| 15 class MemoryMessageFilter; |
| 16 |
| 17 using MemoryMessageCallback = base::Callback<void(bool success)>; |
| 18 |
| 19 class MemoryPressureController { |
| 20 public: |
| 21 MemoryPressureController(); |
| 22 |
| 23 void OnMemoryMessageFilterAdded(MemoryMessageFilter* filter); |
| 24 void OnMemoryMessageFilterRemoved(MemoryMessageFilter* filter); |
| 25 |
| 26 void SetPressureNotificationsSuppressedInAllProcesses( |
| 27 bool suppressed, |
| 28 const MemoryMessageCallback& callback); |
| 29 void OnSetPressureNotificationsSuppressedResponse( |
| 30 MemoryMessageFilter* filter); |
| 31 |
| 32 static MemoryPressureController* GetInstance(); |
| 33 |
| 34 protected: |
| 35 virtual ~MemoryPressureController(); |
| 36 |
| 37 private: |
| 38 // Set of all memory message filters in the browser process. Always accessed |
| 39 // on the UI thread. |
| 40 typedef std::set<scoped_refptr<MemoryMessageFilter>> MemoryMessageFilterSet; |
| 41 MemoryMessageFilterSet memory_message_filters_; |
| 42 |
| 43 // Pending acks for SetPressureNotificationsSuppressedInAllProcesses. |
| 44 MemoryMessageFilterSet pending_set_pressure_notifications_suppressed_filters_; |
| 45 MemoryMessageCallback pending_set_pressure_notifications_suppressed_callback_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(MemoryPressureController); |
| 48 }; |
| 49 |
| 50 } // namespace memory |
| 51 } // namespace content |
| 52 |
| 53 #endif // CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ |
OLD | NEW |