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

Side by Side Diff: chrome/installer/setup/setup_util_unittest.cc

Issue 90963002: Revert of Base: Remove Receive() from ScopedHandle. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/installer/setup/setup_util_unittest.h" 5 #include "chrome/installer/setup/setup_util_unittest.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 }; 48 };
49 49
50 // The privilege tested in ScopeTokenPrivilege tests below. 50 // The privilege tested in ScopeTokenPrivilege tests below.
51 // Use SE_RESTORE_NAME as it is one of the many privileges that is available, 51 // Use SE_RESTORE_NAME as it is one of the many privileges that is available,
52 // but not enabled by default on processes running at high integrity. 52 // but not enabled by default on processes running at high integrity.
53 static const wchar_t kTestedPrivilege[] = SE_RESTORE_NAME; 53 static const wchar_t kTestedPrivilege[] = SE_RESTORE_NAME;
54 54
55 // Returns true if the current process' token has privilege |privilege_name| 55 // Returns true if the current process' token has privilege |privilege_name|
56 // enabled. 56 // enabled.
57 bool CurrentProcessHasPrivilege(const wchar_t* privilege_name) { 57 bool CurrentProcessHasPrivilege(const wchar_t* privilege_name) {
58 HANDLE temp_handle; 58 base::win::ScopedHandle token;
59 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, 59 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY,
60 &temp_handle)) { 60 token.Receive())) {
61 ADD_FAILURE(); 61 ADD_FAILURE();
62 return false; 62 return false;
63 } 63 }
64 64
65 base::win::ScopedHandle token(temp_handle);
66
67 // First get the size of the buffer needed for |privileges| below. 65 // First get the size of the buffer needed for |privileges| below.
68 DWORD size; 66 DWORD size;
69 EXPECT_FALSE(::GetTokenInformation(token, TokenPrivileges, NULL, 0, &size)); 67 EXPECT_FALSE(::GetTokenInformation(token, TokenPrivileges, NULL, 0, &size));
70 68
71 scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]); 69 scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]);
72 TOKEN_PRIVILEGES* privileges = 70 TOKEN_PRIVILEGES* privileges =
73 reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get()); 71 reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get());
74 72
75 if (!::GetTokenInformation(token, TokenPrivileges, privileges, size, &size)) { 73 if (!::GetTokenInformation(token, TokenPrivileges, privileges, size, &size)) {
76 ADD_FAILURE(); 74 ADD_FAILURE();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 BrowserDistribution::CHROME_FRAME)); 476 BrowserDistribution::CHROME_FRAME));
479 EXPECT_TRUE(chrome_frame.GetUsageStats(&usagestats)); 477 EXPECT_TRUE(chrome_frame.GetUsageStats(&usagestats));
480 EXPECT_EQ(1U, usagestats); 478 EXPECT_EQ(1U, usagestats);
481 EXPECT_EQ(L"2.0-dev", chrome_frame.channel().value()); 479 EXPECT_EQ(L"2.0-dev", chrome_frame.channel().value());
482 480
483 // Confirm that the binaries' channel no longer contains GCF. 481 // Confirm that the binaries' channel no longer contains GCF.
484 ASSERT_TRUE(binaries.Initialize(kSystemLevel, 482 ASSERT_TRUE(binaries.Initialize(kSystemLevel,
485 BrowserDistribution::CHROME_BINARIES)); 483 BrowserDistribution::CHROME_BINARIES));
486 EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value()); 484 EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value());
487 } 485 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_util.cc ('k') | chrome/installer/test/alternate_version_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698