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

Side by Side Diff: chrome/browser/chrome_elf_init_win.cc

Issue 133923002: Use a Finch Experiment to control the Browser Blacklist (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix unittests Created 6 years, 11 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/browser/chrome_elf_init_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/metrics/field_trial.h"
6 #include "base/metrics/histogram.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "base/win/registry.h"
9 #include "chrome/browser/chrome_elf_init_win.h"
10 #include "chrome_elf/blacklist/blacklist.h"
11 #include "version.h" // NOLINT
12
13 namespace {
14
15 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist";
16 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
17
18 // This enum is used to define the buckets for an enumerated UMA histogram.
19 // Hence,
20 // (a) existing enumerated constants should never be deleted or reordered, and
21 // (b) new constants should only be appended in front of
22 // BLACKLIST_SETUP_EVENT_MAX.
23 enum BlacklistSetupEventType {
24 // The blacklist beacon has placed to enable the browser blacklisting.
25 BLACKLIST_SETUP_ENABLED = 0,
26
27 // The blacklist was successfully enabled.
28 BLACKLIST_SETUP_RAN_SUCCESSFULLY,
29
30 // The blacklist setup code failed to execute.
31 BLACKLIST_SETUP_FAILED,
32
33 // Always keep this at the end.
34 BLACKLIST_SETUP_EVENT_MAX,
35 };
36
37 void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) {
38 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
39 blacklist_setup_event,
40 BLACKLIST_SETUP_EVENT_MAX);
41 }
42
43 } // namespace
44
45 void InitializeChromeElf() {
46 if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) ==
47 kBrowserBlacklistTrialEnabledGroupName) {
48 BrowserBlacklistBeaconSetup();
49 } else {
50 // Disable the blacklist for all future runs by removing the beacon.
51 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER);
52 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath);
53 }
54 }
55
56 void BrowserBlacklistBeaconSetup() {
57 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER,
58 blacklist::kRegistryBeaconPath,
59 KEY_QUERY_VALUE | KEY_SET_VALUE);
60
61 // Find the last recorded blacklist version.
62 base::string16 blacklist_version;
63 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion,
64 &blacklist_version);
65
66 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) {
67 // The blacklist hasn't run for this version yet, so enable it.
68 LONG set_version = blacklist_registry_key.WriteValue(
69 blacklist::kBeaconVersion,
70 TEXT(CHROME_VERSION_STRING));
71
72 LONG set_state = blacklist_registry_key.WriteValue(
73 blacklist::kBeaconState,
74 blacklist::BLACKLIST_ENABLED);
75
76 // Only report the blacklist as getting setup when both registry writes
77 // succeed, since otherwise the blacklist wasn't properly setup.
78 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
79 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
80
81 // Don't try to record if the blacklist setup succeeded or failed in the
82 // run since it could have been from either this version or the previous
83 // version (since crashes occur before we set the version in the registry).
84 } else {
85 // The blacklist version didn't change, so record the results of the
86 // latest setup.
87 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX;
88 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState,
89 &blacklist_state);
90
91 // Record the results of the latest blacklist setup.
92 if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
93 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY);
94 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_RUNNING) {
95 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED);
96
97 // Since the setup failed, mark the blacklist as disabled so we don't
98 // try it again for this version.
99 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
100 blacklist::BLACKLIST_DISABLED);
101 }
102 }
103 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_elf_init_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698