OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/password_manager/password_manager_metrics_util.h" | 5 #include "chrome/browser/password_manager/password_manager_metrics_util.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 {"tumblr.com", {4, 8, 10, 12, 13, 15, 16, 18, 19, 20}}, | 50 {"tumblr.com", {4, 8, 10, 12, 13, 15, 16, 18, 19, 20}}, |
51 }; | 51 }; |
52 const size_t kNumDomains = arraysize(kDomainMapping); | 52 const size_t kNumDomains = arraysize(kDomainMapping); |
53 | 53 |
54 // For every monitored domain, this function chooses which of the groups | 54 // For every monitored domain, this function chooses which of the groups |
55 // containing that domain should be used for reporting. That number is chosen | 55 // containing that domain should be used for reporting. That number is chosen |
56 // randomly and stored in the user's preferences. | 56 // randomly and stored in the user's preferences. |
57 size_t GetGroupIndex(size_t domain_index, PrefService* pref_service) { | 57 size_t GetGroupIndex(size_t domain_index, PrefService* pref_service) { |
58 DCHECK_LT(domain_index, kNumDomains); | 58 DCHECK_LT(domain_index, kNumDomains); |
59 | 59 |
60 const ListValue* group_indices = | 60 const base::ListValue* group_indices = |
61 pref_service->GetList(prefs::kPasswordManagerGroupsForDomains); | 61 pref_service->GetList(prefs::kPasswordManagerGroupsForDomains); |
62 int result = 0; | 62 int result = 0; |
63 if (!group_indices->GetInteger(domain_index, &result)) { | 63 if (!group_indices->GetInteger(domain_index, &result)) { |
64 ListPrefUpdate group_indices_updater( | 64 ListPrefUpdate group_indices_updater( |
65 pref_service, prefs::kPasswordManagerGroupsForDomains); | 65 pref_service, prefs::kPasswordManagerGroupsForDomains); |
66 // This value has not been generated yet. | 66 // This value has not been generated yet. |
67 result = | 67 result = |
68 base::checked_numeric_cast<int>(base::RandGenerator(kGroupsPerDomain)); | 68 base::checked_numeric_cast<int>(base::RandGenerator(kGroupsPerDomain)); |
69 group_indices_updater->Set(domain_index, new FundamentalValue(result)); | 69 group_indices_updater->Set(domain_index, new FundamentalValue(result)); |
70 } | 70 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 std::string GroupIdToString(size_t group_id) { | 111 std::string GroupIdToString(size_t group_id) { |
112 DCHECK_LE(group_id, kNumGroups); | 112 DCHECK_LE(group_id, kNumGroups); |
113 if (group_id > 0) | 113 if (group_id > 0) |
114 return "group_" + base::IntToString(group_id); | 114 return "group_" + base::IntToString(group_id); |
115 return std::string(); | 115 return std::string(); |
116 } | 116 } |
117 | 117 |
118 } // namespace password_manager_metrics_util | 118 } // namespace password_manager_metrics_util |
OLD | NEW |