Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
  • Loading branch information
2 people authored and codebytere committed Apr 28, 2023
1 parent c2308db commit d7d4696
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 19 additions & 3 deletions docs/api/power-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,27 @@ Emitted when system changes to battery power.

### Event: 'thermal-state-change' _macOS_

* `state` string - one of `unknown`, `nominal`, `fair`, `serious`, `critical`.
* `state` string - The system's new thermal state. Can be `unknown`, `nominal`, `fair`, `serious`, `critical`.

### Event: 'speed-limit-change' _macOS_
Emitted when the thermal state of the system changes. Notification of a change
in the thermal status of the system, such as entering a critical temperature
range. Depending on the severity, the system might take steps to reduce said
temperature, for example, throttling the CPU or switching on the fans if
available.

* `limit` number
Apps may react to the new state by reducing expensive computing tasks (e.g.
video encoding), or notifying the user. The same state might be received
repeatedly.

See https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/RespondToThermalStateChanges.html

### Event: 'speed-limit-change' _macOS_ _Windows_

* `limit` number - The operating system's advertised speed limit for CPUs, in percent.

Notification of a change in the operating system's advertised speed limit for
CPUs, in percent. Values below 100 indicate that the system is impairing
processing power due to thermal management.

### Event: 'shutdown' _Linux_ _macOS_

Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_power_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ void PowerMonitor::OnResume() {
void PowerMonitor::OnThermalStateChange(DeviceThermalState new_state) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
EmitWithoutEvent(
EmitWithoutCustomEvent(
"thermal-state-change",
gin::DataObjectBuilder(isolate).Set("state", new_state).Build());
}

void PowerMonitor::OnSpeedLimitChange(int speed_limit) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
EmitWithoutEvent(
EmitWithoutCustomEvent(
"speed-limit-change",
gin::DataObjectBuilder(isolate).Set("limit", speed_limit).Build());
}
Expand Down

0 comments on commit d7d4696

Please sign in to comment.