| 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..36d7d4d683abee85eadec99d27946dc572c82405
|
| --- /dev/null
|
| +++ b/content/browser/memory/memory_monitor_mac.h
|
| @@ -0,0 +1,56 @@
|
| +// 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. According to dispatch/source.h
|
| + // the returned integer values are:
|
| + // DISPATCH_MEMORYPRESSURE_NORMAL: System has sufficient memory available.
|
| + // DISPATCH_MEMORYPRESSURE_WARN: System memory is getting low.
|
| + // DISPATCH_MEMORYPRESSURE_CRITICAL: System has to swap or kill processes.
|
| + bool GetSystemMemoryPressure(int* mem_pressure) override;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_MAC_H_
|
|
|