diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index eed02f57853d..adc8f061aef8 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -6,7 +6,6 @@ #include #include -#include #include #include "atom/common/atom_version.h" @@ -157,28 +156,14 @@ void AtomBindings::Log(const base::string16& message) { std::cout << message << std::flush; } +// static void AtomBindings::Crash() { static_cast(nullptr)->crash = true; } -void AtomBindings::StartCrashReporter( - const std::string& product_name, - const std::string& company_name, - const std::string& submit_url, - const std::string& tmp_path, - const std::map& extra_parameters) { - auto all_parameters = extra_parameters; - all_parameters["_productName"] = product_name; - all_parameters["_companyName"] = company_name; - - auto reporter = crash_reporter::CrashReporter::GetInstance(); - reporter->Start(product_name, - company_name, - submit_url, - base::FilePath(tmp_path), - true, - false, - all_parameters); +// static +void AtomBindings::StartCrashReporter(const mate::Dictionary& options) { + crash_reporter::CrashReporter::GetInstance()->StartWithOptions(options); } } // namespace atom diff --git a/atom/common/api/atom_bindings.h b/atom/common/api/atom_bindings.h index 2be34c989f58..be5352ef1bcf 100644 --- a/atom/common/api/atom_bindings.h +++ b/atom/common/api/atom_bindings.h @@ -6,11 +6,10 @@ #define ATOM_COMMON_API_ATOM_BINDINGS_H_ #include -#include -#include #include "base/macros.h" #include "base/strings/string16.h" +#include "native_mate/dictionary.h" #include "v8/include/v8.h" #include "vendor/node/deps/uv/include/uv.h" @@ -31,12 +30,7 @@ class AtomBindings { static void Log(const base::string16& message); static void Crash(); - static void StartCrashReporter( - const std::string& product_name, - const std::string& company_name, - const std::string& submit_url, - const std::string& tmp_path, - const std::map& extra_parameters); + static void StartCrashReporter(const mate::Dictionary& options); private: void ActivateUVLoop(v8::Isolate* isolate); diff --git a/atom/common/crash_reporter/crash_reporter.cc b/atom/common/crash_reporter/crash_reporter.cc index 5e13bd6fe5b0..28184445fd81 100644 --- a/atom/common/crash_reporter/crash_reporter.cc +++ b/atom/common/crash_reporter/crash_reporter.cc @@ -6,6 +6,7 @@ #include "atom/browser/browser.h" #include "atom/common/atom_version.h" +#include "atom/common/native_mate_converters/file_path_converter.h" #include "base/command_line.h" #include "base/files/file_util.h" #include "base/strings/string_number_conversions.h" @@ -22,6 +23,25 @@ CrashReporter::CrashReporter() { CrashReporter::~CrashReporter() { } +void CrashReporter::StartWithOptions(const mate::Dictionary& options) { + std::string product_name; + options.Get("productName", &product_name); + std::string company_name; + options.Get("companyName", &company_name); + std::string submit_url; + options.Get("submitURL", &submit_url); + base::FilePath crashes_dir; + options.Get("crashesDirectory", &crashes_dir); + StringMap extra_parameters; + options.Get("extra", &extra_parameters); + + extra_parameters["_productName"] = product_name; + extra_parameters["_companyName"] = company_name; + + Start(product_name, company_name, submit_url, crashes_dir, true, false, + extra_parameters); +} + void CrashReporter::Start(const std::string& product_name, const std::string& company_name, const std::string& submit_url, diff --git a/atom/common/crash_reporter/crash_reporter.h b/atom/common/crash_reporter/crash_reporter.h index 6eb43d0a2dfe..c04b5d7ba25d 100644 --- a/atom/common/crash_reporter/crash_reporter.h +++ b/atom/common/crash_reporter/crash_reporter.h @@ -12,6 +12,7 @@ #include "base/files/file_path.h" #include "base/macros.h" +#include "native_mate/dictionary.h" namespace crash_reporter { @@ -29,6 +30,7 @@ class CrashReporter { bool upload_to_server, bool skip_system_crash_handler, const StringMap& extra_parameters); + void StartWithOptions(const mate::Dictionary& options); virtual std::vector GetUploadedReports( const base::FilePath& crashes_dir); diff --git a/default_app/forkedProcess.js b/default_app/forkedProcess.js index 44a74801beb3..864b51ef688e 100644 --- a/default_app/forkedProcess.js +++ b/default_app/forkedProcess.js @@ -5,8 +5,14 @@ let productName = 'Child Product'; let companyName = 'Child Company'; let tmpPath = path.join(os.tmpdir(), productName + ' Crashes'); -process.crashReporter.start(productName, companyName, 'http://localhost:8080/uploadDump/childDump', tmpPath, { +process.crashReporter.start({ + productName: productName, + companyName: companyName, + submitURL: 'http://localhost:1127/post', + crashesDirectory: tmpPath, + extra: { randomData1: 'The Holidays are here!', randomData2: 'Happy New Year!' + } }); process.crash();