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

Side by Side Diff: talk/app/webrtc/objc/RTCDataChannel.mm

Issue 1785353003: Replace scoped_ptr with unique_ptr in talk/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 13 matching lines...) Expand all
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #if !defined(__has_feature) || !__has_feature(objc_arc) 28 #if !defined(__has_feature) || !__has_feature(objc_arc)
29 #error "This file requires ARC support." 29 #error "This file requires ARC support."
30 #endif 30 #endif
31 31
32 #import "RTCDataChannel+Internal.h" 32 #import "RTCDataChannel+Internal.h"
33 33
34 #include <memory>
35
34 #include "webrtc/api/datachannelinterface.h" 36 #include "webrtc/api/datachannelinterface.h"
35 #include "webrtc/base/scoped_ptr.h"
36 37
37 namespace webrtc { 38 namespace webrtc {
38 39
39 class RTCDataChannelObserver : public DataChannelObserver { 40 class RTCDataChannelObserver : public DataChannelObserver {
40 public: 41 public:
41 RTCDataChannelObserver(RTCDataChannel* channel) { _channel = channel; } 42 RTCDataChannelObserver(RTCDataChannel* channel) { _channel = channel; }
42 43
43 void OnStateChange() override { 44 void OnStateChange() override {
44 [_channel.delegate channelDidChangeState:_channel]; 45 [_channel.delegate channelDidChangeState:_channel];
45 } 46 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 140
140 @implementation RTCDataChannelInit (Internal) 141 @implementation RTCDataChannelInit (Internal)
141 142
142 - (const webrtc::DataChannelInit*)dataChannelInit { 143 - (const webrtc::DataChannelInit*)dataChannelInit {
143 return &_dataChannelInit; 144 return &_dataChannelInit;
144 } 145 }
145 146
146 @end 147 @end
147 148
148 @implementation RTCDataBuffer { 149 @implementation RTCDataBuffer {
149 rtc::scoped_ptr<webrtc::DataBuffer> _dataBuffer; 150 std::unique_ptr<webrtc::DataBuffer> _dataBuffer;
150 } 151 }
151 152
152 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary { 153 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary {
153 NSAssert(data, @"data cannot be nil"); 154 NSAssert(data, @"data cannot be nil");
154 if (self = [super init]) { 155 if (self = [super init]) {
155 rtc::Buffer buffer(reinterpret_cast<const uint8_t*>([data bytes]), 156 rtc::Buffer buffer(reinterpret_cast<const uint8_t*>([data bytes]),
156 [data length]); 157 [data length]);
157 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); 158 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary));
158 } 159 }
159 return self; 160 return self;
(...skipping 20 matching lines...) Expand all
180 } 181 }
181 182
182 - (const webrtc::DataBuffer*)dataBuffer { 183 - (const webrtc::DataBuffer*)dataBuffer {
183 return _dataBuffer.get(); 184 return _dataBuffer.get();
184 } 185 }
185 186
186 @end 187 @end
187 188
188 @implementation RTCDataChannel { 189 @implementation RTCDataChannel {
189 rtc::scoped_refptr<webrtc::DataChannelInterface> _dataChannel; 190 rtc::scoped_refptr<webrtc::DataChannelInterface> _dataChannel;
190 rtc::scoped_ptr<webrtc::RTCDataChannelObserver> _observer; 191 std::unique_ptr<webrtc::RTCDataChannelObserver> _observer;
191 BOOL _isObserverRegistered; 192 BOOL _isObserverRegistered;
192 } 193 }
193 194
194 - (void)dealloc { 195 - (void)dealloc {
195 // Handles unregistering the observer properly. We need to do this because 196 // Handles unregistering the observer properly. We need to do this because
196 // there may still be other references to the underlying data channel. 197 // there may still be other references to the underlying data channel.
197 self.delegate = nil; 198 self.delegate = nil;
198 } 199 }
199 200
200 - (NSString*)label { 201 - (NSString*)label {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 _observer.reset(new webrtc::RTCDataChannelObserver(self)); 283 _observer.reset(new webrtc::RTCDataChannelObserver(self));
283 } 284 }
284 return self; 285 return self;
285 } 286 }
286 287
287 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel { 288 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel {
288 return _dataChannel; 289 return _dataChannel;
289 } 290 }
290 291
291 @end 292 @end
OLDNEW
« no previous file with comments | « talk/app/webrtc/objc/RTCAVFoundationVideoSource.mm ('k') | talk/app/webrtc/objc/RTCI420Frame.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698