From 81733a523ecd0f678e99d90aa062a618c9bef2cb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 5 Oct 2016 14:00:27 -0700 Subject: [PATCH] DRY up temp directory logging --- atom/common/crash_reporter/crash_reporter.cc | 5 ++++- atom/common/crash_reporter/crash_reporter_linux.cc | 4 +--- atom/common/crash_reporter/crash_reporter_mac.mm | 6 ++---- atom/common/crash_reporter/crash_reporter_win.cc | 4 +--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/atom/common/crash_reporter/crash_reporter.cc b/atom/common/crash_reporter/crash_reporter.cc index b7f7eac..7a962da 100644 --- a/atom/common/crash_reporter/crash_reporter.cc +++ b/atom/common/crash_reporter/crash_reporter.cc @@ -36,7 +36,10 @@ void CrashReporter::Start(const std::string& product_name, } bool CrashReporter::GetTempDirectory(base::FilePath* path) { - return PathService::Get(base::DIR_TEMP, path); + bool success = PathService::Get(base::DIR_TEMP, path); + if (!success) + LOG(ERROR) << "Cannot get temp directory"; + return success; } bool CrashReporter::GetCrashesDirectory( diff --git a/atom/common/crash_reporter/crash_reporter_linux.cc b/atom/common/crash_reporter/crash_reporter_linux.cc index faaa5f4..4913e4b 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.cc +++ b/atom/common/crash_reporter/crash_reporter_linux.cc @@ -79,10 +79,8 @@ void CrashReporterLinux::SetUploadParameters() { void CrashReporterLinux::EnableCrashDumping(const std::string& product_name) { base::FilePath dumps_path; - if (!GetCrashesDirectory(&dumps_path)) { - LOG(ERROR) << "Cannot get temp directory"; + if (!GetCrashesDirectory(&dumps_path)) return; - } base::CreateDirectory(dumps_path); diff --git a/atom/common/crash_reporter/crash_reporter_mac.mm b/atom/common/crash_reporter/crash_reporter_mac.mm index e5bfc43..99e8846 100644 --- a/atom/common/crash_reporter/crash_reporter_mac.mm +++ b/atom/common/crash_reporter/crash_reporter_mac.mm @@ -34,15 +34,13 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name, bool auto_submit, bool skip_system_crash_handler) { // check whether crashpad has been initialized. - // Only need to initilize once. + // Only need to initialize once. if (simple_string_dictionary_) return; base::FilePath database_path; - if (!GetCrashesDirectory(product_name, &database_path)) { - LOG(ERROR) << "Cannot get temp directory"; + if (!GetCrashesDirectory(product_name, &database_path)) return; - } if (is_browser_) { @autoreleasepool { diff --git a/atom/common/crash_reporter/crash_reporter_win.cc b/atom/common/crash_reporter/crash_reporter_win.cc index 4e3d2ef..27af3e1 100644 --- a/atom/common/crash_reporter/crash_reporter_win.cc +++ b/atom/common/crash_reporter/crash_reporter_win.cc @@ -154,10 +154,8 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name, skip_system_crash_handler_ = skip_system_crash_handler; base::FilePath temp_dir; - if (!GetTempDirectory(&temp_dir)) { - LOG(ERROR) << "Cannot get temp directory"; + if (!GetTempDirectory(&temp_dir)) return; - } base::string16 pipe_name = base::ReplaceStringPlaceholders( kPipeNameFormat, base::UTF8ToUTF16(product_name), NULL); -- 2.7.4