diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 036c61b407f..018ca1f85a3 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -24,6 +24,7 @@ #include "base/path_service.h" #include "brightray/browser/brightray_paths.h" #include "content/public/browser/client_certificate_delegate.h" +#include "content/public/browser/gpu_data_manager.h" #include "native_mate/callback.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" @@ -135,10 +136,12 @@ void OnClientCertificateSelected( App::App() { Browser::Get()->AddObserver(this); + content::GpuDataManager::GetInstance()->AddObserver(this); } App::~App() { Browser::Get()->RemoveObserver(this); + content::GpuDataManager::GetInstance()->RemoveObserver(this); } void App::OnBeforeQuit(bool* prevent_default) { @@ -206,6 +209,10 @@ void App::OnSelectCertificate( cert_request_info->client_certs[0].get()); } +void App::OnGpuProcessCrashed(base::TerminationStatus exit_code) { + Emit("gpu-crashed"); +} + base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) { bool succeed = false; base::FilePath path; diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 97489917dc2..040f7e3363a 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -9,6 +9,7 @@ #include "atom/browser/api/event_emitter.h" #include "atom/browser/browser_observer.h" +#include "content/public/browser/gpu_data_manager_observer.h" #include "native_mate/handle.h" namespace base { @@ -24,7 +25,8 @@ namespace atom { namespace api { class App : public mate::EventEmitter, - public BrowserObserver { + public BrowserObserver, + public content::GpuDataManagerObserver { public: static mate::Handle Create(v8::Isolate* isolate); @@ -47,6 +49,9 @@ class App : public mate::EventEmitter, net::SSLCertRequestInfo* cert_request_info, scoped_ptr delegate) override; + // content::GpuDataManagerObserver: + void OnGpuProcessCrashed(base::TerminationStatus exit_code) override; + // mate::Wrappable: mate::ObjectTemplateBuilder GetObjectTemplateBuilder( v8::Isolate* isolate) override; diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 849b60ee6fa..d07b03760d0 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -328,11 +328,6 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path, 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()) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 9ef88e57040..e6056d05657 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -12,7 +12,6 @@ #include "atom/browser/common_web_contents_delegate.h" #include "content/public/common/favicon_url.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" @@ -34,8 +33,7 @@ namespace api { class WebContents : public mate::TrackableObject, public CommonWebContentsDelegate, - public content::WebContentsObserver, - public content::GpuDataManagerObserver { + public content::WebContentsObserver { public: // For node.js callback function type: function(error, buffer) typedef base::Callback, v8::Local)> @@ -185,9 +183,6 @@ class WebContents : public mate::TrackableObject, void PluginCrashed(const base::FilePath& plugin_path, base::ProcessId plugin_pid) override; - // content::GpuDataManagerObserver: - void OnGpuProcessCrashed(base::TerminationStatus exit_code) override; - private: enum Type { BROWSER_WINDOW, // Used by BrowserWindow.