Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: content/browser/memory/memory_monitor_mac.h

Issue 2360433002: Memory-monitor for Mac. (Closed)
Patch Set: calculate adjustment based on poll interval; limit calculations to avoid overflow Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a9cf278806e8bf3075c186dce7f4182ea9956ab6
--- /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_;
+};
+
+// An delegate with extra methods required to support Mac.
chrisha 2016/11/09 21:21:11 A* delegate
bcwhite 2016/11/09 22:46:54 Done.
+class CONTENT_EXPORT MemoryMonitorMacDelegate : public MemoryMonitorDelegate {
+ public:
+ static MemoryMonitorMacDelegate* GetInstance();
+
+ // Returns system memory-pressure information.
+ bool GetSystemMemoryPressure(int* mem_pressure) override;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698