From 237bd6790b457c288f3e21e50543cb9634874fbd Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 18 Dec 2017 22:23:20 +0530 Subject: [PATCH] FIXME: allow IO access on main thread for crash reporter --- .../crash_reporter/crash_reporter_linux.cc | 31 +++---------------- .../crash_reporter/crash_reporter_linux.h | 2 -- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/atom/common/crash_reporter/crash_reporter_linux.cc b/atom/common/crash_reporter/crash_reporter_linux.cc index db6dd663b09e..881780d8589b 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.cc +++ b/atom/common/crash_reporter/crash_reporter_linux.cc @@ -17,7 +17,7 @@ #include "base/logging.h" #include "base/memory/singleton.h" #include "base/process/memory.h" -#include "base/task_scheduler/post_task.h" +#include "base/threading/thread_restrictions.h" #include "vendor/breakpad/src/client/linux/handler/exception_handler.h" #include "vendor/breakpad/src/common/linux/linux_libc_support.h" @@ -35,18 +35,6 @@ static const size_t kDistroSize = 128; // no limit. static const off_t kMaxMinidumpFileSize = 1258291; -bool CreateCrashDataDirectory(const base::FilePath& crashes_dir) { - // Make sure the crash log directory is created. - bool success = base::CreateDirectoryAndGetError(crashes_dir, nullptr); - - if (!success) { - NOTREACHED() << "Failed to create directory '" << crashes_dir.value() - << "'"; - } - - return success; -} - } // namespace CrashReporterLinux::CrashReporterLinux() @@ -103,19 +91,10 @@ bool CrashReporterLinux::GetUploadToServer() { } void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) { - base::PostTaskWithTraitsAndReplyWithResult( - FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, - base::Bind(&CreateCrashDataDirectory, crashes_dir), - base::Bind(&CrashReporterLinux::OnCrashDataDirectoryCreated, - base::Unretained(this), crashes_dir)); -} - -void CrashReporterLinux::OnCrashDataDirectoryCreated( - const base::FilePath& crashes_dir, - bool success) { - if (!success) - return; - + { + base::ThreadRestrictions::ScopedAllowIO allow_io; + base::CreateDirectory(crashes_dir); + } std::string log_file = crashes_dir.Append("uploads.log").value(); strncpy(g_crash_log_path, log_file.c_str(), sizeof(g_crash_log_path)); diff --git a/atom/common/crash_reporter/crash_reporter_linux.h b/atom/common/crash_reporter/crash_reporter_linux.h index 880e3203baad..75a57ec1c172 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.h +++ b/atom/common/crash_reporter/crash_reporter_linux.h @@ -45,8 +45,6 @@ class CrashReporterLinux : public CrashReporter { virtual ~CrashReporterLinux(); void EnableCrashDumping(const base::FilePath& crashes_dir); - void OnCrashDataDirectoryCreated(const base::FilePath& crashes_dir, - bool success); static bool CrashDone(const google_breakpad::MinidumpDescriptor& minidump, void* context,