commit
f54506acc0
12 changed files with 155 additions and 61 deletions
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using crash_reporter::CrashReporter;
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
|
@ -31,17 +33,30 @@ struct Converter<std::map<std::string, std::string> > {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<CrashReporter::UploadReportResult> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const CrashReporter::UploadReportResult& reports) {
|
||||
mate::Dictionary dict(isolate, v8::Object::New(isolate));
|
||||
dict.Set("date", v8::Date::New(isolate, reports.first*1000.0));
|
||||
dict.Set("id", reports.second);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
using crash_reporter::CrashReporter;
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
auto report = base::Unretained(CrashReporter::GetInstance());
|
||||
dict.SetMethod("start",
|
||||
base::Bind(&CrashReporter::Start,
|
||||
base::Unretained(CrashReporter::GetInstance())));
|
||||
base::Bind(&CrashReporter::Start, report));
|
||||
dict.SetMethod("_getUploadedReports",
|
||||
base::Bind(&CrashReporter::GetUploadedReports, report));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -41,6 +41,10 @@ class CrashReporter
|
|||
start()
|
||||
|
||||
getLastCrashReport: ->
|
||||
if process.platform is 'darwin'
|
||||
reports = binding._getUploadedReports()
|
||||
return if reports.length > 0 then reports[0] else null
|
||||
|
||||
tmpdir =
|
||||
if process.platform is 'win32'
|
||||
os.tmpdir()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue