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

Side by Side Diff: webrtc/p2p/base/basicpacketsocketfactory.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/p2p/base/asyncstuntcpsocket.cc ('k') | webrtc/p2p/base/candidate.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 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 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
11 #include "webrtc/p2p/base/basicpacketsocketfactory.h" 11 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "webrtc/p2p/base/asyncstuntcpsocket.h" 15 #include "webrtc/p2p/base/asyncstuntcpsocket.h"
16 #include "webrtc/p2p/base/stun.h" 16 #include "webrtc/p2p/base/stun.h"
17 #include "webrtc/base/asynctcpsocket.h" 17 #include "webrtc/base/asynctcpsocket.h"
18 #include "webrtc/base/asyncudpsocket.h" 18 #include "webrtc/base/asyncudpsocket.h"
19 #include "webrtc/base/checks.h"
19 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
20 #include "webrtc/base/nethelpers.h" 21 #include "webrtc/base/nethelpers.h"
21 #include "webrtc/base/physicalsocketserver.h" 22 #include "webrtc/base/physicalsocketserver.h"
22 #include "webrtc/base/socketadapters.h" 23 #include "webrtc/base/socketadapters.h"
23 #include "webrtc/base/ssladapter.h" 24 #include "webrtc/base/ssladapter.h"
24 #include "webrtc/base/thread.h" 25 #include "webrtc/base/thread.h"
25 26
26 namespace rtc { 27 namespace rtc {
27 28
28 BasicPacketSocketFactory::BasicPacketSocketFactory() 29 BasicPacketSocketFactory::BasicPacketSocketFactory()
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 83
83 if (BindSocket(socket, local_address, min_port, max_port) < 0) { 84 if (BindSocket(socket, local_address, min_port, max_port) < 0) {
84 LOG(LS_ERROR) << "TCP bind failed with error " 85 LOG(LS_ERROR) << "TCP bind failed with error "
85 << socket->GetError(); 86 << socket->GetError();
86 delete socket; 87 delete socket;
87 return NULL; 88 return NULL;
88 } 89 }
89 90
90 // If using fake TLS, wrap the TCP socket in a pseudo-SSL socket. 91 // If using fake TLS, wrap the TCP socket in a pseudo-SSL socket.
91 if (opts & PacketSocketFactory::OPT_TLS_FAKE) { 92 if (opts & PacketSocketFactory::OPT_TLS_FAKE) {
92 ASSERT(!(opts & PacketSocketFactory::OPT_TLS)); 93 RTC_DCHECK(!(opts & PacketSocketFactory::OPT_TLS));
93 socket = new AsyncSSLSocket(socket); 94 socket = new AsyncSSLSocket(socket);
94 } 95 }
95 96
96 // Set TCP_NODELAY (via OPT_NODELAY) for improved performance. 97 // Set TCP_NODELAY (via OPT_NODELAY) for improved performance.
97 // See http://go/gtalktcpnodelayexperiment 98 // See http://go/gtalktcpnodelayexperiment
98 socket->SetOption(Socket::OPT_NODELAY, 1); 99 socket->SetOption(Socket::OPT_NODELAY, 1);
99 100
100 if (opts & PacketSocketFactory::OPT_STUN) 101 if (opts & PacketSocketFactory::OPT_STUN)
101 return new cricket::AsyncStunTCPSocket(socket, true); 102 return new cricket::AsyncStunTCPSocket(socket, true);
102 103
(...skipping 23 matching lines...) Expand all
126 } else if (proxy_info.type == PROXY_HTTPS) { 127 } else if (proxy_info.type == PROXY_HTTPS) {
127 socket = 128 socket =
128 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address, 129 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address,
129 proxy_info.username, proxy_info.password); 130 proxy_info.username, proxy_info.password);
130 } 131 }
131 132
132 // Assert that at most one TLS option is used. 133 // Assert that at most one TLS option is used.
133 int tlsOpts = 134 int tlsOpts =
134 opts & (PacketSocketFactory::OPT_TLS | PacketSocketFactory::OPT_TLS_FAKE | 135 opts & (PacketSocketFactory::OPT_TLS | PacketSocketFactory::OPT_TLS_FAKE |
135 PacketSocketFactory::OPT_TLS_INSECURE); 136 PacketSocketFactory::OPT_TLS_INSECURE);
136 ASSERT((tlsOpts & (tlsOpts - 1)) == 0); 137 RTC_DCHECK((tlsOpts & (tlsOpts - 1)) == 0);
137 138
138 if ((tlsOpts & PacketSocketFactory::OPT_TLS) || 139 if ((tlsOpts & PacketSocketFactory::OPT_TLS) ||
139 (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE)) { 140 (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE)) {
140 // Using TLS, wrap the socket in an SSL adapter. 141 // Using TLS, wrap the socket in an SSL adapter.
141 SSLAdapter* ssl_adapter = SSLAdapter::Create(socket); 142 SSLAdapter* ssl_adapter = SSLAdapter::Create(socket);
142 if (!ssl_adapter) { 143 if (!ssl_adapter) {
143 return NULL; 144 return NULL;
144 } 145 }
145 146
146 if (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE) { 147 if (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Otherwise, try to find a port in the provided range. 198 // Otherwise, try to find a port in the provided range.
198 for (int port = min_port; ret < 0 && port <= max_port; ++port) { 199 for (int port = min_port; ret < 0 && port <= max_port; ++port) {
199 ret = socket->Bind(SocketAddress(local_address.ipaddr(), port)); 200 ret = socket->Bind(SocketAddress(local_address.ipaddr(), port));
200 } 201 }
201 } 202 }
202 return ret; 203 return ret;
203 } 204 }
204 205
205 SocketFactory* BasicPacketSocketFactory::socket_factory() { 206 SocketFactory* BasicPacketSocketFactory::socket_factory() {
206 if (thread_) { 207 if (thread_) {
207 ASSERT(thread_ == Thread::Current()); 208 RTC_DCHECK(thread_ == Thread::Current());
208 return thread_->socketserver(); 209 return thread_->socketserver();
209 } else { 210 } else {
210 return socket_factory_; 211 return socket_factory_;
211 } 212 }
212 } 213 }
213 214
214 } // namespace rtc 215 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/p2p/base/asyncstuntcpsocket.cc ('k') | webrtc/p2p/base/candidate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698