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

Side by Side Diff: components/memory_coordinator/browser/memory_monitor.h

Issue 2310193002: Added MemoryMonitor for Linux (with test) (Closed)
Patch Set: rebased Created 4 years, 3 months 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
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ 5 #ifndef COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_
6 #define COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ 6 #define COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/memory_coordinator/common/memory_coordinator_export.h" 11 #include "components/memory_coordinator/common/memory_coordinator_export.h"
12 12
13 namespace base {
14 struct SystemMemoryInfoKB;
15 }
16
13 namespace memory_coordinator { 17 namespace memory_coordinator {
14 18
15 // A simple class that monitors the amount of free memory available on a system. 19 // A simple class that monitors the amount of free memory available on a system.
16 // This is an interface to facilitate dependency injection for testing. 20 // This is an interface to facilitate dependency injection for testing.
17 class MEMORY_COORDINATOR_EXPORT MemoryMonitor { 21 class MEMORY_COORDINATOR_EXPORT MemoryMonitor {
18 public: 22 public:
19 MemoryMonitor() {} 23 MemoryMonitor() {}
20 virtual ~MemoryMonitor() {} 24 virtual ~MemoryMonitor() {}
21 25
22 // Returns the amount of free memory available on the system until the system 26 // Returns the amount of free memory available on the system until the system
23 // will be in a critical state. Critical is as defined by the OS (swapping 27 // will be in a critical state. Critical is as defined by the OS (swapping
24 // will occur, or physical memory will run out, etc). It is possible for this 28 // will occur, or physical memory will run out, etc). It is possible for this
25 // to return negative values, in which case that much memory would have to be 29 // to return negative values, in which case that much memory would have to be
26 // freed in order to exit a critical memory state. 30 // freed in order to exit a critical memory state.
27 virtual int GetFreeMemoryUntilCriticalMB() = 0; 31 virtual int GetFreeMemoryUntilCriticalMB() = 0;
28 32
29 private: 33 private:
30 DISALLOW_COPY_AND_ASSIGN(MemoryMonitor); 34 DISALLOW_COPY_AND_ASSIGN(MemoryMonitor);
31 }; 35 };
32 36
33 // Factory function for creating a monitor for the current platform. 37 // Factory function for creating a monitor for the current platform.
34 MEMORY_COORDINATOR_EXPORT std::unique_ptr<MemoryMonitor> CreateMemoryMonitor(); 38 MEMORY_COORDINATOR_EXPORT std::unique_ptr<MemoryMonitor> CreateMemoryMonitor();
35 39
40
41 // A class for fetching system information used by a memory monitor. This can
42 // be subclassed for testing or if a particular MemoryMonitor implementation
43 // needs additional functionality.
44 class MEMORY_COORDINATOR_EXPORT MemoryMonitorDelegate {
45 public:
46 MemoryMonitorDelegate() {}
47 virtual ~MemoryMonitorDelegate();
48
49 // Returns system memory information.
50 virtual void GetSystemMemoryInfo(base::SystemMemoryInfoKB* mem_info);
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(MemoryMonitorDelegate);
54 };
55
36 } // namespace memory_coordinator 56 } // namespace memory_coordinator
37 57
38 #endif // COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ 58 #endif // COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_
OLDNEW
« no previous file with comments | « components/memory_coordinator/browser/BUILD.gn ('k') | components/memory_coordinator/browser/memory_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698