2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-06-01 07:57:37 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 01:13:06 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2014-04-15 08:02:19 +00:00
|
|
|
#include "base/bind.h"
|
2019-05-01 22:19:11 +00:00
|
|
|
#include "gin/data_object_builder.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/crash_reporter/crash_reporter.h"
|
2019-09-04 15:45:25 +00:00
|
|
|
#include "shell/common/gin_converters/callback_converter.h"
|
2019-10-18 00:31:29 +00:00
|
|
|
#include "shell/common/gin_converters/file_path_converter.h"
|
2019-09-04 15:45:25 +00:00
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
2013-12-11 07:48:19 +00:00
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/node_includes.h"
|
2013-06-01 07:57:37 +00:00
|
|
|
|
2015-06-03 03:31:34 +00:00
|
|
|
using crash_reporter::CrashReporter;
|
|
|
|
|
2019-05-01 22:19:11 +00:00
|
|
|
namespace gin {
|
2014-04-15 08:02:19 +00:00
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
template <>
|
2015-06-04 07:52:16 +00:00
|
|
|
struct Converter<CrashReporter::UploadReportResult> {
|
2018-04-18 01:55:30 +00:00
|
|
|
static v8::Local<v8::Value> ToV8(
|
|
|
|
v8::Isolate* isolate,
|
2015-06-04 07:52:16 +00:00
|
|
|
const CrashReporter::UploadReportResult& reports) {
|
2019-05-01 22:19:11 +00:00
|
|
|
return gin::DataObjectBuilder(isolate)
|
|
|
|
.Set("date",
|
2019-01-12 01:00:43 +00:00
|
|
|
v8::Date::New(isolate->GetCurrentContext(), reports.first * 1000.0)
|
2019-05-01 22:19:11 +00:00
|
|
|
.ToLocalChecked())
|
|
|
|
.Set("id", reports.second)
|
|
|
|
.Build();
|
2015-06-03 01:47:42 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-01 22:19:11 +00:00
|
|
|
} // namespace gin
|
2014-04-15 08:02:19 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void Initialize(v8::Local<v8::Object> exports,
|
|
|
|
v8::Local<v8::Value> unused,
|
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
void* priv) {
|
2017-02-02 22:23:21 +00:00
|
|
|
auto reporter = base::Unretained(CrashReporter::GetInstance());
|
2019-09-04 15:45:25 +00:00
|
|
|
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
|
|
|
dict.SetMethod("start", base::BindRepeating(&CrashReporter::Start, reporter));
|
|
|
|
dict.SetMethod(
|
|
|
|
"addExtraParameter",
|
|
|
|
base::BindRepeating(&CrashReporter::AddExtraParameter, reporter));
|
|
|
|
dict.SetMethod(
|
|
|
|
"removeExtraParameter",
|
2019-05-01 22:19:11 +00:00
|
|
|
base::BindRepeating(&CrashReporter::RemoveExtraParameter, reporter));
|
2019-09-04 15:45:25 +00:00
|
|
|
dict.SetMethod("getParameters",
|
|
|
|
base::BindRepeating(&CrashReporter::GetParameters, reporter));
|
|
|
|
dict.SetMethod(
|
|
|
|
"getUploadedReports",
|
|
|
|
base::BindRepeating(&CrashReporter::GetUploadedReports, reporter));
|
|
|
|
dict.SetMethod(
|
|
|
|
"setUploadToServer",
|
|
|
|
base::BindRepeating(&CrashReporter::SetUploadToServer, reporter));
|
|
|
|
dict.SetMethod(
|
|
|
|
"getUploadToServer",
|
|
|
|
base::BindRepeating(&CrashReporter::GetUploadToServer, reporter));
|
2013-06-01 07:57:37 +00:00
|
|
|
}
|
|
|
|
|
2014-04-15 08:02:19 +00:00
|
|
|
} // namespace
|
2013-06-01 07:57:37 +00:00
|
|
|
|
2019-03-08 18:29:52 +00:00
|
|
|
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_crash_reporter, Initialize)
|