1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ash / hud_display / data_source.h [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_HUD_DISPLAY_DATA_SOURCE_H_
#define ASH_HUD_DISPLAY_DATA_SOURCE_H_
#include <cstdint>
#include <limits>
#include "ash/hud_display/cpu_stats.h"
namespace ash {
namespace hud_display {
// This is source of data to draw the HUD display.
class DataSource {
public:
struct Snapshot {
Snapshot();
Snapshot(const Snapshot&);
Snapshot& operator=(const Snapshot&);
// All memory sizes are in bytes.
// Separate non-zero-initialized members from zero-initialized.
int64_t free_ram{std::numeric_limits<int64_t>::max()};
int64_t physical_ram = 0; // Amount of physical RAM installed.
int64_t total_ram = 0; // As reported in /proc/meminfo.
// Amount of RSS Private memory used by "/android" cgroup.
int64_t arc_rss = 0;
// Amount of RSS Shared memory used by "/android" cgroup.
int64_t arc_rss_shared = 0;
// Amount of RSS Private memory used by Chrome browser process.
int64_t browser_rss = 0;
// Amount of RSS Shared memory used by Chrome browser process.
int64_t browser_rss_shared = 0;
// Amount of GPU memory used by kernel GPU driver.
int64_t gpu_kernel = 0;
// Amount of RSS Private memory used by Chrome GPU process.
int64_t gpu_rss = 0;
// Amount of RSS Shared memory used by Chrome GPU process.
int64_t gpu_rss_shared = 0;
// Amount of RSS Private memory used by Chrome type=renderer processes.
int64_t renderers_rss = 0;
// Amount of RSS Shared memory used by Chrome type=renderer processes.
int64_t renderers_rss_shared = 0;
// CPU stats are calculated only in GetSnapshotAndReset().
// CPU usage values should sum to 1.
float cpu_idle_part = 0; // Amount spent in idle state.
float cpu_user_part = 0; // Amount spent in user + nice mode.
float cpu_system_part = 0; // Amount spent in system mode.
float cpu_other_part = 0; // Other states: irq, etc.
};
DataSource();
DataSource(const DataSource&) = delete;
DataSource& operator=(const DataSource&) = delete;
~DataSource();
// This must be called on io-enabled thread.
Snapshot GetSnapshotAndReset();
private:
void Refresh();
Snapshot GetSnapshot() const;
void ResetCounters();
// Current system snapshot.
Snapshot snapshot_;
// Last CPU stats snapshot.
CpuStats cpu_stats_latest_;
// Last stats before Reset() to calculate delta.
CpuStats cpu_stats_base_;
};
} // namespace hud_display
} // namespace ash
#endif // ASH_HUD_DISPLAY_DATA_SOURCE_H_