Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2798)

Unified Diff: base/base_paths_win.cc

Issue 1481703002: win: Move Crashpad all into chrome.exe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: breakpad_dump_location, revert test change Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/base_paths_win.cc
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
index 58f925f7e1f69d06529a1f7489faea656ce7285b..2e0eededdafd1823d192deec5b8e8de21de62e69 100644
--- a/base/base_paths_win.cc
+++ b/base/base_paths_win.cc
@@ -20,6 +20,57 @@ using base::FilePath;
namespace base {
+bool GetLocalAppData(FilePath* result) {
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer)))
+ return false;
+ *result = FilePath(system_buffer);
+ return true;
+}
+
+bool GetFileExe(FilePath* result) {
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ if (GetModuleFileName(NULL, system_buffer, MAX_PATH) == 0)
+ return false;
+ *result = FilePath(system_buffer);
+ return true;
+}
+
+bool GetFileModule(FilePath* result) {
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ // The resource containing module is assumed to be the one that this code
+ // lives in, whether that's a dll or exe.
+ HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
+ if (GetModuleFileName(this_module, system_buffer, MAX_PATH) == 0)
+ return false;
+ *result = FilePath(system_buffer);
+ return true;
+}
+
+bool GetProgramFilesX86(FilePath* result) {
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer)))
+ return false;
+ *result = FilePath(system_buffer);
+ return true;
+}
+
+bool GetProgramFiles(FilePath* result) {
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer)))
+ return false;
+ *result = FilePath(system_buffer);
+ return true;
+}
+
bool PathProviderWin(int key, FilePath* result) {
// We need to go compute the value. It would be nice to support paths with
// names longer than MAX_PATH, but the system functions don't seem to be
@@ -32,19 +83,13 @@ bool PathProviderWin(int key, FilePath* result) {
FilePath cur;
switch (key) {
case base::FILE_EXE:
- if (GetModuleFileName(NULL, system_buffer, MAX_PATH) == 0)
+ if (!GetFileExe(&cur))
return false;
- cur = FilePath(system_buffer);
break;
- case base::FILE_MODULE: {
- // the resource containing module is assumed to be the one that
- // this code lives in, whether that's a dll or exe
- HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
- if (GetModuleFileName(this_module, system_buffer, MAX_PATH) == 0)
+ case base::FILE_MODULE:
+ if (!GetFileModule(&cur))
return false;
- cur = FilePath(system_buffer);
break;
- }
case base::DIR_WINDOWS:
GetWindowsDirectory(system_buffer, MAX_PATH);
cur = FilePath(system_buffer);
@@ -56,18 +101,14 @@ bool PathProviderWin(int key, FilePath* result) {
case base::DIR_PROGRAM_FILESX86:
if (base::win::OSInfo::GetInstance()->architecture() !=
base::win::OSInfo::X86_ARCHITECTURE) {
- if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL,
- SHGFP_TYPE_CURRENT, system_buffer)))
+ if (!GetProgramFilesX86(&cur))
return false;
- cur = FilePath(system_buffer);
break;
}
// Fall through to base::DIR_PROGRAM_FILES if we're on an X86 machine.
case base::DIR_PROGRAM_FILES:
- if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
- SHGFP_TYPE_CURRENT, system_buffer)))
+ if (!GetProgramFiles(&cur))
return false;
- cur = FilePath(system_buffer);
break;
case base::DIR_PROGRAM_FILES6432:
#if !defined(_WIN64)
@@ -121,10 +162,8 @@ bool PathProviderWin(int key, FilePath* result) {
cur = FilePath(system_buffer);
break;
case base::DIR_LOCAL_APP_DATA:
- if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
- SHGFP_TYPE_CURRENT, system_buffer)))
+ if (!GetLocalAppData(&cur))
return false;
- cur = FilePath(system_buffer);
break;
case base::DIR_SOURCE_ROOT: {
FilePath executableDir;

Powered by Google App Engine
This is Rietveld 408576698