Merge pull request #2057 from atom/app-gpu-crash

Move gpu-crashed event to app
This commit is contained in:
Cheng Zhao 2015-06-26 10:47:04 +08:00
commit 7fd60294f9
6 changed files with 18 additions and 16 deletions

View file

@ -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-process-crashed");
}
base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {
bool succeed = false;
base::FilePath path;

View file

@ -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<App> Create(v8::Isolate* isolate);
@ -47,6 +49,9 @@ class App : public mate::EventEmitter,
net::SSLCertRequestInfo* cert_request_info,
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
// content::GpuDataManagerObserver:
void OnGpuProcessCrashed(base::TerminationStatus exit_code) override;
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;

View file

@ -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())

View file

@ -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<WebContents>,
public CommonWebContentsDelegate,
public content::WebContentsObserver,
public content::GpuDataManagerObserver {
public content::WebContentsObserver {
public:
// For node.js callback function type: function(error, buffer)
typedef base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>
@ -185,9 +183,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
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.

View file

@ -125,6 +125,10 @@ app.on('select-certificate', function(event, host, url, list, callback) {
`event.preventDefault()` prevents from using the first certificate from
the store.
### Event: 'gpu-process-crashed'
Emitted when the gpu process is crashed.
## app.quit()
Try to close all windows. The `before-quit` event will first be emitted. If all

View file

@ -757,10 +757,6 @@ 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