mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
6813689: Switch SystemMemoryInfoKB to use ByteCount
https://chromium-review.googlesource.com/c/chromium/src/+/6813689
This commit is contained in:
@@ -165,28 +165,28 @@ v8::Local<v8::Value> ElectronBindings::GetCreationTime(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo(
|
||||
v8::Isolate* isolate,
|
||||
gin_helper::Arguments* args) {
|
||||
base::SystemMemoryInfoKB mem_info;
|
||||
base::SystemMemoryInfo mem_info;
|
||||
if (!base::GetSystemMemoryInfo(&mem_info)) {
|
||||
args->ThrowError("Unable to retrieve system memory information");
|
||||
return v8::Undefined(isolate);
|
||||
}
|
||||
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("total", mem_info.total);
|
||||
dict.Set("total", mem_info.total.InKiB());
|
||||
|
||||
// See Chromium's "base/process/process_metrics.h" for an explanation.
|
||||
int free =
|
||||
base::ByteCount free =
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
mem_info.avail_phys;
|
||||
#else
|
||||
mem_info.free;
|
||||
#endif
|
||||
dict.Set("free", free);
|
||||
dict.Set("free", free.InKiB());
|
||||
|
||||
// NB: These return bogus values on macOS
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
dict.Set("swapTotal", mem_info.swap_total);
|
||||
dict.Set("swapFree", mem_info.swap_free);
|
||||
dict.Set("swapTotal", mem_info.swap_total.InKiB());
|
||||
dict.Set("swapFree", mem_info.swap_free.InKiB());
|
||||
#endif
|
||||
|
||||
return dict.GetHandle();
|
||||
|
||||
Reference in New Issue
Block a user