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

Side by Side Diff: webrtc/voice_engine/test/channel_transport/udp_socket_manager_posix.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 this, 189 this,
190 "UdpSocketManagerPosixImplThread"), 190 "UdpSocketManagerPosixImplThread"),
191 _critSectList(CriticalSectionWrapper::CreateCriticalSection()) { 191 _critSectList(CriticalSectionWrapper::CreateCriticalSection()) {
192 FD_ZERO(&_readFds); 192 FD_ZERO(&_readFds);
193 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, 193 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
194 "UdpSocketManagerPosix created"); 194 "UdpSocketManagerPosix created");
195 } 195 }
196 196
197 UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl() 197 UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl()
198 { 198 {
199 if (_critSectList != NULL) 199 if (_critSectList != nullptr) {
200 { 200 UpdateSocketMap();
201 UpdateSocketMap();
202 201
203 _critSectList->Enter(); 202 _critSectList->Enter();
204 for (std::map<SOCKET, UdpSocketPosix*>::iterator it = 203 for (std::map<SOCKET, UdpSocketPosix*>::iterator it = _socketMap.begin();
205 _socketMap.begin(); 204 it != _socketMap.end(); ++it) {
206 it != _socketMap.end(); 205 delete it->second;
207 ++it) { 206 }
208 delete it->second; 207 _socketMap.clear();
209 } 208 _critSectList->Leave();
210 _socketMap.clear();
211 _critSectList->Leave();
212 209
213 delete _critSectList; 210 delete _critSectList;
214 } 211 }
215 212
216 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, 213 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
217 "UdpSocketManagerPosix deleted"); 214 "UdpSocketManagerPosix deleted");
218 } 215 }
219 216
220 bool UdpSocketManagerPosixImpl::Start() 217 bool UdpSocketManagerPosixImpl::Start()
221 { 218 {
222 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, 219 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
223 "Start UdpSocketManagerPosix"); 220 "Start UdpSocketManagerPosix");
(...skipping 28 matching lines...) Expand all
252 ++it) { 249 ++it) {
253 doSelect = true; 250 doSelect = true;
254 if (it->first > maxFd) 251 if (it->first > maxFd)
255 maxFd = it->first; 252 maxFd = it->first;
256 FD_SET(it->first, &_readFds); 253 FD_SET(it->first, &_readFds);
257 } 254 }
258 255
259 int num = 0; 256 int num = 0;
260 if (doSelect) 257 if (doSelect)
261 { 258 {
262 num = select(maxFd+1, &_readFds, NULL, NULL, &timeout); 259 num = select(maxFd + 1, &_readFds, nullptr, nullptr, &timeout);
263 260
264 if (num == SOCKET_ERROR) 261 if (num == SOCKET_ERROR) {
265 { 262 // Timeout = 10 ms.
266 // Timeout = 10 ms. 263 SleepMs(10);
267 SleepMs(10); 264 return true;
268 return true;
269 } 265 }
270 }else 266 }else
271 { 267 {
272 // Timeout = 10 ms. 268 // Timeout = 10 ms.
273 SleepMs(10); 269 SleepMs(10);
274 return true; 270 return true;
275 } 271 }
276 272
277 for (std::map<SOCKET, UdpSocketPosix*>::iterator it = _socketMap.begin(); 273 for (std::map<SOCKET, UdpSocketPosix*>::iterator it = _socketMap.begin();
278 it != _socketMap.end(); 274 it != _socketMap.end();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 _critSectList->Leave(); 332 _critSectList->Leave();
337 return false; 333 return false;
338 } 334 }
339 335
340 void UdpSocketManagerPosixImpl::UpdateSocketMap() 336 void UdpSocketManagerPosixImpl::UpdateSocketMap()
341 { 337 {
342 // Remove items in remove list. 338 // Remove items in remove list.
343 _critSectList->Enter(); 339 _critSectList->Enter();
344 for (FdList::iterator iter = _removeList.begin(); 340 for (FdList::iterator iter = _removeList.begin();
345 iter != _removeList.end(); ++iter) { 341 iter != _removeList.end(); ++iter) {
346 UdpSocketPosix* deleteSocket = NULL; 342 UdpSocketPosix* deleteSocket = nullptr;
347 SOCKET removeFD = *iter; 343 SOCKET removeFD = *iter;
348 344
349 // If the socket is in the add list it hasn't been added to the socket 345 // If the socket is in the add list it hasn't been added to the socket
350 // map yet. Just remove the socket from the add list. 346 // map yet. Just remove the socket from the add list.
351 for (SocketList::iterator iter = _addList.begin(); 347 for (SocketList::iterator iter = _addList.begin(); iter != _addList.end();
352 iter != _addList.end(); ++iter) { 348 ++iter) {
353 UdpSocketPosix* addSocket = static_cast<UdpSocketPosix*>(*iter); 349 UdpSocketPosix* addSocket = static_cast<UdpSocketPosix*>(*iter);
354 SOCKET addFD = addSocket->GetFd(); 350 SOCKET addFD = addSocket->GetFd();
355 if(removeFD == addFD) 351 if (removeFD == addFD) {
356 { 352 deleteSocket = addSocket;
357 deleteSocket = addSocket; 353 _addList.erase(iter);
358 _addList.erase(iter); 354 break;
359 break; 355 }
360 }
361 } 356 }
362 357
363 // Find and remove socket from _socketMap. 358 // Find and remove socket from _socketMap.
364 std::map<SOCKET, UdpSocketPosix*>::iterator it = 359 std::map<SOCKET, UdpSocketPosix*>::iterator it =
365 _socketMap.find(removeFD); 360 _socketMap.find(removeFD);
366 if(it != _socketMap.end()) 361 if(it != _socketMap.end())
367 { 362 {
368 deleteSocket = it->second; 363 deleteSocket = it->second;
369 _socketMap.erase(it); 364 _socketMap.erase(it);
370 } 365 }
(...skipping 12 matching lines...) Expand all
383 if(s) { 378 if(s) {
384 _socketMap[s->GetFd()] = s; 379 _socketMap[s->GetFd()] = s;
385 } 380 }
386 } 381 }
387 _addList.clear(); 382 _addList.clear();
388 _critSectList->Leave(); 383 _critSectList->Leave();
389 } 384 }
390 385
391 } // namespace test 386 } // namespace test
392 } // namespace webrtc 387 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698