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

Side by Side Diff: webrtc/base/physicalsocketserver.cc

Issue 2718663005: Replace NULL with nullptr or null in webrtc/base/. (Closed)
Patch Set: Fixing Windows and formatting issues. Created 3 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 | « webrtc/base/pathutils.cc ('k') | webrtc/base/physicalsocketserver_unittest.cc » ('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 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 #include "webrtc/base/physicalsocketserver.h" 10 #include "webrtc/base/physicalsocketserver.h"
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 class EventDispatcher : public Dispatcher { 1111 class EventDispatcher : public Dispatcher {
1112 public: 1112 public:
1113 EventDispatcher(PhysicalSocketServer *ss) : ss_(ss) { 1113 EventDispatcher(PhysicalSocketServer *ss) : ss_(ss) {
1114 hev_ = WSACreateEvent(); 1114 hev_ = WSACreateEvent();
1115 if (hev_) { 1115 if (hev_) {
1116 ss_->Add(this); 1116 ss_->Add(this);
1117 } 1117 }
1118 } 1118 }
1119 1119
1120 ~EventDispatcher() { 1120 ~EventDispatcher() {
1121 if (hev_ != NULL) { 1121 if (hev_ != nullptr) {
1122 ss_->Remove(this); 1122 ss_->Remove(this);
1123 WSACloseEvent(hev_); 1123 WSACloseEvent(hev_);
1124 hev_ = NULL; 1124 hev_ = nullptr;
1125 } 1125 }
1126 } 1126 }
1127 1127
1128 virtual void Signal() { 1128 virtual void Signal() {
1129 if (hev_ != NULL) 1129 if (hev_ != nullptr)
1130 WSASetEvent(hev_); 1130 WSASetEvent(hev_);
1131 } 1131 }
1132 1132
1133 virtual uint32_t GetRequestedEvents() { return 0; } 1133 virtual uint32_t GetRequestedEvents() { return 0; }
1134 1134
1135 virtual void OnPreEvent(uint32_t ff) { WSAResetEvent(hev_); } 1135 virtual void OnPreEvent(uint32_t ff) { WSAResetEvent(hev_); }
1136 1136
1137 virtual void OnEvent(uint32_t ff, int err) {} 1137 virtual void OnEvent(uint32_t ff, int err) {}
1138 1138
1139 virtual WSAEVENT GetWSAEvent() { 1139 virtual WSAEVENT GetWSAEvent() {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 if (index < **it) { 1261 if (index < **it) {
1262 --**it; 1262 --**it;
1263 } 1263 }
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 #if defined(WEBRTC_POSIX) 1267 #if defined(WEBRTC_POSIX)
1268 bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { 1268 bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
1269 // Calculate timing information 1269 // Calculate timing information
1270 1270
1271 struct timeval *ptvWait = NULL; 1271 struct timeval* ptvWait = nullptr;
1272 struct timeval tvWait; 1272 struct timeval tvWait;
1273 struct timeval tvStop; 1273 struct timeval tvStop;
1274 if (cmsWait != kForever) { 1274 if (cmsWait != kForever) {
1275 // Calculate wait timeval 1275 // Calculate wait timeval
1276 tvWait.tv_sec = cmsWait / 1000; 1276 tvWait.tv_sec = cmsWait / 1000;
1277 tvWait.tv_usec = (cmsWait % 1000) * 1000; 1277 tvWait.tv_usec = (cmsWait % 1000) * 1000;
1278 ptvWait = &tvWait; 1278 ptvWait = &tvWait;
1279 1279
1280 // Calculate when to return in a timeval 1280 // Calculate when to return in a timeval
1281 gettimeofday(&tvStop, NULL); 1281 gettimeofday(&tvStop, nullptr);
1282 tvStop.tv_sec += tvWait.tv_sec; 1282 tvStop.tv_sec += tvWait.tv_sec;
1283 tvStop.tv_usec += tvWait.tv_usec; 1283 tvStop.tv_usec += tvWait.tv_usec;
1284 if (tvStop.tv_usec >= 1000000) { 1284 if (tvStop.tv_usec >= 1000000) {
1285 tvStop.tv_usec -= 1000000; 1285 tvStop.tv_usec -= 1000000;
1286 tvStop.tv_sec += 1; 1286 tvStop.tv_sec += 1;
1287 } 1287 }
1288 } 1288 }
1289 1289
1290 // Zero all fd_sets. Don't need to do this inside the loop since 1290 // Zero all fd_sets. Don't need to do this inside the loop since
1291 // select() zeros the descriptors not signaled 1291 // select() zeros the descriptors not signaled
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 FD_SET(fd, &fdsRead); 1323 FD_SET(fd, &fdsRead);
1324 if (ff & (DE_WRITE | DE_CONNECT)) 1324 if (ff & (DE_WRITE | DE_CONNECT))
1325 FD_SET(fd, &fdsWrite); 1325 FD_SET(fd, &fdsWrite);
1326 } 1326 }
1327 } 1327 }
1328 1328
1329 // Wait then call handlers as appropriate 1329 // Wait then call handlers as appropriate
1330 // < 0 means error 1330 // < 0 means error
1331 // 0 means timeout 1331 // 0 means timeout
1332 // > 0 means count of descriptors ready 1332 // > 0 means count of descriptors ready
1333 int n = select(fdmax + 1, &fdsRead, &fdsWrite, NULL, ptvWait); 1333 int n = select(fdmax + 1, &fdsRead, &fdsWrite, nullptr, ptvWait);
1334 1334
1335 // If error, return error. 1335 // If error, return error.
1336 if (n < 0) { 1336 if (n < 0) {
1337 if (errno != EINTR) { 1337 if (errno != EINTR) {
1338 LOG_E(LS_ERROR, EN, errno) << "select"; 1338 LOG_E(LS_ERROR, EN, errno) << "select";
1339 return false; 1339 return false;
1340 } 1340 }
1341 // Else ignore the error and keep going. If this EINTR was for one of the 1341 // Else ignore the error and keep going. If this EINTR was for one of the
1342 // signals managed by this PhysicalSocketServer, the 1342 // signals managed by this PhysicalSocketServer, the
1343 // PosixSignalDeliveryDispatcher will be in the signaled state in the next 1343 // PosixSignalDeliveryDispatcher will be in the signaled state in the next
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } 1398 }
1399 } 1399 }
1400 } 1400 }
1401 1401
1402 // Recalc the time remaining to wait. Doing it here means it doesn't get 1402 // Recalc the time remaining to wait. Doing it here means it doesn't get
1403 // calced twice the first time through the loop 1403 // calced twice the first time through the loop
1404 if (ptvWait) { 1404 if (ptvWait) {
1405 ptvWait->tv_sec = 0; 1405 ptvWait->tv_sec = 0;
1406 ptvWait->tv_usec = 0; 1406 ptvWait->tv_usec = 0;
1407 struct timeval tvT; 1407 struct timeval tvT;
1408 gettimeofday(&tvT, NULL); 1408 gettimeofday(&tvT, nullptr);
1409 if ((tvStop.tv_sec > tvT.tv_sec) 1409 if ((tvStop.tv_sec > tvT.tv_sec)
1410 || ((tvStop.tv_sec == tvT.tv_sec) 1410 || ((tvStop.tv_sec == tvT.tv_sec)
1411 && (tvStop.tv_usec > tvT.tv_usec))) { 1411 && (tvStop.tv_usec > tvT.tv_usec))) {
1412 ptvWait->tv_sec = tvStop.tv_sec - tvT.tv_sec; 1412 ptvWait->tv_sec = tvStop.tv_sec - tvT.tv_sec;
1413 ptvWait->tv_usec = tvStop.tv_usec - tvT.tv_usec; 1413 ptvWait->tv_usec = tvStop.tv_usec - tvT.tv_usec;
1414 if (ptvWait->tv_usec < 0) { 1414 if (ptvWait->tv_usec < 0) {
1415 RTC_DCHECK(ptvWait->tv_sec > 0); 1415 RTC_DCHECK(ptvWait->tv_sec > 0);
1416 ptvWait->tv_usec += 1000000; 1416 ptvWait->tv_usec += 1000000;
1417 ptvWait->tv_sec -= 1; 1417 ptvWait->tv_sec -= 1;
1418 } 1418 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 } 1466 }
1467 act.sa_handler = handler; 1467 act.sa_handler = handler;
1468 #if !defined(__native_client__) 1468 #if !defined(__native_client__)
1469 // Use SA_RESTART so that our syscalls don't get EINTR, since we don't need it 1469 // Use SA_RESTART so that our syscalls don't get EINTR, since we don't need it
1470 // and it's a nuisance. Though some syscalls still return EINTR and there's no 1470 // and it's a nuisance. Though some syscalls still return EINTR and there's no
1471 // real standard for which ones. :( 1471 // real standard for which ones. :(
1472 act.sa_flags = SA_RESTART; 1472 act.sa_flags = SA_RESTART;
1473 #else 1473 #else
1474 act.sa_flags = 0; 1474 act.sa_flags = 0;
1475 #endif 1475 #endif
1476 if (sigaction(signum, &act, NULL) != 0) { 1476 if (sigaction(signum, &act, nullptr) != 0) {
1477 LOG_ERR(LS_ERROR) << "Couldn't set sigaction"; 1477 LOG_ERR(LS_ERROR) << "Couldn't set sigaction";
1478 return false; 1478 return false;
1479 } 1479 }
1480 return true; 1480 return true;
1481 } 1481 }
1482 #endif // WEBRTC_POSIX 1482 #endif // WEBRTC_POSIX
1483 1483
1484 #if defined(WEBRTC_WIN) 1484 #if defined(WEBRTC_WIN)
1485 bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { 1485 bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
1486 int64_t cmsTotal = cmsWait; 1486 int64_t cmsTotal = cmsWait;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 break; 1637 break;
1638 } 1638 }
1639 } 1639 }
1640 1640
1641 // Done 1641 // Done
1642 return true; 1642 return true;
1643 } 1643 }
1644 #endif // WEBRTC_WIN 1644 #endif // WEBRTC_WIN
1645 1645
1646 } // namespace rtc 1646 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/pathutils.cc ('k') | webrtc/base/physicalsocketserver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698