Add crashReporter property to process

This commit is contained in:
Ramya Achutha Rao 2016-12-09 01:44:12 -08:00 committed by Kevin Sawicki
parent d4b44d8b69
commit 1f07cf2545
4 changed files with 22 additions and 19 deletions

View file

@ -62,9 +62,13 @@ int NodeMain(int argc, char *argv[]) {
#if defined(OS_WIN) #if defined(OS_WIN)
process.SetMethod("log", &AtomBindings::Log); process.SetMethod("log", &AtomBindings::Log);
#endif #endif
process.SetMethod("startCrashReporter", &AtomBindings::StartCrashReporter);
process.SetMethod("crash", &AtomBindings::Crash); process.SetMethod("crash", &AtomBindings::Crash);
v8::Local<v8::Object> crashReporterObj = v8::Object::New(env->isolate());
mate::Dictionary crashReporterDict(gin_env.isolate(), crashReporterObj);
crashReporterDict.SetMethod("start", &AtomBindings::StartCrashReporter);
process.Set("crashReporter", crashReporterObj);
node::LoadEnvironment(env); node::LoadEnvironment(env);
bool more; bool more;

View file

@ -162,24 +162,23 @@ void AtomBindings::Crash() {
} }
void AtomBindings::StartCrashReporter( void AtomBindings::StartCrashReporter(
const std::string& productName, const std::string& product_name,
const std::string& companyName, const std::string& company_name,
const std::string& submitUrl, const std::string& submit_url,
const std::string& tmpPath, const std::string& tmp_path,
const std::map<std::string, std::string>& extra_parameters) { const std::map<std::string, std::string>& extra_parameters) {
std::map<std::string, std::string> allParameters; auto all_parameters = extra_parameters;
allParameters.insert(std::make_pair("_productName", productName)); all_parameters["_productName"] = product_name;
allParameters.insert(std::make_pair("_companyName", companyName)); all_parameters["_companyName"] = company_name;
allParameters.insert(extra_parameters.begin(), extra_parameters.end());
auto reporter = crash_reporter::CrashReporter::GetInstance(); auto reporter = crash_reporter::CrashReporter::GetInstance();
reporter->Start(productName, reporter->Start(product_name,
companyName, company_name,
submitUrl, submit_url,
base::FilePath(tmpPath), base::FilePath(tmp_path),
true, true,
false, false,
allParameters); all_parameters);
} }
} // namespace atom } // namespace atom

View file

@ -32,10 +32,10 @@ class AtomBindings {
static void Log(const base::string16& message); static void Log(const base::string16& message);
static void Crash(); static void Crash();
static void StartCrashReporter( static void StartCrashReporter(
const std::string& productName, const std::string& product_name,
const std::string& companyName, const std::string& company_name,
const std::string& submitUrl, const std::string& submit_url,
const std::string& tmpPath, const std::string& tmp_path,
const std::map<std::string, std::string>& extra_parameters); const std::map<std::string, std::string>& extra_parameters);
private: private:

View file

@ -5,7 +5,7 @@ let productName = 'Child Product';
let companyName = 'Child Company'; let companyName = 'Child Company';
let tmpPath = path.join(os.tmpdir(), productName + ' Crashes'); let tmpPath = path.join(os.tmpdir(), productName + ' Crashes');
process.startCrashReporter(productName, companyName, 'http://localhost:8080/uploadDump/childDump', tmpPath, { process.crashReporter.start(productName, companyName, 'http://localhost:8080/uploadDump/childDump', tmpPath, {
randomData1: 'The Holidays are here!', randomData1: 'The Holidays are here!',
randomData2: 'Happy New Year!' randomData2: 'Happy New Year!'
}); });