}
};
+template<>
+struct Converter<std::vector<crash_reporter::CrashReporter::UploadReportResult> > {
+ static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
+ const std::vector<
+ crash_reporter::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;
+ }
+};
+
} // namespace mate
namespace {
+std::vector<crash_reporter::CrashReporter::UploadReportResult>
+GetUploadedReports() {
+ return (crash_reporter::CrashReporter::GetInstance())->GetUploadedReports();
+}
+
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
using crash_reporter::CrashReporter;
dict.SetMethod("start",
base::Bind(&CrashReporter::Start,
base::Unretained(CrashReporter::GetInstance())));
+ dict.SetMethod("_getUploadedReports", &GetUploadedReports);
}
} // namespace
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()
SetUploadParameters();
}
+std::vector<CrashReporter::UploadReportResult> CrashReporter::GetUploadedReports() {
+ return std::vector<CrashReporter::UploadReportResult>();
+}
+
} // namespace crash_reporter
#include <map>
#include <string>
+#include <vector>
#include "base/basictypes.h"
class CrashReporter {
public:
typedef std::map<std::string, std::string> StringMap;
+ typedef std::pair<int, std::string> UploadReportResult; // upload-date, id
static CrashReporter* GetInstance();
bool skip_system_crash_handler,
const StringMap& extra_parameters);
+ virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports();
+
protected:
CrashReporter();
virtual ~CrashReporter();
void SetCrashKeyValue(const base::StringPiece& key,
const base::StringPiece& value);
+ std::vector<UploadReportResult> GetUploadedReports() override;
+
scoped_ptr<crashpad::SimpleStringDictionary> simple_string_dictionary_;
scoped_ptr<crashpad::CrashReportDatabase> crash_report_database_;
simple_string_dictionary_->SetKeyValue(key.data(), value.data());
}
+std::vector<CrashReporter::UploadReportResult>
+CrashReporterMac::GetUploadedReports() {
+ std::vector<CrashReporter::UploadReportResult> uploaded_reports;
+
+ if (!crash_report_database_) {
+ return uploaded_reports;
+ }
+
+ std::vector<crashpad::CrashReportDatabase::Report> completed_reports;
+ crashpad::CrashReportDatabase::OperationStatus status =
+ crash_report_database_->GetCompletedReports(&completed_reports);
+ if (status != crashpad::CrashReportDatabase::kNoError) {
+ return uploaded_reports;
+ }
+
+ for (const crashpad::CrashReportDatabase::Report& completed_report :
+ completed_reports) {
+ if (completed_report.uploaded) {
+ uploaded_reports.push_back(
+ UploadReportResult(static_cast<int>(completed_report.creation_time),
+ completed_report.id));
+ }
+ }
+
+ struct {
+ bool operator()(const UploadReportResult& a, const UploadReportResult& b) {
+ return a.first >= b.first;
+ }
+ } sort_by_time;
+ std::sort(uploaded_reports.begin(), uploaded_reports.end(), sort_by_time);
+ return uploaded_reports;
+}
+
// static
CrashReporterMac* CrashReporterMac::GetInstance() {
return Singleton<CrashReporterMac>::get();