Chromium Code Reviews| Index: content/browser/memory/memory_monitor_mac.h |
| diff --git a/content/browser/memory/memory_monitor_mac.h b/content/browser/memory/memory_monitor_mac.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3a6dd225f2640dbe2a8a64c24bf8fbaf057059f0 |
| --- /dev/null |
| +++ b/content/browser/memory/memory_monitor_mac.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// 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_MONITOR_MAC_H_ |
| +#define CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_MAC_H_ |
| + |
| +#include "content/browser/memory/memory_monitor.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +// A memory monitor for the Mac platform. |
| +class CONTENT_EXPORT MemoryMonitorMac : public MemoryMonitor { |
| + public: |
| + MemoryMonitorMac(MemoryMonitorDelegate* delegate, |
| + base::TimeDelta poll_interval); |
| + ~MemoryMonitorMac() override; |
| + |
| + // MemoryMonitor: |
| + int GetFreeMemoryUntilCriticalMB() override; |
| + |
| + // Factory function to create an instance of this class. |
| + static std::unique_ptr<MemoryMonitorMac> Create( |
| + MemoryMonitorDelegate* delegate, |
| + base::TimeDelta poll_interval); |
| + |
| + private: |
| + // The delegate to be used for retrieving system memory information. Used as a |
| + // testing seam. |
| + MemoryMonitorDelegate* delegate_; |
| + |
| + // The poll-interval amount by which |critical_free_mb_| increase. |
| + const int64_t poll_interval_adjustment_mb_; |
| + |
| + // The threshold of free memory that is considered "critical". This value is |
| + // determined dynamically via system "memory pressure" events. |
| + int critical_free_mb_; |
| +}; |
| + |
| +// A delegate with extra methods required to support Mac. |
| +class CONTENT_EXPORT MemoryMonitorMacDelegate : public MemoryMonitorDelegate { |
| + public: |
| + static MemoryMonitorMacDelegate* GetInstance(); |
| + |
| + // Returns system memory-pressure information. |
|
chrisha
2016/11/14 18:14:31
Define what the pressure levels are, and their mea
bcwhite
2016/11/15 23:15:09
Done.
|
| + bool GetSystemMemoryPressure(int* mem_pressure) override; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_MAC_H_ |