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

Fix retain cycle caused by ConnectionTypeObserverBridge

There are two uses of ConnectionTypeObserverBridge by Objective-C
classes (MetricsMediator and PreloadController) and both of them
pass "self" as the observer.

Since those classes also keep the ownership of the C++ bridge
(via a std::unique_ptr<ConnectionTypeObserverBridge> ivar), this
caused a retain cycle because "observer_" was strongly retained.

Mark the observer as __weak in order to break the retain cycle.

Bug: 1005152
Change-Id: Ief077e6ab97d7f6daa30951a3bed012308bb5369
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1813338
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697964}
parent bcdce5a6
......@@ -27,7 +27,7 @@ class ConnectionTypeObserverBridge
void OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) override;
id<CRConnectionTypeObserverBridge> delegate_; // Weak, owns this.
__weak id<CRConnectionTypeObserverBridge> delegate_;
DISALLOW_COPY_AND_ASSIGN(ConnectionTypeObserverBridge);
};
......
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