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

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

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add constructor Created 7 years, 1 month 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 base::win::ScopedHandle token; 58 HANDLE temp_handle;
59 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, 59 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY,
60 token.Receive())) { 60 &temp_handle)) {
61 ADD_FAILURE(); 61 ADD_FAILURE();
62 return false; 62 return false;
63 } 63 }
64 64
65 base::win::ScopedHandle token;
66 token.Set(temp_handle);
cpu_(ooo_6.6-7.5) 2013/11/22 02:42:53 and for ScopedHandle too?
rvargas (doing something else) 2013/11/25 19:53:27 Done.
67
65 // First get the size of the buffer needed for |privileges| below. 68 // First get the size of the buffer needed for |privileges| below.
66 DWORD size; 69 DWORD size;
67 EXPECT_FALSE(::GetTokenInformation(token, TokenPrivileges, NULL, 0, &size)); 70 EXPECT_FALSE(::GetTokenInformation(token, TokenPrivileges, NULL, 0, &size));
68 71
69 scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]); 72 scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]);
70 TOKEN_PRIVILEGES* privileges = 73 TOKEN_PRIVILEGES* privileges =
71 reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get()); 74 reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get());
72 75
73 if (!::GetTokenInformation(token, TokenPrivileges, privileges, size, &size)) { 76 if (!::GetTokenInformation(token, TokenPrivileges, privileges, size, &size)) {
74 ADD_FAILURE(); 77 ADD_FAILURE();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 BrowserDistribution::CHROME_FRAME)); 479 BrowserDistribution::CHROME_FRAME));
477 EXPECT_TRUE(chrome_frame.GetUsageStats(&usagestats)); 480 EXPECT_TRUE(chrome_frame.GetUsageStats(&usagestats));
478 EXPECT_EQ(1U, usagestats); 481 EXPECT_EQ(1U, usagestats);
479 EXPECT_EQ(L"2.0-dev", chrome_frame.channel().value()); 482 EXPECT_EQ(L"2.0-dev", chrome_frame.channel().value());
480 483
481 // Confirm that the binaries' channel no longer contains GCF. 484 // Confirm that the binaries' channel no longer contains GCF.
482 ASSERT_TRUE(binaries.Initialize(kSystemLevel, 485 ASSERT_TRUE(binaries.Initialize(kSystemLevel,
483 BrowserDistribution::CHROME_BINARIES)); 486 BrowserDistribution::CHROME_BINARIES));
484 EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value()); 487 EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value());
485 } 488 }
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