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

Unified Diff: content/browser/memory/memory_monitor_android.h

Issue 2340293003: Add MemoryMonitorAndroid (Closed)
Patch Set: Use native callback instead of returning MemoryInfo 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: 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
index 3d983ac56e4a4dde4701c20f8f1cc9cf23abd663..abd7824c1ae42ab86977fdb4af3b57db71c8f702 100644
--- a/content/browser/memory/memory_monitor_android.h
+++ b/content/browser/memory/memory_monitor_android.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Copyright 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.
@@ -16,12 +16,14 @@ class CONTENT_EXPORT MemoryMonitorAndroid : public MemoryMonitor {
public:
static std::unique_ptr<MemoryMonitorAndroid> Create();
+ static bool Register(JNIEnv* env);
+
// C++ counter-part of ActivityManager.MemoryInfo
struct MemoryInfo {
- long avail_mem;
- bool low_memory;
- long threshold;
- long total_mem;
+ jlong avail_mem;
+ jboolean low_memory;
+ jlong threshold;
+ jlong total_mem;
};
~MemoryMonitorAndroid() override;
@@ -29,23 +31,12 @@ class CONTENT_EXPORT MemoryMonitorAndroid : public MemoryMonitor {
// 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 field IDs of ActivityManager.MemoryInfo
- 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);
};

Powered by Google App Engine
This is Rietveld 408576698