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

Side by Side Diff: chrome/install_static/install_util.cc

Issue 2507263002: Make nt_registry Create/OpenRegKey return a scoped object
Patch Set: fixes Created 3 years, 10 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 | « no previous file | chrome_elf/blacklist/blacklist.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/install_static/install_util.h" 5 #include "chrome/install_static/install_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // If reading the value failed, treat it as though sampling isn't in effect, 343 // If reading the value failed, treat it as though sampling isn't in effect,
344 // implicitly meaning this install is in the sample. 344 // implicitly meaning this install is in the sample.
345 return true; 345 return true;
346 } 346 }
347 return out_value == 1; 347 return out_value == 1;
348 } 348 }
349 349
350 bool SetCollectStatsInSample(bool in_sample) { 350 bool SetCollectStatsInSample(bool in_sample) {
351 std::wstring registry_path = GetChromeInstallRegistryPath(); 351 std::wstring registry_path = GetChromeInstallRegistryPath();
352 352
353 HANDLE key_handle = INVALID_HANDLE_VALUE; 353 nt::ScopedHANDLE key = nt::CreateRegKey(nt::HKCU, registry_path.c_str(),
354 if (!nt::CreateRegKey(nt::HKCU, registry_path.c_str(), 354 KEY_SET_VALUE | KEY_WOW64_32KEY);
355 KEY_SET_VALUE | KEY_WOW64_32KEY, &key_handle)) { 355 if (!key.is_valid())
grt (UTC plus 2) 2017/02/08 21:44:02 wdyt of an explicit operator bool so this can be w
356 return false; 356 return false;
357 }
358 357
359 bool success = nt::SetRegValueDWORD(key_handle, kRegValueChromeStatsSample, 358 return nt::SetRegValueDWORD(key.get(), kRegValueChromeStatsSample,
grt (UTC plus 2) 2017/02/08 21:44:02 i think that return key.SetRegValueDWORD(...); i
360 in_sample ? 1 : 0); 359 in_sample ? 1 : 0);
361 nt::CloseRegKey(key_handle);
362 return success;
363 } 360 }
364 361
365 // Appends "[kCompanyPathName\]kProductPathName[install_suffix]" to |path|, 362 // Appends "[kCompanyPathName\]kProductPathName[install_suffix]" to |path|,
366 // returning a reference to |path|. 363 // returning a reference to |path|.
367 std::wstring& AppendChromeInstallSubDirectory(const InstallConstants& mode, 364 std::wstring& AppendChromeInstallSubDirectory(const InstallConstants& mode,
368 bool include_suffix, 365 bool include_suffix,
369 std::wstring* path) { 366 std::wstring* path) {
370 if (*kCompanyPathName) { 367 if (*kCompanyPathName) {
371 path->append(kCompanyPathName); 368 path->append(kCompanyPathName);
372 path->push_back(L'\\'); 369 path->push_back(L'\\');
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 case ChannelStrategy::ADDITIONAL_PARAMETERS: 745 case ChannelStrategy::ADDITIONAL_PARAMETERS:
749 return ChannelFromAdditionalParameters(mode, system_level); 746 return ChannelFromAdditionalParameters(mode, system_level);
750 case ChannelStrategy::FIXED: 747 case ChannelStrategy::FIXED:
751 return mode.default_channel_name; 748 return mode.default_channel_name;
752 } 749 }
753 750
754 return std::wstring(); 751 return std::wstring();
755 } 752 }
756 753
757 } // namespace install_static 754 } // namespace install_static
OLDNEW
« no previous file with comments | « no previous file | chrome_elf/blacklist/blacklist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698