};
template<>
-struct Converter<std::vector<CrashReporter::UploadReportResult> > {
+struct Converter<CrashReporter::UploadReportResult> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
- const std::vector<CrashReporter::UploadReportResult>& reports) {
- v8::Local<v8::Array> result(v8::Array::New(isolate, reports.size()));
- for (size_t i = 0; i < reports.size(); ++i) {
- mate::Dictionary dict(isolate, v8::Object::New(isolate));
- dict.Set("date", reports[i].first);
- dict.Set("id", reports[i].second);
- v8::TryCatch try_catch;
- result->Set(static_cast<uint32>(i), dict.GetHandle());
- if (try_catch.HasCaught())
- LOG(ERROR) << "Setter for index " << i << " threw an exception.";
- }
- return result;
+ 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 {
-std::vector<CrashReporter::UploadReportResult> GetUploadedReports() {
- return (CrashReporter::GetInstance())->GetUploadedReports();
-}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
+ auto report = base::Unretained(CrashReporter::GetInstance());
dict.SetMethod("start",
- base::Bind(&CrashReporter::Start,
- base::Unretained(CrashReporter::GetInstance())));
- dict.SetMethod("_getUploadedReports", &GetUploadedReports);
+ base::Bind(&CrashReporter::Start, report));
+ dict.SetMethod("_getUploadedReports",
+ base::Bind(&CrashReporter::GetUploadedReports, report));
}
} // namespace
#include "vendor/crashpad/client/crashpad_client.h"
#include "vendor/crashpad/client/crashpad_info.h"
#include "vendor/crashpad/client/settings.h"
-#include "vendor/crashpad/client/simple_string_dictionary.h"
namespace crash_reporter {
const std::string& submit_url,
bool auto_submit,
bool skip_system_crash_handler) {
- static bool initialized = false;
- if (initialized)
+ // check whether crashpad has been initilized.
+ // Only need to initilize once.
+ if (simple_string_dictionary_)
return;
- initialized = true;
std::string dump_dir = "/tmp/" + product_name + " Crashes";
base::FilePath database_path(dump_dir);
crashpad_info->set_simple_annotations(simple_string_dictionary_.get());
SetCrashKeyValue("prod", ATOM_PRODUCT_NAME);
- SetCrashKeyValue("process_type", is_browser_ ? base::StringPiece("browser")
- : base::StringPiece("renderer"));
+ SetCrashKeyValue("process_type", is_browser_ ? "browser" : "renderer");
SetCrashKeyValue("ver", version);
- for (auto iter = upload_parameters_.begin();
- iter != upload_parameters_.end(); ++iter) {
- SetCrashKeyValue(iter->first, iter->second);
+ for (const auto& upload_parameter: upload_parameters_) {
+ SetCrashKeyValue(upload_parameter.first, upload_parameter.second);
}
if (is_browser_) {
crash_report_database_ = crashpad::CrashReportDatabase::Initialize(
}
}
- struct {
- bool operator()(const UploadReportResult& a, const UploadReportResult& b) {
- return a.first >= b.first;
- }
- } sort_by_time;
+ auto sort_by_time = [](const UploadReportResult& a,
+ const UploadReportResult& b) {return a.first >= b.first;};
std::sort(uploaded_reports.begin(), uploaded_reports.end(), sort_by_time);
return uploaded_reports;
}
**Note:** On OS X, electron uses a new `crashpad` client, which is different
with the `breakpad` on Windows and Linux. To enable crash collection feature,
-you are required to call `crashReporter.start` API to initiliaze `crashpad` in Browser Process, even you only collect crash report in Renderer Process.
+you are required to call `crashReporter.start` API to initiliaze `crashpad` in
+main process, even you only collect crash report in renderer process.
## crashReporter.getLastCrashReport()
protocol: 'file'
pathname: path.join fixtures, 'api', 'crash.html'
search: "?port=#{port}"
- crashReporter.start {'submitUrl': 'http://127.0.0.1:' + port}
+ crashReporter.start {'submitUrl': 'http://127.0.0.1:' + port}
w.loadUrl url