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

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

Issue 2620303003: Replace ASSERT by RTC_DCHECK in all non-test code. (Closed)
Patch Set: Address final nits. Created 3 years, 11 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/win32filesystem.cc ('k') | webrtc/base/win32window.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 10
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 UpdateLastError(); 244 UpdateLastError();
245 return false; 245 return false;
246 } 246 }
247 if ((SOCK_DGRAM == type) && !SetAsync(FD_READ | FD_WRITE)) { 247 if ((SOCK_DGRAM == type) && !SetAsync(FD_READ | FD_WRITE)) {
248 return false; 248 return false;
249 } 249 }
250 return true; 250 return true;
251 } 251 }
252 252
253 int Win32Socket::Attach(SOCKET s) { 253 int Win32Socket::Attach(SOCKET s) {
254 ASSERT(socket_ == INVALID_SOCKET); 254 RTC_DCHECK(socket_ == INVALID_SOCKET);
255 if (socket_ != INVALID_SOCKET) 255 if (socket_ != INVALID_SOCKET)
256 return SOCKET_ERROR; 256 return SOCKET_ERROR;
257 257
258 ASSERT(s != INVALID_SOCKET); 258 RTC_DCHECK(s != INVALID_SOCKET);
259 if (s == INVALID_SOCKET) 259 if (s == INVALID_SOCKET)
260 return SOCKET_ERROR; 260 return SOCKET_ERROR;
261 261
262 socket_ = s; 262 socket_ = s;
263 state_ = CS_CONNECTED; 263 state_ = CS_CONNECTED;
264 264
265 if (!SetAsync(FD_READ | FD_WRITE | FD_CLOSE)) 265 if (!SetAsync(FD_READ | FD_WRITE | FD_CLOSE))
266 return SOCKET_ERROR; 266 return SOCKET_ERROR;
267 267
268 return 0; 268 return 0;
(...skipping 28 matching lines...) Expand all
297 if (result >= 0) { 297 if (result >= 0) {
298 SocketAddressFromSockAddrStorage(addr, &address); 298 SocketAddressFromSockAddrStorage(addr, &address);
299 } else { 299 } else {
300 LOG(LS_WARNING) << "GetRemoteAddress: unable to get remote addr, socket=" 300 LOG(LS_WARNING) << "GetRemoteAddress: unable to get remote addr, socket="
301 << socket_; 301 << socket_;
302 } 302 }
303 return address; 303 return address;
304 } 304 }
305 305
306 int Win32Socket::Bind(const SocketAddress& addr) { 306 int Win32Socket::Bind(const SocketAddress& addr) {
307 ASSERT(socket_ != INVALID_SOCKET); 307 RTC_DCHECK(socket_ != INVALID_SOCKET);
308 if (socket_ == INVALID_SOCKET) 308 if (socket_ == INVALID_SOCKET)
309 return SOCKET_ERROR; 309 return SOCKET_ERROR;
310 310
311 sockaddr_storage saddr; 311 sockaddr_storage saddr;
312 size_t len = addr.ToSockAddrStorage(&saddr); 312 size_t len = addr.ToSockAddrStorage(&saddr);
313 int err = ::bind(socket_, 313 int err = ::bind(socket_,
314 reinterpret_cast<sockaddr*>(&saddr), 314 reinterpret_cast<sockaddr*>(&saddr),
315 static_cast<int>(len)); 315 static_cast<int>(len));
316 UpdateLastError(); 316 UpdateLastError();
317 return err; 317 return err;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 *mtu = PACKET_MAXIMUMS[level]; 546 *mtu = PACKET_MAXIMUMS[level];
547 return 0; 547 return 0;
548 } 548 }
549 } 549 }
550 550
551 RTC_NOTREACHED(); 551 RTC_NOTREACHED();
552 return 0; 552 return 0;
553 } 553 }
554 554
555 void Win32Socket::CreateSink() { 555 void Win32Socket::CreateSink() {
556 ASSERT(NULL == sink_); 556 RTC_DCHECK(NULL == sink_);
557 557
558 // Create window 558 // Create window
559 sink_ = new EventSink(this); 559 sink_ = new EventSink(this);
560 sink_->Create(NULL, L"EventSink", 0, 0, 0, 0, 10, 10); 560 sink_->Create(NULL, L"EventSink", 0, 0, 0, 0, 10, 10);
561 } 561 }
562 562
563 bool Win32Socket::SetAsync(int events) { 563 bool Win32Socket::SetAsync(int events) {
564 if (NULL == sink_) { 564 if (NULL == sink_) {
565 CreateSink(); 565 CreateSink();
566 ASSERT(NULL != sink_); 566 RTC_DCHECK(NULL != sink_);
567 } 567 }
568 568
569 // start the async select 569 // start the async select
570 if (WSAAsyncSelect(socket_, sink_->handle(), WM_SOCKETNOTIFY, events) 570 if (WSAAsyncSelect(socket_, sink_->handle(), WM_SOCKETNOTIFY, events)
571 == SOCKET_ERROR) { 571 == SOCKET_ERROR) {
572 UpdateLastError(); 572 UpdateLastError();
573 Close(); 573 Close();
574 return false; 574 return false;
575 } 575 }
576 576
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } else if(b) { 786 } else if(b) {
787 if (!hdlg_ || !IsDialogMessage(hdlg_, &msg)) { 787 if (!hdlg_ || !IsDialogMessage(hdlg_, &msg)) {
788 TranslateMessage(&msg); 788 TranslateMessage(&msg);
789 DispatchMessage(&msg); 789 DispatchMessage(&msg);
790 } 790 }
791 } 791 }
792 KillTimer(wnd_.handle(), 0); 792 KillTimer(wnd_.handle(), 0);
793 } while (b && TimeSince(start) < cms); 793 } while (b && TimeSince(start) < cms);
794 } else if (cms != 0) { 794 } else if (cms != 0) {
795 // Sit and wait forever for a WakeUp. This is the Thread::Send case. 795 // Sit and wait forever for a WakeUp. This is the Thread::Send case.
796 ASSERT(cms == -1); 796 RTC_DCHECK(cms == -1);
797 MSG msg; 797 MSG msg;
798 b = GetMessage(&msg, NULL, s_wm_wakeup_id, s_wm_wakeup_id); 798 b = GetMessage(&msg, NULL, s_wm_wakeup_id, s_wm_wakeup_id);
799 { 799 {
800 CritScope scope(&cs_); 800 CritScope scope(&cs_);
801 posted_ = false; 801 posted_ = false;
802 } 802 }
803 } else { 803 } else {
804 // No-op (cms == 0 && !process_io). This is the Pump case. 804 // No-op (cms == 0 && !process_io). This is the Pump case.
805 b = TRUE; 805 b = TRUE;
806 } 806 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 bool handled = false; 854 bool handled = false;
855 if (wm == s_wm_wakeup_id || (wm == WM_TIMER && wp == 1)) { 855 if (wm == s_wm_wakeup_id || (wm == WM_TIMER && wp == 1)) {
856 ss_->Pump(); 856 ss_->Pump();
857 lr = 0; 857 lr = 0;
858 handled = true; 858 handled = true;
859 } 859 }
860 return handled; 860 return handled;
861 } 861 }
862 862
863 } // namespace rtc 863 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/win32filesystem.cc ('k') | webrtc/base/win32window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698