feat: Add new powerMonitor synchronous API (#17144)

`powerMonitor.querySystemIdleState` and `powerMonitor.querySystemIdleTime` had async backing APIs in chromium (https://chromium-review.googlesource.com/c/chromium/src/+/1379183). However, that has changed in ch73. So, this PR deprecates the old async APIs and adds new sync APIs.
This commit is contained in:
Nitish Sakhawalkar 2019-02-27 12:54:01 -08:00 committed by John Kleinschmidt
commit bfa07ec4be
7 changed files with 96 additions and 25 deletions

View file

@ -84,8 +84,8 @@ void PowerMonitor::OnResume() {
Emit("resume");
}
ui::IdleState PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
int idle_threshold) {
ui::IdleState PowerMonitor::GetSystemIdleState(v8::Isolate* isolate,
int idle_threshold) {
if (idle_threshold > 0) {
return ui::CalculateIdleState(idle_threshold);
} else {
@ -95,7 +95,7 @@ ui::IdleState PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
}
}
int PowerMonitor::QuerySystemIdleTime() {
int PowerMonitor::GetSystemIdleTime() {
return ui::CalculateIdleTime();
}
@ -122,8 +122,8 @@ void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
#endif
.SetMethod("_querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
.SetMethod("_querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
.SetMethod("getSystemIdleState", &PowerMonitor::GetSystemIdleState)
.SetMethod("getSystemIdleTime", &PowerMonitor::GetSystemIdleTime);
}
} // namespace api