OLD | NEW |
---|---|
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 Loading... | |
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 // Deprecated. The blacklist thunk setup code failed to execute. | 43 // The blacklist thunk setup code failed. This is probably an indication |
44 // that something else patched that code first. | |
44 BLACKLIST_THUNK_SETUP_FAILED, | 45 BLACKLIST_THUNK_SETUP_FAILED, |
45 | 46 |
46 // Deprecated. The blacklist interception code failed to execute. | 47 // Deprecated. The blacklist interception code failed to execute. |
47 BLACKLIST_INTERCEPTION_FAILED, | 48 BLACKLIST_INTERCEPTION_FAILED, |
48 | 49 |
49 // The blacklist was disabled for this run (after it failed too many times). | 50 // The blacklist was disabled for this run (after it failed too many times). |
50 BLACKLIST_SETUP_DISABLED, | 51 BLACKLIST_SETUP_DISABLED, |
51 | 52 |
52 // Always keep this at the end. | 53 // Always keep this at the end. |
53 BLACKLIST_SETUP_EVENT_MAX, | 54 BLACKLIST_SETUP_EVENT_MAX, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 | 137 |
137 // No point in trying to continue if the registry key isn't valid. | 138 // No point in trying to continue if the registry key isn't valid. |
138 if (!blacklist_registry_key.Valid()) | 139 if (!blacklist_registry_key.Valid()) |
139 return; | 140 return; |
140 | 141 |
141 // Record the results of the last blacklist setup. | 142 // Record the results of the last blacklist setup. |
142 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX; | 143 DWORD blacklist_state = blacklist::BLACKLIST_STATE_MAX; |
143 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState, &blacklist_state); | 144 blacklist_registry_key.ReadValueDW(blacklist::kBeaconState, &blacklist_state); |
144 | 145 |
145 if (blacklist_state == blacklist::BLACKLIST_ENABLED) { | 146 if (blacklist_state == blacklist::BLACKLIST_ENABLED) { |
146 // The blacklist was enabled successfully so we record the event (along with | 147 // The blacklist setup didn't crash, so we report if it was enabled or not. |
147 // the number of failed previous attempts). | 148 if (blacklist::IsBlacklistInitialized()) { |
148 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY); | 149 RecordBlacklistSetupEvent(BLACKLIST_SETUP_RAN_SUCCESSFULLY); |
150 } else { | |
151 // The only way for the blacklist to be enabled, but not fully | |
152 // initialized is if the thunk setup failed. See blacklist.cc | |
krstnmnlsn
2014/06/18 18:36:41
I guess my comment on line 196 of blacklist.cc is
csharp
2014/06/18 19:03:00
Correct, I updated blacklist.cc
| |
153 // for more details. | |
154 RecordBlacklistSetupEvent(BLACKLIST_THUNK_SETUP_FAILED); | |
155 } | |
156 | |
157 // Regardless of if the blacklist was fully enabled or not, report how many | |
158 // times we had to try to set it up. | |
149 DWORD attempt_count = 0; | 159 DWORD attempt_count = 0; |
150 blacklist_registry_key.ReadValueDW(blacklist::kBeaconAttemptCount, | 160 blacklist_registry_key.ReadValueDW(blacklist::kBeaconAttemptCount, |
151 &attempt_count); | 161 &attempt_count); |
152 UMA_HISTOGRAM_COUNTS_100("Blacklist.RetryAttempts.Success", attempt_count); | 162 UMA_HISTOGRAM_COUNTS_100("Blacklist.RetryAttempts.Success", attempt_count); |
153 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_FAILED) { | 163 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_FAILED) { |
154 // We can set the state to disabled without checking that the maximum number | 164 // We can set the state to disabled without checking that the maximum number |
155 // of attempts was exceeded because blacklist.cc has already done this. | 165 // of attempts was exceeded because blacklist.cc has already done this. |
156 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED); | 166 RecordBlacklistSetupEvent(BLACKLIST_SETUP_FAILED); |
157 blacklist_registry_key.WriteValue(blacklist::kBeaconState, | 167 blacklist_registry_key.WriteValue(blacklist::kBeaconState, |
158 blacklist::BLACKLIST_DISABLED); | 168 blacklist::BLACKLIST_DISABLED); |
(...skipping 19 matching lines...) Expand all Loading... | |
178 | 188 |
179 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, | 189 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, |
180 static_cast<DWORD>(0)); | 190 static_cast<DWORD>(0)); |
181 | 191 |
182 // Only report the blacklist as getting setup when both registry writes | 192 // Only report the blacklist as getting setup when both registry writes |
183 // succeed, since otherwise the blacklist wasn't properly setup. | 193 // succeed, since otherwise the blacklist wasn't properly setup. |
184 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) | 194 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) |
185 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); | 195 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); |
186 } | 196 } |
187 } | 197 } |
OLD | NEW |