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

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

Issue 120963002: Use a Finch Experiment to control the Browser Blacklist (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Only report when the version is the same 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 2013 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/common/chrome_version_info.h"
11 #include "chrome_elf/blacklist/blacklist.h"
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 SetupChromeElfInitialization() {
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_READ | KEY_WRITE);
60
61 // Find the last recorded blacklist version and the current version.
62 std::wstring blacklist_version(L"");
robertshield 2014/01/02 20:46:20 Use base::string16 rather than wstring. Also, don
csharp 2014/01/02 21:57:59 Hmm, I thought I got a compile error when I tried
63 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion,
64 &blacklist_version);
65
66 chrome::VersionInfo version_info;
67 base::string16 current_version = base::UTF8ToUTF16(version_info.Version());
68 if (blacklist_version != current_version) {
69 // The blacklist hasn't run for this version yet, so enable it.
70 blacklist_registry_key.WriteValue(blacklist::kBeaconVersion,
71 current_version.c_str());
72
73 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
74 blacklist::BLACKLIST_ENABLED);
75
76 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
77
78 // Don't try to record the results of the last setup since it could have
robertshield 2014/01/02 20:46:20 explicitly state here that by "results" we mean ei
csharp 2014/01/02 21:57:59 Done.
79 // been from either this version or the previous version (since crashes
80 // occur before we set the version in the registry).
81 } else {
82 // The blacklist version didn't change, so record the results of the
83 // latest setup.
84 DWORD blacklist_state = 0;
robertshield 2014/01/02 20:46:20 = BLACKLIST_SETUP_ENABLED;
csharp 2014/01/02 21:57:59 We are reading the value here, not writing. Settin
robertshield 2014/01/03 03:21:42 0 isn't a dummy value though, it's a legitimate en
85 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState,
86 &blacklist_state);
87
88 // Record the results of the latest blacklist setup.
89 if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
90 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY);
91 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_RUNNING) {
92 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED);
93
94 // Since the setup failed, mark the blacklist as disabled so we don't
95 // try it again for this version.
96 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
97 blacklist::BLACKLIST_DISABLED);
98 }
99 }
100 }
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