From: Kevin Sawicki Date: Wed, 5 Oct 2016 23:15:49 +0000 (-0700) Subject: Pass crashes directory to crash service process X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0380d3ae50c9290c396523a35c6e16cef859d853;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Pass crashes directory to crash service process --- diff --git a/atom/common/api/atom_api_crash_reporter.cc b/atom/common/api/atom_api_crash_reporter.cc index 184a70c..b416bda 100644 --- a/atom/common/api/atom_api_crash_reporter.cc +++ b/atom/common/api/atom_api_crash_reporter.cc @@ -6,6 +6,7 @@ #include #include "atom/common/crash_reporter/crash_reporter.h" +#include "atom/common/native_mate_converters/file_path_converter.h" #include "base/bind.h" #include "native_mate/dictionary.h" @@ -39,6 +40,8 @@ void Initialize(v8::Local exports, v8::Local unused, base::Bind(&CrashReporter::Start, report)); dict.SetMethod("_getUploadedReports", base::Bind(&CrashReporter::GetUploadedReports, report)); + dict.SetMethod("_getCrashesDirectory", + base::Bind(&CrashReporter::GetCrashesDirectory, report)); } } // namespace diff --git a/atom/common/crash_reporter/crash_reporter.h b/atom/common/crash_reporter/crash_reporter.h index 84208df..40a1f5a 100644 --- a/atom/common/crash_reporter/crash_reporter.h +++ b/atom/common/crash_reporter/crash_reporter.h @@ -34,6 +34,9 @@ class CrashReporter { const std::string& product_name, const std::string& temp_path); + base::FilePath GetCrashesDirectory(const std::string& product_name, + const std::string& temp_dir); + protected: CrashReporter(); virtual ~CrashReporter(); @@ -47,9 +50,6 @@ class CrashReporter { bool skip_system_crash_handler); virtual void SetUploadParameters(); - base::FilePath GetCrashesDirectory(const std::string& product_name, - const std::string& temp_dir); - StringMap upload_parameters_; bool is_browser_; diff --git a/atom/common/crash_reporter/win/crash_service_main.cc b/atom/common/crash_reporter/win/crash_service_main.cc index c6325f0..c672c0e 100644 --- a/atom/common/crash_reporter/win/crash_service_main.cc +++ b/atom/common/crash_reporter/win/crash_service_main.cc @@ -16,6 +16,7 @@ namespace crash_service { namespace { const char kApplicationName[] = "application-name"; +const char kCrashesDirectory[] = "crashes-directory"; const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service"; const wchar_t kStandardLogFile[] = L"operation_log.txt"; @@ -25,17 +26,11 @@ void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, // noop. } -bool GetCrashServiceDirectory(const std::wstring& application_name, - base::FilePath* dir) { - base::FilePath temp_dir; - if (!base::GetTempDir(&temp_dir)) - return false; - temp_dir = temp_dir.Append(application_name + L" Crashes"); +bool CreateCrashServiceDirectory(const base::FilePath& temp_dir) { if (!base::PathExists(temp_dir)) { if (!base::CreateDirectory(temp_dir)) return false; } - *dir = temp_dir; return true; } @@ -59,9 +54,16 @@ int Main(const wchar_t* cmd) { std::wstring application_name = cmd_line.GetSwitchValueNative( kApplicationName); + if (!cmd_line.HasSwitch(kCrashesDirectory)) { + LOG(ERROR) << "Crashes directory path must be specified with --" + << kCrashesDirectory; + return 1; + } + // We use/create a directory under the user's temp folder, for logging. - base::FilePath operating_dir; - GetCrashServiceDirectory(application_name, &operating_dir); + base::FilePath operating_dir( + cmd_line.GetSwitchValueNative(kCrashesDirectory)); + GetCrashServiceDirectory(operating_dir); base::FilePath log_file = operating_dir.Append(kStandardLogFile); // Logging to stderr (to help with debugging failures on the diff --git a/lib/common/api/crash-reporter.js b/lib/common/api/crash-reporter.js index ac0c98d..ca429df 100644 --- a/lib/common/api/crash-reporter.js +++ b/lib/common/api/crash-reporter.js @@ -43,7 +43,12 @@ class CrashReporter { } if (process.platform === 'win32') { - const args = ['--reporter-url=' + submitURL, '--application-name=' + this.productName, '--v=1'] + const args = [ + '--reporter-url=' + submitURL, + '--application-name=' + this.productName, + '--crashes-directory=' + bindings._getCrashesDirectory(this.productName, this.tempDirectory), + '--v=1' + ] const env = { ELECTRON_INTERNAL_CRASH_SERVICE: 1 } diff --git a/spec/api-crash-reporter-spec.js b/spec/api-crash-reporter-spec.js index bb114f9..72e9317 100644 --- a/spec/api-crash-reporter-spec.js +++ b/spec/api-crash-reporter-spec.js @@ -1,5 +1,4 @@ const assert = require('assert') -const fs = require('fs') const http = require('http') const multiparty = require('multiparty') const path = require('path')