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

Side by Side Diff: webrtc/p2p/base/asyncstuntcpsocket.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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2013 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
11 #include "webrtc/p2p/base/asyncstuntcpsocket.h" 11 #include "webrtc/p2p/base/asyncstuntcpsocket.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include "webrtc/p2p/base/stun.h" 15 #include "webrtc/p2p/base/stun.h"
16 #include "webrtc/base/checks.h"
16 #include "webrtc/base/common.h" 17 #include "webrtc/base/common.h"
17 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
18 19
19 namespace cricket { 20 namespace cricket {
20 21
21 static const size_t kMaxPacketSize = 64 * 1024; 22 static const size_t kMaxPacketSize = 64 * 1024;
22 23
23 typedef uint16_t PacketLength; 24 typedef uint16_t PacketLength;
24 static const size_t kPacketLenSize = sizeof(PacketLength); 25 static const size_t kPacketLenSize = sizeof(PacketLength);
25 static const size_t kPacketLenOffset = 2; 26 static const size_t kPacketLenOffset = 2;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 62
62 int pad_bytes; 63 int pad_bytes;
63 size_t expected_pkt_len = GetExpectedLength(pv, cb, &pad_bytes); 64 size_t expected_pkt_len = GetExpectedLength(pv, cb, &pad_bytes);
64 65
65 // Accepts only complete STUN/ChannelData packets. 66 // Accepts only complete STUN/ChannelData packets.
66 if (cb != expected_pkt_len) 67 if (cb != expected_pkt_len)
67 return -1; 68 return -1;
68 69
69 AppendToOutBuffer(pv, cb); 70 AppendToOutBuffer(pv, cb);
70 71
71 ASSERT(pad_bytes < 4); 72 RTC_DCHECK(pad_bytes < 4);
72 char padding[4] = {0}; 73 char padding[4] = {0};
73 AppendToOutBuffer(padding, pad_bytes); 74 AppendToOutBuffer(padding, pad_bytes);
74 75
75 int res = FlushOutBuffer(); 76 int res = FlushOutBuffer();
76 if (res <= 0) { 77 if (res <= 0) {
77 // drop packet if we made no progress 78 // drop packet if we made no progress
78 ClearOutBuffer(); 79 ClearOutBuffer();
79 return res; 80 return res;
80 } 81 }
81 82
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // message (including padding) is (4 + Length) rounded up to the nearest 145 // message (including padding) is (4 + Length) rounded up to the nearest
145 // multiple of 4. Over UDP, the padding is not required but MAY be 146 // multiple of 4. Over UDP, the padding is not required but MAY be
146 // included. 147 // included.
147 if (expected_pkt_len % 4) 148 if (expected_pkt_len % 4)
148 *pad_bytes = 4 - (expected_pkt_len % 4); 149 *pad_bytes = 4 - (expected_pkt_len % 4);
149 } 150 }
150 return expected_pkt_len; 151 return expected_pkt_len;
151 } 152 }
152 153
153 } // namespace cricket 154 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/modules/video_capture/windows/sink_filter_ds.cc ('k') | webrtc/p2p/base/basicpacketsocketfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698