#include "remoting/base/breakpad_utils.h"
#include <utility>
#include "base/base_paths.h"
#include "base/check.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "remoting/base/version.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
namespace remoting {
class ScopedAllowBlockingForCrashReporting : public base::ScopedAllowBlocking { … };
namespace {
const base::BasePathKey kBasePathKey = …
base::BasePathKey::DIR_ASSETS;
#else
base::BasePathKey::DIR_TEMP;
#endif
const base::FilePath::CharType kMinidumpsPath[] = …FILE_PATH_LITERAL("minidumps");
#else
FILE_PATH_LITERAL("chromoting/minidumps");
#endif
const base::FilePath::CharType kTempExtension[] = …);
const base::FilePath::CharType kJsonExtension[] = …);
}
const char kBreakpadProductVersionKey[] = …;
const char kBreakpadProcessStartTimeKey[] = …;
const char kBreakpadProcessIdKey[] = …;
const char kBreakpadProcessNameKey[] = …;
const char kBreakpadProcessUptimeKey[] = …;
#if BUILDFLAG(IS_WIN)
const wchar_t kCrashServerPipeName[] =
L"\\\\.\\pipe\\RemotingCrashService\\S-1-5-18";
base::win::ScopedHandle GetClientHandleForCrashServerPipe() {
const ACCESS_MASK kPipeAccessMask = FILE_READ_ATTRIBUTES | FILE_READ_DATA |
FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA |
SYNCHRONIZE;
const DWORD kPipeFlagsAndAttributes =
SECURITY_IDENTIFICATION | SECURITY_SQOS_PRESENT;
SECURITY_ATTRIBUTES security_attributes = {0};
security_attributes.bInheritHandle = true;
base::win::ScopedHandle handle(
CreateFile(kCrashServerPipeName, kPipeAccessMask,
0, &security_attributes, OPEN_EXISTING,
kPipeFlagsAndAttributes,
nullptr));
if (!handle.get()) {
PLOG(ERROR) << "Failed to open named pipe to crash server.";
}
return handle;
}
#endif
base::FilePath GetMinidumpDirectoryPath() { … }
bool CreateMinidumpDirectoryIfNeeded(const base::FilePath& minidump_directory) { … }
bool WriteMetadataForMinidump(const base::FilePath& minidump_file_path,
base::Value::Dict metadata) { … }
BreakpadHelper::BreakpadHelper() = default;
BreakpadHelper::~BreakpadHelper() = default;
bool BreakpadHelper::Initialize(const base::FilePath& minidump_directory) { … }
void BreakpadHelper::OnException() { … }
bool BreakpadHelper::OnMinidumpGenerated(
const base::FilePath& minidump_file_path) { … }
}