]> khamidou — GitHub mirrors - electron.git/commitdiff
webContents: adding events to detect gpu and plugin process crashes
authordeepak1556 <hop2deep@gmail.com>
Tue, 12 May 2015 19:35:56 +0000 (01:05 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Wed, 20 May 2015 09:35:48 +0000 (15:05 +0530)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/browser/lib/guest-view-manager.coffee
atom/renderer/lib/web-view/guest-view-internal.coffee
docs/api/browser-window.md
docs/api/web-view-tag.md

index 2866871a004bade784823c708237356883cbf1d1..5a91062340d6b23fec7c56c29893f24b323204a2 100644 (file)
@@ -24,6 +24,7 @@
 #include "content/public/browser/favicon_status.h"
 #include "content/public/browser/navigation_details.h"
 #include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/plugin_service.h"
 #include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
@@ -223,6 +224,19 @@ void WebContents::RenderProcessGone(base::TerminationStatus status) {
   Emit("crashed");
 }
 
+void WebContents::PluginCrashed(const base::FilePath& plugin_path,
+                                base::ProcessId plugin_pid) {
+  content::WebPluginInfo info;
+  auto plugin_service = content::PluginService::GetInstance();
+  plugin_service->GetPluginInfoByPath(plugin_path, &info);
+  Emit("plugin-crashed", info.name, info.version);
+}
+
+void WebContents::OnGpuProcessCrashed(base::TerminationStatus exit_code) {
+  if (exit_code == base::TERMINATION_STATUS_PROCESS_CRASHED)
+    Emit("gpu-crashed");
+}
+
 void WebContents::DocumentLoadedInFrame(
     content::RenderFrameHost* render_frame_host) {
   if (!render_frame_host->GetParent())
index e75cfb0267f0b784b82727fbe969578eda1099f6..4d0937436f3659e41e43b6a19fe5eb23e364aa2f 100644 (file)
@@ -14,6 +14,7 @@
 #include "content/public/common/favicon_url.h"
 #include "content/public/browser/web_contents_delegate.h"
 #include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/gpu_data_manager_observer.h"
 #include "native_mate/handle.h"
 #include "ui/gfx/image/image.h"
 
@@ -35,7 +36,8 @@ namespace api {
 class WebContents : public mate::EventEmitter,
                     public content::BrowserPluginGuestDelegate,
                     public content::WebContentsDelegate,
-                    public content::WebContentsObserver {
+                    public content::WebContentsObserver,
+                    public content::GpuDataManagerObserver {
  public:
   // Create from an existing WebContents.
   static mate::Handle<WebContents> CreateFrom(
@@ -182,6 +184,8 @@ class WebContents : public mate::EventEmitter,
   void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
   void DidUpdateFaviconURL(
       const std::vector<content::FaviconURL>& urls) override;
+  void PluginCrashed(const base::FilePath& plugin_path,
+                     base::ProcessId plugin_pid) override;
 
   // content::BrowserPluginGuestDelegate:
   void DidAttach(int guest_proxy_routing_id) final;
@@ -194,6 +198,9 @@ class WebContents : public mate::EventEmitter,
                   int element_instance_id,
                   bool is_full_page_plugin) final;
 
+  // content::GpuDataManagerObserver:
+  void OnGpuProcessCrashed(base::TerminationStatus exit_code) override;
+
  private:
   // Called when received a message from renderer.
   void OnRendererMessage(const base::string16& channel,
index a02a1676e8e6e4f482da37f4448b5be2a5c66467..9403466f27a7a626d9692a991b94278117bf8344 100644 (file)
@@ -15,6 +15,8 @@ supportedWebViewEvents = [
   'new-window'
   'close'
   'crashed'
+  'gpu-crashed'
+  'plugin-crashed'
   'destroyed'
   'page-title-set'
   'page-favicon-updated'
index 04aa5c5494f0246dd4180ac3a581e4f00b398335..fb1b40d27e1fdb8e26dd4f3e7ee7f681175be152 100644 (file)
@@ -17,6 +17,8 @@ WEB_VIEW_EVENTS =
   'new-window': ['url', 'frameName', 'disposition']
   'close': []
   'crashed': []
+  'gpu-crashed': []
+  'plugin-crashed': ['name', 'version']
   'destroyed': []
   'page-title-set': ['title', 'explicitSet']
   'page-favicon-updated': ['favicons']
index f8ff8e7b9e0cab2449f2ce73888456021fa7af25..9808e3abfd15a177ee83841840814521a7c6feb8 100644 (file)
@@ -724,6 +724,18 @@ Calling `event.preventDefault()` can prevent the navigation.
 
 Emitted when the renderer process is crashed.
 
+### Event: 'gpu-crashed'
+
+Emitted when the gpu process is crashed.
+
+### Event: 'plugin-crashed'
+
+* `event` Event
+* `name` String
+* `version` String
+
+Emitted when a plugin process is crashed.
+
 ### Event: 'destroyed'
 
 Emitted when the WebContents is destroyed.
index 3e008a5db2582ae26eacb9c6c68c3fa766f705aa..49c16fabae93a25118e9579e7cc5574ca0c7e4a8 100644 (file)
@@ -434,6 +434,17 @@ ipc.on('ping', function() {
 
 Fired when the renderer process is crashed.
 
+### gpu-crashed
+
+Fired when the gpu process is crashed.
+
+### plugin-crashed
+
+* `name` String
+* `version` String
+
+Fired when a plugin process is crashed.
+
 ### destroyed
 
 Fired when the WebContents is destroyed.