Browse Source

feat: add 'gpu-info-update' event to app (#18250)

Milan Burda 6 years ago
parent
commit
2b4ad2cb09
3 changed files with 11 additions and 0 deletions
  1. 4 0
      atom/browser/api/atom_api_app.cc
  2. 1 0
      atom/browser/api/atom_api_app.h
  3. 6 0
      docs/api/app.md

+ 4 - 0
atom/browser/api/atom_api_app.cc

@@ -773,6 +773,10 @@ void App::SelectClientCertificate(
   }
 }
 
+void App::OnGpuInfoUpdate() {
+  Emit("gpu-info-update");
+}
+
 void App::OnGpuProcessCrashed(base::TerminationStatus status) {
   Emit("gpu-process-crashed",
        status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);

+ 1 - 0
atom/browser/api/atom_api_app.h

@@ -157,6 +157,7 @@ class App : public AtomBrowserClient::Delegate,
                        bool* no_javascript_access) override;
 
   // content::GpuDataManagerObserver:
+  void OnGpuInfoUpdate() override;
   void OnGpuProcessCrashed(base::TerminationStatus status) override;
 
   // content::BrowserChildProcessObserver:

+ 6 - 0
docs/api/app.md

@@ -343,6 +343,10 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
 })
 ```
 
+### Event: 'gpu-info-update'
+
+Emitted whenever there is a GPU info update.
+
 ### Event: 'gpu-process-crashed'
 
 Returns:
@@ -1012,6 +1016,8 @@ Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetr
 
 Returns [`GPUFeatureStatus`](structures/gpu-feature-status.md) - The Graphics Feature Status from `chrome://gpu/`.
 
+**Note:** This information is only usable after the `gpu-info-update` event is emitted.
+
 ### `app.getGPUInfo(infoType)`
 
 * `infoType` String - Values can be either `basic` for basic info or `complete` for complete info.