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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 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_MONITOR_MAC_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_MAC_H_
7
8 #include "content/browser/memory/memory_monitor.h"
9 #include "content/common/content_export.h"
10
11 namespace content {
12
13 // A memory monitor for the Mac platform.
14 class CONTENT_EXPORT MemoryMonitorMac : public MemoryMonitor {
15 public:
16 MemoryMonitorMac(MemoryMonitorDelegate* delegate,
17 base::TimeDelta poll_interval);
18 ~MemoryMonitorMac() override;
19
20 // MemoryMonitor:
21 int GetFreeMemoryUntilCriticalMB() override;
22
23 // Factory function to create an instance of this class.
24 static std::unique_ptr<MemoryMonitorMac> Create(
25 MemoryMonitorDelegate* delegate,
26 base::TimeDelta poll_interval);
27
28 private:
29 // The delegate to be used for retrieving system memory information. Used as a
30 // testing seam.
31 MemoryMonitorDelegate* delegate_;
32
33 // The poll-interval amount by which |critical_free_mb_| increase.
34 const int64_t poll_interval_adjustment_mb_;
35
36 // The threshold of free memory that is considered "critical". This value is
37 // determined dynamically via system "memory pressure" events.
38 int critical_free_mb_;
39 };
40
41 // 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.
42 class CONTENT_EXPORT MemoryMonitorMacDelegate : public MemoryMonitorDelegate {
43 public:
44 static MemoryMonitorMacDelegate* GetInstance();
45
46 // Returns system memory-pressure information.
47 bool GetSystemMemoryPressure(int* mem_pressure) override;
48 };
49
50 } // namespace content
51
52 #endif // CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698