summaryrefslogtreecommitdiffstats
path: root/rlz/win
diff options
context:
space:
mode:
authoryiyaoliu@chromium.org <yiyaoliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-10 18:22:14 +0000
committeryiyaoliu@chromium.org <yiyaoliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-10 18:22:14 +0000
commitca13fbf58d6c2bd5734bee3f66f779f45b83ec7f (patch)
tree2bbb50742902a340a700a8d37fae04a8992b0b76 /rlz/win
parentd77a71ce2392efa9bac9153dbb9a8f11319c11de (diff)
downloadchromium_src-ca13fbf58d6c2bd5734bee3f66f779f45b83ec7f.zip
chromium_src-ca13fbf58d6c2bd5734bee3f66f779f45b83ec7f.tar.gz
chromium_src-ca13fbf58d6c2bd5734bee3f66f779f45b83ec7f.tar.bz2
Make GetUserName() return more specific error code, so that we could know how the function failed.
However, a lot user at under version 33 or lower, which means they don't auto-update Chrome? I'm not sure if this new piece of code will get to the affected users. BUG=334675 Review URL: https://codereview.chromium.org/177843009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'rlz/win')
-rw-r--r--rlz/win/lib/process_info.cc23
1 files changed, 9 insertions, 14 deletions
diff --git a/rlz/win/lib/process_info.cc b/rlz/win/lib/process_info.cc
index 2511f54a..d17b4fe 100644
--- a/rlz/win/lib/process_info.cc
+++ b/rlz/win/lib/process_info.cc
@@ -33,8 +33,8 @@ HRESULT GetCurrentUser(std::wstring* name,
// In which case, search for and use the process handle of a running
// Explorer.exe.)
HANDLE token;
- if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token))
- return E_FAIL;
+
+ CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token));
base::win::ScopedHandle scoped_process_token(token);
@@ -49,13 +49,10 @@ HRESULT GetCurrentUser(std::wstring* name,
CHECK(!result && err == ERROR_INSUFFICIENT_BUFFER);
token_user_bytes.reset(new char[token_user_size]);
- if (!token_user_bytes.get())
- return E_OUTOFMEMORY;
+ CHECK(token_user_bytes.get());
- if (!::GetTokenInformation(token, TokenUser, token_user_bytes.get(),
- token_user_size, &token_user_size2)) {
- return E_FAIL;
- }
+ CHECK(::GetTokenInformation(token, TokenUser, token_user_bytes.get(),
+ token_user_size, &token_user_size2));
WCHAR user_name[UNLEN + 1]; // max username length
WCHAR domain_name[UNLEN + 1];
@@ -64,13 +61,11 @@ HRESULT GetCurrentUser(std::wstring* name,
SID_NAME_USE sid_type;
TOKEN_USER* token_user =
reinterpret_cast<TOKEN_USER*>(token_user_bytes.get());
- if (!token_user)
- return E_FAIL;
+ CHECK(token_user);
+
PSID user_sid = token_user->User.Sid;
- if (!::LookupAccountSidW(NULL, user_sid, user_name, &user_name_size,
- domain_name, &domain_name_size, &sid_type)) {
- return E_FAIL;
- }
+ CHECK(::LookupAccountSidW(NULL, user_sid, user_name, &user_name_size,
+ domain_name, &domain_name_size, &sid_type));
if (name != NULL) {
*name = user_name;