Index: content/browser/memory/memory_monitor_android.h |
diff --git a/content/browser/memory/memory_monitor_android.h b/content/browser/memory/memory_monitor_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b084178bbc69b433630be4cb601c1d78668ea33f |
--- /dev/null |
+++ b/content/browser/memory/memory_monitor_android.h |
@@ -0,0 +1,54 @@ |
+// 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 CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_ANDROID_H_ |
+#define CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_ANDROID_H_ |
+ |
+#include <jni.h> |
+ |
+#include "content/browser/memory/memory_monitor.h" |
+ |
+namespace content { |
+ |
+// A memory monitor for the Android system. |
+class CONTENT_EXPORT MemoryMonitorAndroid : public MemoryMonitor { |
+ public: |
+ static std::unique_ptr<MemoryMonitorAndroid> Create(); |
+ |
+ // C++ counter-part of ActivityManager.MemoryInfo |
+ struct MemoryInfo { |
+ long avail_mem; |
+ bool low_memory; |
+ long threshold; |
+ long total_mem; |
+ }; |
+ |
+ ~MemoryMonitorAndroid() override; |
+ |
+ // MemoryMonitor implementation: |
+ int GetFreeMemoryUntilCriticalMB() override; |
+ |
+ // Returns true when this class can get memory info from the Android system. |
+ bool CanGetMemoryInfo(); |
+ // Get memory info from the Android system. |
+ void GetMemoryInfo(MemoryInfo* out); |
+ |
+ private: |
+ MemoryMonitorAndroid(); |
+ |
+ // Initializes fields IDs of ActivityManager.MemoryInfo |
haraken
2016/09/16 06:49:26
field IDs
bashi
2016/09/20 02:57:01
Done.
|
+ void InitializeFieldIDs(); |
+ |
+ // Field IDs for ActivityManager.MemoryInfo |
+ jfieldID avail_mem_id_ = 0; |
+ jfieldID low_memory_id_ = 0; |
+ jfieldID threshold_id_ = 0; |
+ jfieldID total_mem_id_ = 0; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MemoryMonitorAndroid); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_ANDROID_H_ |