From 4a5c529d37e17c3ea7def8aa7de2507a5548d84d Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Fri, 11 Mar 2016 10:42:14 -0800 Subject: crashpad win: Ensure database dir exists on first run Crashpad will only create one level of directory for its database storage. On Windows, the target is %LOCALAPPDATA%\Google\Chrome\User Data\Crashpad. However, on first run when Crashpad is initialized, "User Data" will not yet have been created. We don't want to move Crashpad initialization later in startup, so we instead create the directory if it does not exist. Note that this is calling file_util::CreateDirectory(), rather than CreateDirectoryW() which means the full parent tree will be created, not just the last entry in the path. R=thakis@chromium.org,wfh@chromium.org TEST=remove local user data dir, install chrome, confirm that chrome --process-type=crashpad-handler exists on first run BUG=591504 Review URL: https://codereview.chromium.org/1774573002 Cr-Commit-Position: refs/heads/master@{#379676} (cherry picked from commit 92905ef36a30be9be9041d8ee07ccd6e7ca45d64) Review URL: https://codereview.chromium.org/1790493003 . Cr-Commit-Position: refs/branch-heads/2623@{#613} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907} --- chrome/common/chrome_paths_win.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc index 37a262c..4713a0a 100644 --- a/chrome/common/chrome_paths_win.cc +++ b/chrome/common/chrome_paths_win.cc @@ -11,6 +11,7 @@ #include #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/path_service.h" #include "base/win/scoped_co_mem.h" #include "chrome/common/chrome_constants.h" @@ -124,6 +125,10 @@ bool GetDefaultCrashDumpLocation(base::FilePath* crash_dir) { // Windows. See https://crbug.com/564398. if (!GetDefaultUserDataDirectory(crash_dir)) return false; + // We have to make sure the user data dir exists on first run. See + // http://crbug.com/591504. + if (!PathExists(*crash_dir) && !CreateDirectory(*crash_dir)) + return false; *crash_dir = crash_dir->Append(FILE_PATH_LITERAL("Crashpad")); return true; } -- cgit v1.1