OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_ANDROID_H_ | |
6 #define CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_ANDROID_H_ | |
7 | |
8 #include <jni.h> | |
9 | |
10 #include "content/browser/memory/memory_monitor.h" | |
11 | |
12 namespace content { | |
13 | |
14 // A memory monitor for the Android system. | |
15 class CONTENT_EXPORT MemoryMonitorAndroid : public MemoryMonitor { | |
16 public: | |
17 static std::unique_ptr<MemoryMonitorAndroid> Create(); | |
18 | |
19 // C++ counter-part of ActivityManager.MemoryInfo | |
20 struct MemoryInfo { | |
21 long avail_mem; | |
22 bool low_memory; | |
23 long threshold; | |
24 long total_mem; | |
25 }; | |
26 | |
27 ~MemoryMonitorAndroid() override; | |
28 | |
29 // MemoryMonitor implementation: | |
30 int GetFreeMemoryUntilCriticalMB() override; | |
31 | |
32 // Returns true when this class can get memory info from the Android system. | |
33 bool CanGetMemoryInfo(); | |
34 // Get memory info from the Android system. | |
35 void GetMemoryInfo(MemoryInfo* out); | |
36 | |
37 private: | |
38 MemoryMonitorAndroid(); | |
39 | |
40 // Initializes fields IDs of ActivityManager.MemoryInfo | |
haraken
2016/09/16 06:49:26
field IDs
bashi
2016/09/20 02:57:01
Done.
| |
41 void InitializeFieldIDs(); | |
42 | |
43 // Field IDs for ActivityManager.MemoryInfo | |
44 jfieldID avail_mem_id_ = 0; | |
45 jfieldID low_memory_id_ = 0; | |
46 jfieldID threshold_id_ = 0; | |
47 jfieldID total_mem_id_ = 0; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(MemoryMonitorAndroid); | |
50 }; | |
51 | |
52 } // namespace content | |
53 | |
54 #endif // CONTENT_BROWSER_MEMORY_MEMORY_MONITOR_ANDROID_H_ | |
OLD | NEW |