REVIEW: fix base::File helper usage on incorrect task sequence
This commit is contained in:
parent
fd297722a8
commit
e3a56240c9
3 changed files with 29 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/string_split.h"
|
#include "base/strings/string_split.h"
|
||||||
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
|
|
||||||
namespace crash_reporter {
|
namespace crash_reporter {
|
||||||
|
@ -53,6 +54,7 @@ bool CrashReporter::GetUploadToServer() {
|
||||||
|
|
||||||
std::vector<CrashReporter::UploadReportResult>
|
std::vector<CrashReporter::UploadReportResult>
|
||||||
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
|
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
|
||||||
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||||
std::string file_content;
|
std::string file_content;
|
||||||
std::vector<CrashReporter::UploadReportResult> result;
|
std::vector<CrashReporter::UploadReportResult> result;
|
||||||
base::FilePath uploads_path =
|
base::FilePath uploads_path =
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/memory/singleton.h"
|
#include "base/memory/singleton.h"
|
||||||
#include "base/process/memory.h"
|
#include "base/process/memory.h"
|
||||||
|
#include "base/task_scheduler/post_task.h"
|
||||||
#include "vendor/breakpad/src/client/linux/handler/exception_handler.h"
|
#include "vendor/breakpad/src/client/linux/handler/exception_handler.h"
|
||||||
#include "vendor/breakpad/src/common/linux/linux_libc_support.h"
|
#include "vendor/breakpad/src/common/linux/linux_libc_support.h"
|
||||||
|
|
||||||
|
@ -34,6 +35,18 @@ static const size_t kDistroSize = 128;
|
||||||
// no limit.
|
// no limit.
|
||||||
static const off_t kMaxMinidumpFileSize = 1258291;
|
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
|
} // namespace
|
||||||
|
|
||||||
CrashReporterLinux::CrashReporterLinux()
|
CrashReporterLinux::CrashReporterLinux()
|
||||||
|
@ -90,7 +103,18 @@ bool CrashReporterLinux::GetUploadToServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) {
|
void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) {
|
||||||
base::CreateDirectory(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;
|
||||||
|
|
||||||
std::string log_file = crashes_dir.Append("uploads.log").value();
|
std::string log_file = crashes_dir.Append("uploads.log").value();
|
||||||
strncpy(g_crash_log_path, log_file.c_str(), sizeof(g_crash_log_path));
|
strncpy(g_crash_log_path, log_file.c_str(), sizeof(g_crash_log_path));
|
||||||
|
|
|
@ -45,6 +45,8 @@ class CrashReporterLinux : public CrashReporter {
|
||||||
virtual ~CrashReporterLinux();
|
virtual ~CrashReporterLinux();
|
||||||
|
|
||||||
void EnableCrashDumping(const base::FilePath& crashes_dir);
|
void EnableCrashDumping(const base::FilePath& crashes_dir);
|
||||||
|
void OnCrashDataDirectoryCreated(const base::FilePath& crashes_dir,
|
||||||
|
bool success);
|
||||||
|
|
||||||
static bool CrashDone(const google_breakpad::MinidumpDescriptor& minidump,
|
static bool CrashDone(const google_breakpad::MinidumpDescriptor& minidump,
|
||||||
void* context,
|
void* context,
|
||||||
|
|
Loading…
Add table
Reference in a new issue