feat: Add new powerMonitor synchronous API (#17144)
`powerMonitor.querySystemIdleState` and `powerMonitor.querySystemIdleTime` had async backing APIs in chromium (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:
parent
29ab74688d
commit
bfa07ec4be
7 changed files with 96 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue