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

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

Issue 1823503002: Reland Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (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
« no previous file with comments | « no previous file | webrtc/api/datachannel.h » ('j') | webrtc/media/sctp/sctpdataengine.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 @end 147 @end
148 148
149 @implementation RTCDataBuffer { 149 @implementation RTCDataBuffer {
150 std::unique_ptr<webrtc::DataBuffer> _dataBuffer; 150 std::unique_ptr<webrtc::DataBuffer> _dataBuffer;
151 } 151 }
152 152
153 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary { 153 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary {
154 NSAssert(data, @"data cannot be nil"); 154 NSAssert(data, @"data cannot be nil");
155 if (self = [super init]) { 155 if (self = [super init]) {
156 rtc::Buffer buffer(reinterpret_cast<const uint8_t*>([data bytes]), 156 rtc::CopyOnWriteBuffer buffer(
157 [data length]); 157 reinterpret_cast<const uint8_t*>([data bytes]), [data length]);
158 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); 158 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary));
159 } 159 }
160 return self; 160 return self;
161 } 161 }
162 162
163 - (NSData*)data { 163 - (NSData*)data {
164 return [NSData dataWithBytes:_dataBuffer->data.data() 164 return [NSData dataWithBytes:_dataBuffer->data.data()
165 length:_dataBuffer->data.size()]; 165 length:_dataBuffer->data.size()];
166 } 166 }
167 167
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 _observer.reset(new webrtc::RTCDataChannelObserver(self)); 283 _observer.reset(new webrtc::RTCDataChannelObserver(self));
284 } 284 }
285 return self; 285 return self;
286 } 286 }
287 287
288 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel { 288 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel {
289 return _dataChannel; 289 return _dataChannel;
290 } 290 }
291 291
292 @end 292 @end
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/datachannel.h » ('j') | webrtc/media/sctp/sctpdataengine.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698