#include "atom/common/atom_version.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
-#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "content/public/common/content_switches.h"
void CrashReporter::Start(const std::string& product_name,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_path,
bool auto_submit,
bool skip_system_crash_handler,
const StringMap& extra_parameters) {
SetUploadParameters(extra_parameters);
InitBreakpad(product_name, ATOM_VERSION_STRING, company_name, submit_url,
- auto_submit, skip_system_crash_handler);
+ temp_path, auto_submit, skip_system_crash_handler);
}
-bool CrashReporter::GetTempDirectory(base::FilePath* path) {
- bool success = PathService::Get(base::DIR_TEMP, path);
- if (!success)
- LOG(ERROR) << "Cannot get temp directory";
- return success;
-}
-
-bool CrashReporter::GetCrashesDirectory(
- const std::string& product_name, base::FilePath* path) {
- if (GetTempDirectory(path)) {
- *path = path->Append(product_name + " Crashes");
- return true;
- }
- return false;
+base::FilePath CrashReporter::GetCrashesDirectory(
+ const std::string& product_name, const std::string& temp_dir) {
+ return base::FilePath(temp_dir).Append(product_name + " Crashes");
}
void CrashReporter::SetUploadParameters(const StringMap& parameters) {
}
std::vector<CrashReporter::UploadReportResult>
-CrashReporter::GetUploadedReports(const std::string& product_name) {
+CrashReporter::GetUploadedReports(const std::string& product_name,
+ const std::string& temp_path) {
std::vector<CrashReporter::UploadReportResult> result;
- base::FilePath crashes_dir;
- if (!GetCrashesDirectory(product_name, &crashes_dir))
- return result;
-
+ base::FilePath uploads_path =
+ GetCrashesDirectory(product_name, temp_path).Append("uploads.log");
std::string file_content;
- if (base::ReadFileToString(crashes_dir.Append("uploads.log"),
- &file_content)) {
+ if (base::ReadFileToString(uploads_path, &file_content)) {
std::vector<std::string> reports = base::SplitString(
file_content, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
for (const std::string& report : reports) {
const std::string& version,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_path,
bool auto_submit,
bool skip_system_crash_handler) {
}
void Start(const std::string& product_name,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_path,
bool auto_submit,
bool skip_system_crash_handler,
const StringMap& extra_parameters);
virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
- const std::string& product_name);
+ const std::string& product_name,
+ const std::string& temp_path);
protected:
CrashReporter();
const std::string& version,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_path,
bool auto_submit,
bool skip_system_crash_handler);
virtual void SetUploadParameters();
- bool GetTempDirectory(base::FilePath* path);
- bool GetCrashesDirectory(const std::string& product_name,
- base::FilePath* path);
+ base::FilePath GetCrashesDirectory(const std::string& product_name,
+ const std::string& temp_dir);
StringMap upload_parameters_;
bool is_browser_;
const std::string& version,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_dir,
bool auto_submit,
bool skip_system_crash_handler) {
- EnableCrashDumping(product_name);
+ EnableCrashDumping(product_name, temp_dir);
crash_keys_.SetKeyValue("prod", ATOM_PRODUCT_NAME);
crash_keys_.SetKeyValue("ver", version.c_str());
upload_parameters_["platform"] = "linux";
}
-void CrashReporterLinux::EnableCrashDumping(const std::string& product_name) {
- base::FilePath dumps_path;
- if (!GetCrashesDirectory(product_name, &dumps_path))
- return;
-
+void CrashReporterLinux::EnableCrashDumping(const std::string& product_name,
+ const std::string& temp_dir) {
+ base::FilePath dumps_path = GetCrashesDirectory(product_name, temp_dir);
base::CreateDirectory(dumps_path);
std::string log_file = base::StringPrintf(
CrashReporterLinux();
virtual ~CrashReporterLinux();
- void EnableCrashDumping(const std::string& product_name);
+ void EnableCrashDumping(const std::string& product_name,
+ const std::string& temp_dir);
static bool CrashDone(const google_breakpad::MinidumpDescriptor& minidump,
void* context,
const std::string& version,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_path,
bool auto_submit,
bool skip_system_crash_handler) override;
void SetUploadParameters() override;
const base::StringPiece& value);
std::vector<UploadReportResult> GetUploadedReports(
- const std::string& path) override;
+ const std::string& path, const std::string& temp_path) override;
std::unique_ptr<crashpad::SimpleStringDictionary> simple_string_dictionary_;
const std::string& version,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_dir,
bool auto_submit,
bool skip_system_crash_handler) {
// check whether crashpad has been initialized.
if (simple_string_dictionary_)
return;
- base::FilePath database_path;
- if (!GetCrashesDirectory(product_name, &database_path))
- return;
-
+ base::FilePath database_path = GetCrashesDirectory(product_name, temp_dir);
if (is_browser_) {
@autoreleasepool {
base::FilePath framework_bundle_path = base::mac::FrameworkBundlePath();
}
std::vector<CrashReporter::UploadReportResult>
-CrashReporterMac::GetUploadedReports(const std::string& product_name) {
+CrashReporterMac::GetUploadedReports(const std::string& product_name,
+ const std::string& temp_path) {
std::vector<CrashReporter::UploadReportResult> uploaded_reports;
- base::FilePath file_path;
- if (!GetCrashesDirectory(product_name, &file_path) ||
- !base::PathExists(file_path)) {
+ base::FilePath file_path = GetCrashesDirectory(product_name, temp_path);
+ if (!base::PathExists(file_path)) {
return uploaded_reports;
}
-
// Load crashpad database.
std::unique_ptr<crashpad::CrashReportDatabase> database =
crashpad::CrashReportDatabase::Initialize(file_path);
const std::string& version,
const std::string& company_name,
const std::string& submit_url,
+ const std::string& temp_path,
bool auto_submit,
bool skip_system_crash_handler) {
skip_system_crash_handler_ = skip_system_crash_handler;
- base::FilePath temp_dir;
- if (!GetTempDirectory(&temp_dir))
- return;
-
base::string16 pipe_name = base::ReplaceStringPlaceholders(
kPipeNameFormat, base::UTF8ToUTF16(product_name), NULL);
base::string16 wait_name = base::ReplaceStringPlaceholders(
breakpad_.reset();
breakpad_.reset(new google_breakpad::ExceptionHandler(
- temp_dir.value(),
+ temp_path,
FilterCallback,
MinidumpCallback,
this,
let {autoSubmit, companyName, extra, ignoreSystemCrashHandler, submitURL} = options
const app = (process.type === 'browser' ? electron : electron.remote).app
+ this.tempDirectory = app.getPath('temp')
if (this.productName == null) {
this.productName = app.getName()
}
if (extra._version == null) {
extra._version = app.getVersion()
}
-
if (companyName == null) {
throw new Error('companyName is a required option to crashReporter.start')
}
})
}
- binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra)
+ binding.start(this.productName, companyName, submitURL, this.tempDirectory, autoSubmit, ignoreSystemCrashHandler, extra)
}
getLastCrashReport () {
}
getUploadedReports () {
- return binding._getUploadedReports(this.productName)
+ return binding._getUploadedReports(this.productName, this.tempDirectory)
}
}