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

Unified Diff: sandbox/win/src/win_utils.cc

Issue 109843003: Replace wstring with string16 in sandbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « sandbox/win/src/win_utils.h ('k') | sandbox/win/src/win_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/win_utils.cc
diff --git a/sandbox/win/src/win_utils.cc b/sandbox/win/src/win_utils.cc
index cb366a6e75f88a7e63f5f951046f2b4f14c6ba9d..53a12a4f292d4da12435fd20ad3858f57feaddf5 100644
--- a/sandbox/win/src/win_utils.cc
+++ b/sandbox/win/src/win_utils.cc
@@ -33,7 +33,7 @@ const KnownReservedKey kKnownKey[] = {
};
// Returns true if the provided path points to a pipe.
-bool IsPipe(const std::wstring& path) {
+bool IsPipe(const base::string16& path) {
size_t start = 0;
if (0 == path.compare(0, sandbox::kNTPrefixLen, sandbox::kNTPrefix))
start = sandbox::kNTPrefixLen;
@@ -46,7 +46,7 @@ bool IsPipe(const std::wstring& path) {
namespace sandbox {
-HKEY GetReservedKeyFromName(const std::wstring& name) {
+HKEY GetReservedKeyFromName(const base::string16& name) {
for (size_t i = 0; i < arraysize(kKnownKey); ++i) {
if (name == kKnownKey[i].name)
return kKnownKey[i].key;
@@ -55,7 +55,7 @@ HKEY GetReservedKeyFromName(const std::wstring& name) {
return NULL;
}
-bool ResolveRegistryName(std::wstring name, std::wstring* resolved_name) {
+bool ResolveRegistryName(base::string16 name, base::string16* resolved_name) {
for (size_t i = 0; i < arraysize(kKnownKey); ++i) {
if (name.find(kKnownKey[i].name) == 0) {
HKEY key;
@@ -79,8 +79,8 @@ bool ResolveRegistryName(std::wstring name, std::wstring* resolved_name) {
return false;
}
-DWORD IsReparsePoint(const std::wstring& full_path, bool* result) {
- std::wstring path = full_path;
+DWORD IsReparsePoint(const base::string16& full_path, bool* result) {
+ base::string16 path = full_path;
// Remove the nt prefix.
if (0 == path.compare(0, kNTPrefixLen, kNTPrefix))
@@ -92,7 +92,7 @@ DWORD IsReparsePoint(const std::wstring& full_path, bool* result) {
return ERROR_SUCCESS;
}
- std::wstring::size_type last_pos = std::wstring::npos;
+ base::string16::size_type last_pos = base::string16::npos;
do {
path = path.substr(0, last_pos);
@@ -114,7 +114,7 @@ DWORD IsReparsePoint(const std::wstring& full_path, bool* result) {
}
last_pos = path.rfind(L'\\');
- } while (last_pos != std::wstring::npos);
+ } while (last_pos != base::string16::npos);
*result = false;
return ERROR_SUCCESS;
@@ -123,14 +123,14 @@ DWORD IsReparsePoint(const std::wstring& full_path, bool* result) {
// We get a |full_path| of the form \??\c:\some\foo\bar, and the name that
// we'll get from |handle| will be \device\harddiskvolume1\some\foo\bar.
bool SameObject(HANDLE handle, const wchar_t* full_path) {
- std::wstring path(full_path);
+ base::string16 path(full_path);
DCHECK_NT(!path.empty());
// Check if it's a pipe.
if (IsPipe(path))
return true;
- std::wstring actual_path;
+ base::string16 actual_path;
if (!GetPathFromHandle(handle, &actual_path))
return false;
@@ -145,7 +145,7 @@ bool SameObject(HANDLE handle, const wchar_t* full_path) {
// Look for the drive letter.
size_t colon_pos = path.find(L':');
- if (colon_pos == 0 || colon_pos == std::wstring::npos)
+ if (colon_pos == 0 || colon_pos == base::string16::npos)
return false;
// Only one character for the drive.
@@ -180,11 +180,11 @@ bool SameObject(HANDLE handle, const wchar_t* full_path) {
return true;
}
-bool ConvertToLongPath(const std::wstring& short_path,
- std::wstring* long_path) {
+bool ConvertToLongPath(const base::string16& short_path,
+ base::string16* long_path) {
// Check if the path is a NT path.
bool is_nt_path = false;
- std::wstring path = short_path;
+ base::string16 path = short_path;
if (0 == path.compare(0, kNTPrefixLen, kNTPrefix)) {
path = path.substr(kNTPrefixLen);
is_nt_path = true;
@@ -206,12 +206,12 @@ bool ConvertToLongPath(const std::wstring& short_path,
ERROR_PATH_NOT_FOUND == last_error ||
ERROR_INVALID_NAME == last_error)) {
// The file does not exist, but maybe a sub path needs to be expanded.
- std::wstring::size_type last_slash = path.rfind(L'\\');
- if (std::wstring::npos == last_slash)
+ base::string16::size_type last_slash = path.rfind(L'\\');
+ if (base::string16::npos == last_slash)
return false;
- std::wstring begin = path.substr(0, last_slash);
- std::wstring end = path.substr(last_slash);
+ base::string16 begin = path.substr(0, last_slash);
+ base::string16 end = path.substr(last_slash);
if (!ConvertToLongPath(begin, &begin))
return false;
@@ -236,7 +236,7 @@ bool ConvertToLongPath(const std::wstring& short_path,
return false;
}
-bool GetPathFromHandle(HANDLE handle, std::wstring* path) {
+bool GetPathFromHandle(HANDLE handle, base::string16* path) {
NtQueryObjectFunction NtQueryObject = NULL;
ResolveNTFunctionPtr("NtQueryObject", &NtQueryObject);
@@ -265,7 +265,8 @@ bool GetPathFromHandle(HANDLE handle, std::wstring* path) {
return true;
}
-bool GetNtPathFromWin32Path(const std::wstring& path, std::wstring* nt_path) {
+bool GetNtPathFromWin32Path(const base::string16& path,
+ base::string16* nt_path) {
HANDLE file = ::CreateFileW(path.c_str(), 0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
« no previous file with comments | « sandbox/win/src/win_utils.h ('k') | sandbox/win/src/win_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698