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

[ios] Create weakSelf pointer outside of a block

The creation of weakSelf in -updateAllTopSitesSpotlightItems was done
in a block passed to -clearAllSpotlightItems to be used by an inner
block. This caused the outer block (that is passed to Spotlight) to
capture a reference to self.

As spotlight execute the block on a background thread, this could
cause the instance of TopSitesSpotlightManager to be deallocated on
the background thread which is not supported (as BaseSpotlightManager
owns a base::CancelableTaskTracker which is sequence-affine).

Creating the weakSelf outside of all the block ensure that none of
them (either the outer or inner block) capture a strong reference
to the BaseSpotlightManager, leaving the full ownership of them to
SpotlightManager (and ensuring that they are deallocated when shutdown
is called).

Bug: 1122991
Change-Id: Ie5e91d3cf29da2ecbca91d2c6c3722cf8b6d0769
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388280
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803566}
parent 5075457e
......@@ -130,8 +130,8 @@ BOOL SetStartupParametersForSpotlightAction(
#pragma mark private methods
- (void)clearAndAddSpotlightActions {
__weak ActionsSpotlightManager* weakSelf = self;
[self clearAllSpotlightItems:^(NSError* error) {
__weak ActionsSpotlightManager* weakSelf = self;
dispatch_after(
dispatch_time(DISPATCH_TIME_NOW,
static_cast<int64_t>(1 * NSEC_PER_SEC)),
......
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