6813689: Switch SystemMemoryInfoKB to use ByteCount

https://chromium-review.googlesource.com/c/chromium/src/+/6813689
This commit is contained in:
clavin
2025-08-07 15:10:39 -06:00
parent e1f649a5e0
commit eae81d1672

View File

@@ -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();