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

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: Corrected code so that it actually works as intended. Updated unit tests. 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 21 matching lines...) Expand all
32 enum BlacklistSetupEventType { 32 enum BlacklistSetupEventType {
33 // The blacklist beacon has placed to enable the browser blacklisting. 33 // The blacklist beacon has placed to enable the browser blacklisting.
34 BLACKLIST_SETUP_ENABLED = 0, 34 BLACKLIST_SETUP_ENABLED = 0,
35 35
36 // The blacklist was successfully enabled. 36 // The blacklist was successfully enabled.
37 BLACKLIST_SETUP_RAN_SUCCESSFULLY, 37 BLACKLIST_SETUP_RAN_SUCCESSFULLY,
38 38
39 // The blacklist setup code failed to execute. 39 // The blacklist setup code failed to execute.
40 BLACKLIST_SETUP_FAILED, 40 BLACKLIST_SETUP_FAILED,
41 41
42 // The blacklist thunk setup code failed to execute. 42 // Depreciated. The blacklist thunk setup code failed to execute.
43 BLACKLIST_THUNK_SETUP_FAILED, 43 BLACKLIST_THUNK_SETUP_FAILED,
44 44
45 // The blacklist interception code failed to execute. 45 // Depreciated. The blacklist interception code failed to execute.
46 BLACKLIST_INTERCEPTION_FAILED, 46 BLACKLIST_INTERCEPTION_FAILED,
47 47
48 // The blacklist was disabled for this run.
csharp 2014/06/10 14:07:02 .. because it has failed too many time (explain wh
krstnmnlsn 2014/06/10 22:03:26 Done.
49 BLACKLIST_SETUP_DISABLED,
50
48 // Always keep this at the end. 51 // Always keep this at the end.
49 BLACKLIST_SETUP_EVENT_MAX, 52 BLACKLIST_SETUP_EVENT_MAX,
50 }; 53 };
51 54
52 void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) { 55 void RecordBlacklistSetupEvent(BlacklistSetupEventType blacklist_setup_event) {
53 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup", 56 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
54 blacklist_setup_event, 57 blacklist_setup_event,
55 BLACKLIST_SETUP_EVENT_MAX); 58 BLACKLIST_SETUP_EVENT_MAX);
56 } 59 }
57 60
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 113
111 // No point in trying to continue if the registry key isn't valid. 114 // No point in trying to continue if the registry key isn't valid.
112 if (!blacklist_registry_key.Valid()) 115 if (!blacklist_registry_key.Valid())
113 return; 116 return;
114 117
115 // Record the results of the last blacklist setup. 118 // Record the results of the last blacklist setup.
116 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX; 119 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX;
117 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState, &blacklist_state); 120 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState, &blacklist_state);
118 121
119 if (blacklist_state == blacklist::BLACKLIST_ENABLED) { 122 if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
123 // The blacklist was enabled successfully so we record the event (along with
124 // the number of failed previous attempts).
120 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY); 125 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY);
121 } else { 126 DWORD attempt_count = 0;
122 switch (blacklist_state) { 127 blacklist_registry_key.ReadValueDW(blacklist::kBeaconAttemptCount,
123 case blacklist::BLACKLIST_SETUP_RUNNING: 128 &attempt_count);
124 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED); 129 UMA_HISTOGRAM_COUNTS("Blacklist.RetryWorked", attempt_count);
125 break; 130 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_FAILED) {
126 case blacklist::BLACKLIST_THUNK_SETUP: 131 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED);
csharp 2014/06/10 14:07:02 Probably worth adding a comment here saying he don
krstnmnlsn 2014/06/10 22:03:26 Done.
127 RecordBlacklistSetupEvent(BLACKLIST_THUNK_SETUP_FAILED); 132 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
128 break; 133 blacklist::BLACKLIST_DISABLED);
129 case blacklist::BLACKLIST_INTERCEPTING: 134 } else if (blacklist_state == blacklist::BLACKLIST_DISABLED) {
130 RecordBlacklistSetupEvent(BLACKLIST_INTERCEPTION_FAILED); 135 RecordBlacklistSetupEvent(BLACKLIST_SETUP_DISABLED);
131 break;
132 }
133
134 // Since some part of the blacklist failed, mark it as disabled
135 // for this version.
136 if (blacklist_state != blacklist::BLACKLIST_DISABLED) {
137 blacklist_registry_key.WriteValue(blacklist::kBeaconState,
138 blacklist::BLACKLIST_DISABLED);
139 }
140 } 136 }
141 137
142 // Find the last recorded blacklist version. 138 // Find the last recorded blacklist version.
143 base::string16 blacklist_version; 139 base::string16 blacklist_version;
144 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion, 140 blacklist_registry_key.ReadValue(blacklist::kBeaconVersion,
145 &blacklist_version); 141 &blacklist_version);
146 142
147 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) { 143 if (blacklist_version != TEXT(CHROME_VERSION_STRING)) {
148 // The blacklist hasn't been enabled for this version yet, so enable it. 144 // The blacklist hasn't been enabled for this version yet, so enable it
145 // and reset the failure count to zero.
149 LONG set_version = blacklist_registry_key.WriteValue( 146 LONG set_version = blacklist_registry_key.WriteValue(
150 blacklist::kBeaconVersion, 147 blacklist::kBeaconVersion,
151 TEXT(CHROME_VERSION_STRING)); 148 TEXT(CHROME_VERSION_STRING));
152 149
153 LONG set_state = blacklist_registry_key.WriteValue( 150 LONG set_state = blacklist_registry_key.WriteValue(
154 blacklist::kBeaconState, 151 blacklist::kBeaconState,
155 blacklist::BLACKLIST_ENABLED); 152 blacklist::BLACKLIST_ENABLED);
156 153
154 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount,
155 static_cast<DWORD>(0));
156
157 // Only report the blacklist as getting setup when both registry writes 157 // Only report the blacklist as getting setup when both registry writes
158 // succeed, since otherwise the blacklist wasn't properly setup. 158 // succeed, since otherwise the blacklist wasn't properly setup.
159 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) 159 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
160 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); 160 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
161 } 161 }
162 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698