Commit ff30aea9 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Compare ChromeIdentity by value

Ensuring ChromeIdentity uniqueness is currently thread-usafe. Removing
the uniqueness guaranty requires that code correctly uses -isEqual: to
compare identities by value instead of doing the comparison of pointers
(like you use -isStringEqual: to compare NSString).

After doing an audit of all code using ChromeIdentity, convert all the
comparison that were using pointers comparison instead of -isEqual:.

Bug: none
Change-Id: I110cb8e289ccaf482dd7addf67f5d194aed98a75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2139666
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757463}
parent e4633f99
...@@ -594,7 +594,7 @@ const char* AlreadySeenSigninViewPreferenceKey( ...@@ -594,7 +594,7 @@ const char* AlreadySeenSigninViewPreferenceKey(
if (identities.count != 0) { if (identities.count != 0) {
newIdentity = identities[0]; newIdentity = identities[0];
} }
if (newIdentity != _defaultIdentity) { if (![_defaultIdentity isEqual:newIdentity]) {
[self selectIdentity:newIdentity]; [self selectIdentity:newIdentity];
[self sendConsumerNotificationWithIdentityChanged:YES]; [self sendConsumerNotificationWithIdentityChanged:YES];
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
} }
- (void)setSelectedIdentity:(ChromeIdentity*)selectedIdentity { - (void)setSelectedIdentity:(ChromeIdentity*)selectedIdentity {
if (_selectedIdentity == selectedIdentity) if ([_selectedIdentity isEqual:selectedIdentity])
return; return;
IdentityChooserItem* previousSelectedItem = [self.consumer IdentityChooserItem* previousSelectedItem = [self.consumer
identityChooserItemWithGaiaID:self.selectedIdentity.gaiaID]; identityChooserItemWithGaiaID:self.selectedIdentity.gaiaID];
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
} }
- (void)setSelectedIdentity:(ChromeIdentity*)selectedIdentity { - (void)setSelectedIdentity:(ChromeIdentity*)selectedIdentity {
if (selectedIdentity == self.selectedIdentity) { if ([self.selectedIdentity isEqual:selectedIdentity]) {
return; return;
} }
// nil is allowed only if there is no other identity. // nil is allowed only if there is no other identity.
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
} }
- (void)profileUpdate:(ChromeIdentity*)identity { - (void)profileUpdate:(ChromeIdentity*)identity {
if (identity == self.selectedIdentity) { if ([self.selectedIdentity isEqual:identity]) {
[self updateViewController]; [self updateViewController];
} }
} }
......
...@@ -1168,7 +1168,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -1168,7 +1168,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
#pragma mark ChromeIdentityServiceObserver #pragma mark ChromeIdentityServiceObserver
- (void)profileUpdate:(ChromeIdentity*)identity { - (void)profileUpdate:(ChromeIdentity*)identity {
if (identity == _identity) { if ([_identity isEqual:identity]) {
[self reloadAccountCell]; [self reloadAccountCell];
} }
} }
......
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