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

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.cc

Issue 2973873002: Primary histograms for InBrowserCleanerUI experiment (Closed)
Patch Set: Next round of reviews Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/safe_browsing/chrome_cleaner/settings_resetter_win.h" 5 #include "chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/barrier_closure.h" 13 #include "base/barrier_closure.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/callback_helpers.h" 15 #include "base/callback_helpers.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/metrics/histogram_macros.h"
18 #include "base/sequence_checker.h" 19 #include "base/sequence_checker.h"
19 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
20 #include "base/win/registry.h" 21 #include "base/win/registry.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/profile_resetter/profile_resetter.h" 23 #include "chrome/browser/profile_resetter/profile_resetter.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" 26 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h"
26 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "components/chrome_cleaner/public/constants/constants.h" 30 #include "components/chrome_cleaner/public/constants/constants.h"
30 #include "components/pref_registry/pref_registry_syncable.h" 31 #include "components/pref_registry/pref_registry_syncable.h"
31 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
32 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
33 34
34 namespace safe_browsing { 35 namespace safe_browsing {
35 36
36 namespace { 37 namespace {
37 38
39 // These values are used to send UMA information and are replicated in the
40 // histograms.xml file, so the order MUST NOT CHANGE.
41 enum TaggedProfileForResetting {
42 TAGGED_PROFILE_FOR_RESETTING_TAGGED = 0,
43
44 TAGGED_PROFILE_FOR_RESETTING_MAX,
45 };
46
38 // Returns the post-cleanup reset pending prefs for |profile|. 47 // Returns the post-cleanup reset pending prefs for |profile|.
39 bool ResetPending(Profile* profile) { 48 bool ResetPending(Profile* profile) {
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 49 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
41 DCHECK(PostCleanupSettingsResetter::IsEnabled()); 50 DCHECK(PostCleanupSettingsResetter::IsEnabled());
42 DCHECK(profile); 51 DCHECK(profile);
43 52
44 PrefService* prefs = profile->GetPrefs(); 53 PrefService* prefs = profile->GetPrefs();
45 return prefs->GetBoolean(prefs::kChromeCleanerResetPending); 54 return prefs->GetBoolean(prefs::kChromeCleanerResetPending);
46 } 55 }
47 56
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 PostCleanupSettingsResetter::Delegate::GetProfileResetter(Profile* profile) { 222 PostCleanupSettingsResetter::Delegate::GetProfileResetter(Profile* profile) {
214 return base::MakeUnique<ProfileResetter>(profile); 223 return base::MakeUnique<ProfileResetter>(profile);
215 } 224 }
216 225
217 void PostCleanupSettingsResetter::TagForResetting(Profile* profile) { 226 void PostCleanupSettingsResetter::TagForResetting(Profile* profile) {
218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 227 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
219 DCHECK(IsEnabled()); 228 DCHECK(IsEnabled());
220 DCHECK(profile); 229 DCHECK(profile);
221 230
222 RecordResetPending(true, profile); 231 RecordResetPending(true, profile);
232 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.TaggedProfileForResetting",
233 TAGGED_PROFILE_FOR_RESETTING_TAGGED,
234 TAGGED_PROFILE_FOR_RESETTING_MAX);
223 } 235 }
224 236
225 void PostCleanupSettingsResetter::ResetTaggedProfiles( 237 void PostCleanupSettingsResetter::ResetTaggedProfiles(
226 std::vector<Profile*> profiles, 238 std::vector<Profile*> profiles,
227 base::OnceClosure done_callback, 239 base::OnceClosure done_callback,
228 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate) { 240 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate) {
229 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 241 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
230 DCHECK(IsEnabled()); 242 DCHECK(IsEnabled());
231 DCHECK(delegate); 243 DCHECK(delegate);
232 244
233 std::vector<Profile*> profiles_to_reset; 245 std::vector<Profile*> profiles_to_reset;
234 if (!CopyProfilesToReset(profiles, &profiles_to_reset) || 246 if (!CopyProfilesToReset(profiles, &profiles_to_reset) ||
235 !CleanupCompletedFromRegistry()) { 247 !CleanupCompletedFromRegistry()) {
236 std::move(done_callback).Run(); 248 std::move(done_callback).Run();
237 return; 249 return;
238 } 250 }
239 251
252 UMA_HISTOGRAM_EXACT_LINEAR("SoftwareReporter.PostCleanupSettingsReset",
253 profiles_to_reset.size(), 10);
254
240 // The SettingsResetter object will self-delete once |done_callback| is 255 // The SettingsResetter object will self-delete once |done_callback| is
241 // invoked. 256 // invoked.
242 make_scoped_refptr(new SettingsResetter(std::move(profiles_to_reset), 257 make_scoped_refptr(new SettingsResetter(std::move(profiles_to_reset),
243 std::move(delegate), 258 std::move(delegate),
244 std::move(done_callback))) 259 std::move(done_callback)))
245 ->Run(); 260 ->Run();
246 } 261 }
247 262
248 // static 263 // static
249 void PostCleanupSettingsResetter::RegisterProfilePrefs( 264 void PostCleanupSettingsResetter::RegisterProfilePrefs(
250 user_prefs::PrefRegistrySyncable* registry) { 265 user_prefs::PrefRegistrySyncable* registry) {
251 DCHECK(registry); 266 DCHECK(registry);
252 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false); 267 registry->RegisterBooleanPref(prefs::kChromeCleanerResetPending, false);
253 } 268 }
254 269
255 } // namespace safe_browsing 270 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698