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

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

Issue 311893005: Can now adjust the number of retries before the blacklist is disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UMA_HISTOGRAM_COUNTS->UMA_HISTOGRAM_COUNTS_100 Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 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 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/metrics/field_trial.h" 6 #include "base/metrics/field_trial.h"
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/win/registry.h" 10 #include "base/win/registry.h"
(...skipping 22 matching lines...) Expand all
33 enum BlacklistSetupEventType { 33 enum BlacklistSetupEventType {
34 // The blacklist beacon has placed to enable the browser blacklisting. 34 // The blacklist beacon has placed to enable the browser blacklisting.
35 BLACKLIST_SETUP_ENABLED = 0, 35 BLACKLIST_SETUP_ENABLED = 0,
36 36
37 // The blacklist was successfully enabled. 37 // The blacklist was successfully enabled.
38 BLACKLIST_SETUP_RAN_SUCCESSFULLY, 38 BLACKLIST_SETUP_RAN_SUCCESSFULLY,
39 39
40 // The blacklist setup code failed to execute. 40 // The blacklist setup code failed to execute.
41 BLACKLIST_SETUP_FAILED, 41 BLACKLIST_SETUP_FAILED,
42 42
43 // The blacklist thunk setup code failed to execute. 43 // Deprecated. The blacklist thunk setup code failed to execute.
robertshield 2014/06/16 13:56:54 Mention in the CL description that these are being
krstnmnlsn 2014/06/16 17:37:43 Done.
44 BLACKLIST_THUNK_SETUP_FAILED, 44 BLACKLIST_THUNK_SETUP_FAILED,
45 45
46 // The blacklist interception code failed to execute. 46 // Deprecated. The blacklist interception code failed to execute.
47 BLACKLIST_INTERCEPTION_FAILED, 47 BLACKLIST_INTERCEPTION_FAILED,
48 48
49 // The blacklist was disabled for this run (after it failed too many times).
50 BLACKLIST_SETUP_DISABLED,
51
49 // Always keep this at the end. 52 // Always keep this at the end.
50 BLACKLIST_SETUP_EVENT_MAX, 53 BLACKLIST_SETUP_EVENT_MAX,
51 }; 54 };
52 55
53 void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) { 56 void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) {
54 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup", 57 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
55 blacklist_setup_event, 58 blacklist_setup_event,
56 BLACKLIST_SETUP_EVENT_MAX); 59 BLACKLIST_SETUP_EVENT_MAX);
57 } 60 }
58 61
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 136
134 // No point in trying to continue if the registry key isn't valid. 137 // No point in trying to continue if the registry key isn't valid.
135 if (!blacklist_registry_key.Valid()) 138 if (!blacklist_registry_key.Valid())
136 return; 139 return;
137 140
138 // Record the results of the last blacklist setup. 141 // Record the results of the last blacklist setup.
139 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX; 142 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX;
140 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState, &blacklist_state); 143 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState, &blacklist_state);
141 144
142 if (blacklist_state == blacklist::BLACKLIST_ENABLED) { 145 if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
146 // The blacklist was enabled successfully so we record the event (along with
147 // the number of failed previous attempts).
143 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY); 148 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY);
144 } else { 149 DWORD attempt_count = 0;
145 switch (blacklist_state) { 150 blacklist_registry_key.ReadValueDW(blacklist::kBeaconAttemptCount,
146 case blacklist::BLACKLIST_SETUP_RUNNING: 151 &attempt_count);
147 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED); 152 UMA_HISTOGRAM_COUNTS_100("Blacklist.RetryAttempts.Success", attempt_count);
148 break; 153 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_FAILED) {
149 case blacklist::BLACKLIST_THUNK_SETUP: 154 // We can set the state to disabled without checking that the maximum number
150 RecordBlacklistSetupEvent(BLACKLIST_THUNK_SETUP_FAILED); 155 // of attempts was exceeded because blacklist.cc has already done this.
151 break; 156 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED);
152 case blacklist::BLACKLIST_INTERCEPTING: 157 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
153 RecordBlacklistSetupEvent(BLACKLIST_INTERCEPTION_FAILED); 158 blacklist::BLACKLIST_DISABLED);
154 break; 159 } else if (blacklist_state == blacklist::BLACKLIST_DISABLED) {
155 } 160 RecordBlacklistSetupEvent(BLACKLIST_SETUP_DISABLED);
156
157 // Since some part of the blacklist failed, mark it as disabled
158 // for this version.
159 if (blacklist_state != blacklist::BLACKLIST_DISABLED) {
160 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
161 blacklist::BLACKLIST_DISABLED);
162 }
163 } 161 }
164 162
165 // Find the last recorded blacklist version. 163 // Find the last recorded blacklist version.
166 base::string16 blacklist_version; 164 base::string16 blacklist_version;
167 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion, 165 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion,
168 &blacklist_version); 166 &blacklist_version);
169 167
170 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) { 168 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) {
171 // The blacklist hasn't been enabled for this version yet, so enable it. 169 // The blacklist hasn't been enabled for this version yet, so enable it
170 // and reset the failure count to zero.
172 LONG set_version = blacklist_registry_key.WriteValue( 171 LONG set_version = blacklist_registry_key.WriteValue(
173 blacklist::kBeaconVersion, 172 blacklist::kBeaconVersion,
174 TEXT(CHROME_VERSION_STRING)); 173 TEXT(CHROME_VERSION_STRING));
175 174
176 LONG set_state = blacklist_registry_key.WriteValue( 175 LONG set_state = blacklist_registry_key.WriteValue(
177 blacklist::kBeaconState, 176 blacklist::kBeaconState,
178 blacklist::BLACKLIST_ENABLED); 177 blacklist::BLACKLIST_ENABLED);
179 178
179 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount,
180 static_cast<DWORD>(0));
181
180 // Only report the blacklist as getting setup when both registry writes 182 // Only report the blacklist as getting setup when both registry writes
181 // succeed, since otherwise the blacklist wasn't properly setup. 183 // succeed, since otherwise the blacklist wasn't properly setup.
182 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) 184 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
183 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); 185 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
184 } 186 }
185 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698