Skip to content

Commit

Permalink
Reorder GenerateStateFromBeaconAndAttemptCount.
Browse files Browse the repository at this point in the history
I think the older order could result in incorrect behavior if Chrome
crashed during startup. This might help with the bug as well.

BUG=406475

Review URL: https://codereview.chromium.org/500563002

Cr-Commit-Position: refs/heads/master@{#291679}
  • Loading branch information
csharp authored and Commit bot committed Aug 25, 2014
1 parent f1e3346 commit 619b85a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions chrome_elf/blacklist/blacklist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ DWORD SetDWValue(HKEY* key, const wchar_t* property, DWORD value) {

bool GenerateStateFromBeaconAndAttemptCount(HKEY* key, DWORD blacklist_state) {
LONG result = 0;
if (blacklist_state == blacklist::BLACKLIST_SETUP_RUNNING) {
if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
// If the blacklist succeeded on the previous run reset the failure
// counter.
return (SetDWValue(key,
blacklist::kBeaconAttemptCount,
static_cast<DWORD>(0)) == ERROR_SUCCESS);
} else {
// Some part of the blacklist setup failed last time. If this has occured
// blacklist::kBeaconMaxAttempts times in a row we switch the state to
// failed and skip setting up the blacklist.
Expand All @@ -111,18 +117,10 @@ bool GenerateStateFromBeaconAndAttemptCount(HKEY* key, DWORD blacklist_state) {
if (attempt_count >= blacklist::kBeaconMaxAttempts) {
blacklist_state = blacklist::BLACKLIST_SETUP_FAILED;
SetDWValue(key, blacklist::kBeaconState, blacklist_state);
return false;
}
} else if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
// If the blacklist succeeded on the previous run reset the failure
// counter.
result =
SetDWValue(key, blacklist::kBeaconAttemptCount, static_cast<DWORD>(0));
if (result != ERROR_SUCCESS) {
return false;
}

return false;
}
return true;
}

} // namespace
Expand Down

0 comments on commit 619b85a

Please sign in to comment.