[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:Mark Cogan <marq@chromium.org> Cr-Commit-Position: refs/heads/master@{#803566}
Showing
Please register or sign in to comment