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

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

Issue 1785713005: Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback from tommi. 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') | no next file with comments »
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 @end 146 @end
147 147
148 @implementation RTCDataBuffer { 148 @implementation RTCDataBuffer {
149 rtc::scoped_ptr<webrtc::DataBuffer> _dataBuffer; 149 rtc::scoped_ptr<webrtc::DataBuffer> _dataBuffer;
150 } 150 }
151 151
152 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary { 152 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary {
153 NSAssert(data, @"data cannot be nil"); 153 NSAssert(data, @"data cannot be nil");
154 if (self = [super init]) { 154 if (self = [super init]) {
155 rtc::Buffer buffer(reinterpret_cast<const uint8_t*>([data bytes]), 155 rtc::CopyOnWriteBuffer buffer(
156 [data length]); 156 reinterpret_cast<const uint8_t*>([data bytes]), [data length]);
157 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); 157 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary));
158 } 158 }
159 return self; 159 return self;
160 } 160 }
161 161
162 - (NSData*)data { 162 - (NSData*)data {
163 return [NSData dataWithBytes:_dataBuffer->data.data() 163 return [NSData dataWithBytes:_dataBuffer->data.data()
164 length:_dataBuffer->data.size()]; 164 length:_dataBuffer->data.size()];
165 } 165 }
166 166
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 _observer.reset(new webrtc::RTCDataChannelObserver(self)); 282 _observer.reset(new webrtc::RTCDataChannelObserver(self));
283 } 283 }
284 return self; 284 return self;
285 } 285 }
286 286
287 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel { 287 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel {
288 return _dataChannel; 288 return _dataChannel;
289 } 289 }
290 290
291 @end 291 @end
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/datachannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698