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

Unified Diff: components/memory_coordinator/browser/test_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 side-by-side diff with in-line comments
Download patch
Index: components/memory_coordinator/browser/test_memory_monitor.h
diff --git a/components/memory_coordinator/browser/test_memory_monitor.h b/components/memory_coordinator/browser/test_memory_monitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..a9e1f8148ea3578b2f57035f7ddb855b0a8fc82e
--- /dev/null
+++ b/components/memory_coordinator/browser/test_memory_monitor.h
@@ -0,0 +1,38 @@
+// 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.
+
+#include "components/memory_coordinator/browser/memory_monitor.h"
+
+#include "base/process/process_metrics.h"
+
+namespace memory_coordinator {
+
+// A delegate that allows mocking the various inputs to MemoryMonitor.
+class TestMemoryMonitorDelegate : public MemoryMonitorDelegate {
+ public:
+ TestMemoryMonitorDelegate() : calls_(0) { mem_info_ = {}; }
+ ~TestMemoryMonitorDelegate() override;
+
+ void GetSystemMemoryInfo(base::SystemMemoryInfoKB* mem_info) override;
+
+ size_t calls() const { return calls_; }
+ void ResetCalls() { calls_ = 0; }
+
+ void SetTotalMemoryKB(int total_memory_kb) {
+ mem_info_.total = total_memory_kb;
+ }
+
+ protected:
+ // Because the fields of SystemMemoryInfoKB vary depending on the operating
+ // system, specific derived classes will have to provide methods to load
+ // values into |mem_info_|;
+ base::SystemMemoryInfoKB mem_info_;
+
+ private:
+ size_t calls_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestMemoryMonitorDelegate);
+};
+
+} // namespace memory_coordinator

Powered by Google App Engine
This is Rietveld 408576698