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

Unified Diff: components/memory_coordinator/browser/memory_monitor.h

Issue 2236983002: Create MemoryMonitor and Windows implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix presubmit and clang errors. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/memory_coordinator/browser/memory_monitor.h
diff --git a/components/memory_coordinator/browser/memory_monitor.h b/components/memory_coordinator/browser/memory_monitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..0d61506b00b62cc8d0f335ba2a71449e7ae00815
--- /dev/null
+++ b/components/memory_coordinator/browser/memory_monitor.h
@@ -0,0 +1,37 @@
+// 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 COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_
+#define COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_
+
+#include <memory>
+
+#include "base/macros.h"
+
+namespace memory_coordinator {
+
+// A simple class that monitors the amount of free memory available on a system.
+// This is an interface to facilitate dependency injection for testing.
+class MemoryMonitor {
+ public:
+ MemoryMonitor() {}
+ virtual ~MemoryMonitor() {}
+
+ // Returns the amount of free memory available on the system until the system
+ // will be in a critical state. Critical is as defined by the OS (swapping
+ // will occur, or physical memory will run out, etc). It is possible for this
+ // to return negative values, in which case that much memory would have to be
+ // freed in order to exit a critical memory state.
+ virtual int GetFreeMemoryUntilCriticalMB() = 0;
bashi 2016/08/11 22:03:12 (just a question) Do we have specific plans for im
chrisha 2016/08/12 20:14:00 Yes. I'm starting with desktop because that's wher
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MemoryMonitor);
+};
+
+// Factory function for creating a monitor for the current platform.
+std::unique_ptr<MemoryMonitor> CreateMemoryMonitor();
+
+} // namespace memory_coordinator
+
+#endif // COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_

Powered by Google App Engine
This is Rietveld 408576698