Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Unified Diff: webrtc/sdk/objc/Framework/Classes/RTCDataChannel.mm

Issue 1957523006: Fixed a crash in Objective-C clients when data channel becomes closed. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/objc/Framework/Classes/RTCDataChannel.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCDataChannel.mm b/webrtc/sdk/objc/Framework/Classes/RTCDataChannel.mm
index 9948615a6a2b4d351ed8ad312c04a8a4e2d9d84a..706e43e2ed5a984ffdbc5a6b7183e490a2a70332 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCDataChannel.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCDataChannel.mm
@@ -95,7 +95,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver {
- (void)dealloc {
// Handles unregistering the observer properly. We need to do this because
// there may still be other references to the underlying data channel.
- self.delegate = nil;
+ _nativeDataChannel->UnregisterObserver();
}
- (NSString *)label {
@@ -147,21 +147,6 @@ class DataChannelDelegateAdapter : public DataChannelObserver {
return _nativeDataChannel->buffered_amount();
}
-- (void)setDelegate:(id<RTCDataChannelDelegate>)delegate {
- if (_delegate == delegate) {
- return;
- }
- if (_isObserverRegistered) {
- _nativeDataChannel->UnregisterObserver();
- _isObserverRegistered = NO;
- }
- _delegate = delegate;
- if (_delegate) {
- _nativeDataChannel->RegisterObserver(_observer.get());
- _isObserverRegistered = YES;
- }
-}
-
- (void)close {
_nativeDataChannel->Close();
}
@@ -186,6 +171,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver {
if (self = [super init]) {
_nativeDataChannel = nativeDataChannel;
_observer.reset(new webrtc::DataChannelDelegateAdapter(self));
+ _nativeDataChannel->RegisterObserver(_observer.get());
}
return self;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698