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

Side by Side Diff: rlz/win/lib/machine_id_win.cc

Issue 1856623002: convert //rlz to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « rlz/win/lib/machine_deal.cc ('k') | rlz/win/lib/process_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <windows.h> 5 #include <windows.h>
6 #include <Sddl.h> // For ConvertSidToStringSidW. 6 #include <Sddl.h> // For ConvertSidToStringSidW.
7
8 #include <memory>
7 #include <string> 9 #include <string>
8 10
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "rlz/lib/assert.h" 13 #include "rlz/lib/assert.h"
13 14
14 namespace rlz_lib { 15 namespace rlz_lib {
15 16
16 namespace { 17 namespace {
17 18
18 bool GetSystemVolumeSerialNumber(int* number) { 19 bool GetSystemVolumeSerialNumber(int* number) {
19 if (!number) 20 if (!number)
20 return false; 21 return false;
(...skipping 14 matching lines...) Expand all
35 NULL, 0)) 36 NULL, 0))
36 return false; 37 return false;
37 38
38 *number = number_local; 39 *number = number_local;
39 return true; 40 return true;
40 } 41 }
41 42
42 bool GetComputerSid(const wchar_t* account_name, SID* sid, DWORD sid_size) { 43 bool GetComputerSid(const wchar_t* account_name, SID* sid, DWORD sid_size) {
43 static const DWORD kStartDomainLength = 128; // reasonable to start with 44 static const DWORD kStartDomainLength = 128; // reasonable to start with
44 45
45 scoped_ptr<wchar_t[]> domain_buffer(new wchar_t[kStartDomainLength]); 46 std::unique_ptr<wchar_t[]> domain_buffer(new wchar_t[kStartDomainLength]);
46 DWORD domain_size = kStartDomainLength; 47 DWORD domain_size = kStartDomainLength;
47 DWORD sid_dword_size = sid_size; 48 DWORD sid_dword_size = sid_size;
48 SID_NAME_USE sid_name_use; 49 SID_NAME_USE sid_name_use;
49 50
50 BOOL success = ::LookupAccountNameW(NULL, account_name, sid, 51 BOOL success = ::LookupAccountNameW(NULL, account_name, sid,
51 &sid_dword_size, domain_buffer.get(), 52 &sid_dword_size, domain_buffer.get(),
52 &domain_size, &sid_name_use); 53 &domain_size, &sid_name_use);
53 if (!success && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) { 54 if (!success && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
54 // We could have gotten the insufficient buffer error because 55 // We could have gotten the insufficient buffer error because
55 // one or both of sid and szDomain was too small. Check for that 56 // one or both of sid and szDomain was too small. Check for that
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 *volume_id = 0; 99 *volume_id = 0;
99 if (!GetSystemVolumeSerialNumber(volume_id)) { 100 if (!GetSystemVolumeSerialNumber(volume_id)) {
100 ASSERT_STRING("GetMachineId: Failed to retrieve volume serial number"); 101 ASSERT_STRING("GetMachineId: Failed to retrieve volume serial number");
101 *volume_id = 0; 102 *volume_id = 0;
102 } 103 }
103 104
104 return true; 105 return true;
105 } 106 }
106 107
107 } // namespace rlz_lib 108 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « rlz/win/lib/machine_deal.cc ('k') | rlz/win/lib/process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698