Add crash reporter module (based on Quincy).

This commit is contained in:
Cheng Zhao 2013-06-01 15:57:37 +08:00
parent 97bc6cfc81
commit cd42fcceb9
5 changed files with 98 additions and 0 deletions

View file

@ -12,6 +12,7 @@
'browser/api/lib/app.coffee',
'browser/api/lib/atom-delegate.coffee',
'browser/api/lib/browser-window.coffee',
'browser/api/lib/crash-reporter.coffee',
'browser/api/lib/dialog.coffee',
'browser/api/lib/ipc.coffee',
'browser/api/lib/menu.coffee',
@ -36,6 +37,8 @@
'browser/api/atom_api_app.h',
'browser/api/atom_api_browser_ipc.cc',
'browser/api/atom_api_browser_ipc.h',
'browser/api/atom_api_crash_reporter.h',
'browser/api/atom_api_crash_reporter_mac.mm',
'browser/api/atom_api_dialog.cc',
'browser/api/atom_api_dialog.h',
'browser/api/atom_api_event.cc',

View file

@ -0,0 +1,31 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
#define ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_
#include "base/basictypes.h"
#include "v8/include/v8.h"
namespace atom {
namespace api {
class CrashReporter {
public:
static void Initialize(v8::Handle<v8::Object> target);
private:
static v8::Handle<v8::Value> SetCompanyName(const v8::Arguments &args);
static v8::Handle<v8::Value> SetSubmissionURL(const v8::Arguments &args);
static v8::Handle<v8::Value> SetAutoSubmit(const v8::Arguments &args);
DISALLOW_IMPLICIT_CONSTRUCTORS(CrashReporter);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_CRASH_REPORTER_H_

View file

@ -0,0 +1,62 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/api/atom_api_crash_reporter.h"
#import <Quincy/BWQuincyManager.h>
#include "base/strings/sys_string_conversions.h"
#include "vendor/node/src/node.h"
#include "vendor/node/src/node_internals.h"
namespace atom {
namespace api {
namespace {
// Converts a V8 value to a string16.
string16 V8ValueToUTF16(v8::Handle<v8::Value> value) {
v8::String::Value s(value);
return string16(reinterpret_cast<const char16*>(*s), s.length());
}
} // namespace
// static
v8::Handle<v8::Value> CrashReporter::SetCompanyName(const v8::Arguments &args) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
string16 str(V8ValueToUTF16(args[0]));
[manager setCompanyName:base::SysUTF16ToNSString(str)];
return v8::Undefined();
}
// static
v8::Handle<v8::Value> CrashReporter::SetSubmissionURL(
const v8::Arguments &args) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
string16 str(V8ValueToUTF16(args[0]));
[manager setSubmissionURL:base::SysUTF16ToNSString(str)];
return v8::Undefined();
}
// static
v8::Handle<v8::Value> CrashReporter::SetAutoSubmit(const v8::Arguments &args) {
BWQuincyManager *manager = [BWQuincyManager sharedQuincyManager];
[manager setAutoSubmitCrashReport:args[0]->BooleanValue()];
return v8::Undefined();
}
// static
void CrashReporter::Initialize(v8::Handle<v8::Object> target) {
node::SetMethod(target, "setCompanyName", SetCompanyName);
node::SetMethod(target, "setSubmissionURL", SetSubmissionURL);
node::SetMethod(target, "setAutoSubmit", SetAutoSubmit);
}
} // namespace api
} // namespace atom
NODE_MODULE(atom_browser_crash_reporter, atom::api::CrashReporter::Initialize)

View file

@ -0,0 +1 @@
module.exports = process.atomBinding 'crash_reporter'

View file

@ -10,6 +10,7 @@ NODE_EXT_LIST_START
// Module names start with `atom_browser_` can only be used by browser process.
NODE_EXT_LIST_ITEM(atom_browser_app)
NODE_EXT_LIST_ITEM(atom_browser_crash_reporter)
NODE_EXT_LIST_ITEM(atom_browser_dialog)
NODE_EXT_LIST_ITEM(atom_browser_ipc)
NODE_EXT_LIST_ITEM(atom_browser_menu)