Commit b9956598 authored by harrisonsean's avatar harrisonsean Committed by Commit Bot

[iOS][Safety Check] Switch all dispatches to weak self

Fix an issue where SafetyCheckMediator instances are not being
released due to use of self instead of weakself.

Bug: 1140923
Change-Id: I1bda7052e504d5e294b4321b48064eede463b6e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498502Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820802}
parent a2ab8688
...@@ -736,6 +736,7 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75; ...@@ -736,6 +736,7 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75;
break; break;
} }
} }
__weak __typeof__(self) weakSelf = self;
// This handles a discrepancy between password check and safety check. In // This handles a discrepancy between password check and safety check. In
// password check a user cannot start a check if they have no passwords, but // password check a user cannot start a check if they have no passwords, but
// in safety check they can, but the |passwordCheckManager| won't even start // in safety check they can, but the |passwordCheckManager| won't even start
...@@ -749,9 +750,9 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75; ...@@ -749,9 +750,9 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75;
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
// Check if the check was cancelled while waiting, we do not want to // Check if the check was cancelled while waiting, we do not want to
// push a completed state to the UI if the check was cancelled. // push a completed state to the UI if the check was cancelled.
if (self.checksRemaining) { if (weakSelf.checksRemaining) {
self.passwordCheckRowState = PasswordCheckRowStateDisabled; weakSelf.passwordCheckRowState = PasswordCheckRowStateDisabled;
[self reconfigurePasswordCheckItem]; [weakSelf reconfigurePasswordCheckItem];
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
kSafetyCheckMetricsPasswords, kSafetyCheckMetricsPasswords,
...@@ -768,8 +769,8 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75; ...@@ -768,8 +769,8 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75;
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
// Check if the check was cancelled while waiting, we do not want to // Check if the check was cancelled while waiting, we do not want to
// push a completed state to the UI if the check was cancelled. // push a completed state to the UI if the check was cancelled.
if (self.checksRemaining) if (weakSelf.checksRemaining)
[self checkAndReconfigureSafeBrowsingState]; [weakSelf checkAndReconfigureSafeBrowsingState];
}); });
} }
return; return;
...@@ -853,15 +854,16 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75; ...@@ -853,15 +854,16 @@ constexpr double kSafeBrowsingRowMinDelay = 1.75;
double minDelay = kUpdateRowMinDelay; double minDelay = kUpdateRowMinDelay;
if (secondsSinceStart < minDelay) { if (secondsSinceStart < minDelay) {
// Want to show the loading wheel for minimum time. // Want to show the loading wheel for minimum time.
__weak __typeof__(self) weakSelf = self;
dispatch_after( dispatch_after(
dispatch_time(DISPATCH_TIME_NOW, dispatch_time(DISPATCH_TIME_NOW,
(int64_t)((minDelay - secondsSinceStart) * NSEC_PER_SEC)), (int64_t)((minDelay - secondsSinceStart) * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
// Check if the check was cancelled while waiting, we do not want to // Check if the check was cancelled while waiting, we do not want to
// push a completed state to the UI if the check was cancelled. // push a completed state to the UI if the check was cancelled.
if (self.checksRemaining) { if (weakSelf.checksRemaining) {
self.updateCheckRowState = newRowState; weakSelf.updateCheckRowState = newRowState;
[self reconfigureUpdateCheckItem]; [weakSelf reconfigureUpdateCheckItem];
} }
}); });
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment