Chromium Code Reviews| 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_ |