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

Side by Side Diff: chrome/installer/util/google_update_settings.cc

Issue 974423002: Revert of Profile_Metrics integration with Keystone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « chrome/installer/util/google_update_settings.h ('k') | no next file » | 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 "chrome/installer/util/google_update_settings.h" 5 #include "chrome/installer/util/google_update_settings.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits>
9 8
10 #include "base/command_line.h" 9 #include "base/command_line.h"
11 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
14 #include "base/path_service.h" 13 #include "base/path_service.h"
15 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
18 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 63 }
65 return true; 64 return true;
66 } 65 }
67 66
68 // Writes |value| into a user-specific value in the key |name| under 67 // Writes |value| into a user-specific value in the key |name| under
69 // |app_reg_data|'s ClientStateMedium key in HKLM along with the aggregation 68 // |app_reg_data|'s ClientStateMedium key in HKLM along with the aggregation
70 // method |aggregate|. This function is solely for use by system-level installs. 69 // method |aggregate|. This function is solely for use by system-level installs.
71 bool WriteGoogleUpdateAggregateNumKeyInternal( 70 bool WriteGoogleUpdateAggregateNumKeyInternal(
72 const AppRegistrationData& app_reg_data, 71 const AppRegistrationData& app_reg_data,
73 const wchar_t* const name, 72 const wchar_t* const name,
74 size_t value, 73 int value,
75 const wchar_t* const aggregate) { 74 const wchar_t* const aggregate) {
76 DCHECK(aggregate); 75 DCHECK(aggregate);
77 DCHECK(GoogleUpdateSettings::IsSystemInstall()); 76 DCHECK(GoogleUpdateSettings::IsSystemInstall());
78 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; 77 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY;
79 78
80 // Machine installs require each OS user to write a unique key under a 79 // Machine installs require each OS user to write a unique key under a
81 // named key in HKLM as well as an "aggregation" function that describes 80 // named key in HKLM as well as an "aggregation" function that describes
82 // how the values of multiple users are to be combined. 81 // how the values of multiple users are to be combined.
83 base::string16 uniquename; 82 base::string16 uniquename;
84 if (!base::win::GetUserSidString(&uniquename)) { 83 if (!base::win::GetUserSidString(&uniquename)) {
85 NOTREACHED(); 84 NOTREACHED();
86 return false; 85 return false;
87 } 86 }
88 87
89 base::string16 reg_path(app_reg_data.GetStateMediumKey()); 88 base::string16 reg_path(app_reg_data.GetStateMediumKey());
90 reg_path.append(L"\\"); 89 reg_path.append(L"\\");
91 reg_path.append(name); 90 reg_path.append(name);
92 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), kAccess); 91 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), kAccess);
93 key.WriteValue(google_update::kRegAggregateMethod, aggregate); 92 key.WriteValue(google_update::kRegAggregateMethod, aggregate);
94 93 return (key.WriteValue(uniquename.c_str(), value) == ERROR_SUCCESS);
95 DWORD dword_value = (value > std::numeric_limits<DWORD>::max() ?
96 std::numeric_limits<DWORD>::max() :
97 static_cast<DWORD>(value));
98 return (key.WriteValue(uniquename.c_str(), dword_value) == ERROR_SUCCESS);
99 } 94 }
100 95
101 // Updates a registry key |name| to be |value| for the given |app_reg_data|. 96 // Updates a registry key |name| to be |value| for the given |app_reg_data|.
102 bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, 97 bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data,
103 const wchar_t* const name, 98 const wchar_t* const name,
104 const base::string16& value) { 99 const base::string16& value) {
105 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; 100 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY;
106 RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), kAccess); 101 RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), kAccess);
107 return (key.WriteValue(name, value.c_str()) == ERROR_SUCCESS); 102 return (key.WriteValue(name, value.c_str()) == ERROR_SUCCESS);
108 } 103 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 539
545 if (value->SetMultiFailSuffix(false)) { 540 if (value->SetMultiFailSuffix(false)) {
546 VLOG(1) << "Removed multi-install failure key; switching to channel: " 541 VLOG(1) << "Removed multi-install failure key; switching to channel: "
547 << value->value(); 542 << value->value();
548 modified = true; 543 modified = true;
549 } 544 }
550 545
551 return modified; 546 return modified;
552 } 547 }
553 548
554 void GoogleUpdateSettings::UpdateProfileCounts(size_t profiles_active, 549 void GoogleUpdateSettings::UpdateProfileCounts(int profiles_active,
555 size_t profiles_signedin) { 550 int profiles_signedin) {
556 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 551 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
557 // System-level installs must write into the ClientStateMedium key shared by 552 // System-level installs must write into the ClientStateMedium key shared by
558 // all users. Special treatment is used to aggregate across those users. 553 // all users. Special treatment is used to aggregate across those users.
559 if (IsSystemInstall()) { 554 if (IsSystemInstall()) {
560 // Write the counts as ints that get aggregated across all users via 555 // Write the counts as ints that get aggregated across all users via
561 // summation for system-level installs. 556 // summation for system-level installs.
562 WriteGoogleUpdateAggregateNumKeyInternal( 557 WriteGoogleUpdateAggregateNumKeyInternal(
563 dist->GetAppRegistrationData(), 558 dist->GetAppRegistrationData(),
564 google_update::kRegProfilesActive, 559 google_update::kRegProfilesActive,
565 profiles_active, 560 profiles_active,
566 L"sum()"); 561 L"sum()");
567 WriteGoogleUpdateAggregateNumKeyInternal( 562 WriteGoogleUpdateAggregateNumKeyInternal(
568 dist->GetAppRegistrationData(), 563 dist->GetAppRegistrationData(),
569 google_update::kRegProfilesSignedIn, 564 google_update::kRegProfilesSignedIn,
570 profiles_signedin, 565 profiles_signedin,
571 L"sum()"); 566 L"sum()");
572 } else { 567 } else {
573 // Write the counts as strings since no aggregation function is needed for 568 // Write the counts as strings since no aggregation function is needed for
574 // user-level installs. 569 // user-level installs.
575 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(), 570 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(),
576 google_update::kRegProfilesActive, 571 google_update::kRegProfilesActive,
577 base::SizeTToString16(profiles_active)); 572 base::IntToString16(profiles_active));
578 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(), 573 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(),
579 google_update::kRegProfilesSignedIn, 574 google_update::kRegProfilesSignedIn,
580 base::SizeTToString16(profiles_signedin)); 575 base::IntToString16(profiles_signedin));
581 } 576 }
582 } 577 }
583 578
584 int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { 579 int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() {
585 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 580 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
586 base::string16 reg_path = dist->GetStateKey(); 581 base::string16 reg_path = dist->GetStateKey();
587 582
588 // Minimum access needed is to be able to write to this key. 583 // Minimum access needed is to be able to write to this key.
589 RegKey reg_key( 584 RegKey reg_key(
590 HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); 585 HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY);
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 } 958 }
964 959
965 // If the key or value was not present, return the empty string. 960 // If the key or value was not present, return the empty string.
966 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { 961 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) {
967 experiment_labels->clear(); 962 experiment_labels->clear();
968 return true; 963 return true;
969 } 964 }
970 965
971 return result == ERROR_SUCCESS; 966 return result == ERROR_SUCCESS;
972 } 967 }
OLDNEW
« no previous file with comments | « chrome/installer/util/google_update_settings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698