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

Side by Side Diff: webrtc/p2p/base/turnport.cc

Issue 2623473004: Replace all use of the VERIFY macro. (Closed)
Patch Set: Delete a DCHECK, instead log and return failure. And fix compile error in previous patch set. 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 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 LOG_J(LS_INFO, this) << "Scheduled refresh in " << delay << "ms."; 920 LOG_J(LS_INFO, this) << "Scheduled refresh in " << delay << "ms.";
921 return true; 921 return true;
922 } 922 }
923 923
924 void TurnPort::SendRequest(StunRequest* req, int delay) { 924 void TurnPort::SendRequest(StunRequest* req, int delay) {
925 request_manager_.SendDelayed(req, delay); 925 request_manager_.SendDelayed(req, delay);
926 } 926 }
927 927
928 void TurnPort::AddRequestAuthInfo(StunMessage* msg) { 928 void TurnPort::AddRequestAuthInfo(StunMessage* msg) {
929 // If we've gotten the necessary data from the server, add it to our request. 929 // If we've gotten the necessary data from the server, add it to our request.
930 VERIFY(!hash_.empty()); 930 RTC_DCHECK(!hash_.empty());
931 msg->AddAttribute(new StunByteStringAttribute( 931 msg->AddAttribute(new StunByteStringAttribute(
932 STUN_ATTR_USERNAME, credentials_.username)); 932 STUN_ATTR_USERNAME, credentials_.username));
933 msg->AddAttribute(new StunByteStringAttribute( 933 msg->AddAttribute(new StunByteStringAttribute(
934 STUN_ATTR_REALM, realm_)); 934 STUN_ATTR_REALM, realm_));
935 msg->AddAttribute(new StunByteStringAttribute( 935 msg->AddAttribute(new StunByteStringAttribute(
936 STUN_ATTR_NONCE, nonce_)); 936 STUN_ATTR_NONCE, nonce_));
937 VERIFY(msg->AddMessageIntegrity(hash())); 937 const bool success = msg->AddMessageIntegrity(hash());
938 RTC_DCHECK(success);
938 } 939 }
939 940
940 int TurnPort::Send(const void* data, size_t len, 941 int TurnPort::Send(const void* data, size_t len,
941 const rtc::PacketOptions& options) { 942 const rtc::PacketOptions& options) {
942 return socket_->SendTo(data, len, server_address_.address, options); 943 return socket_->SendTo(data, len, server_address_.address, options);
943 } 944 }
944 945
945 void TurnPort::UpdateHash() { 946 void TurnPort::UpdateHash() {
946 VERIFY(ComputeStunCredentialHash(credentials_.username, realm_, 947 const bool success = ComputeStunCredentialHash(credentials_.username, realm_,
947 credentials_.password, &hash_)); 948 credentials_.password, &hash_);
949 RTC_DCHECK(success);
948 } 950 }
949 951
950 bool TurnPort::UpdateNonce(StunMessage* response) { 952 bool TurnPort::UpdateNonce(StunMessage* response) {
951 // When stale nonce error received, we should update 953 // When stale nonce error received, we should update
952 // hash and store realm and nonce. 954 // hash and store realm and nonce.
953 // Check the mandatory attributes. 955 // Check the mandatory attributes.
954 const StunByteStringAttribute* realm_attr = 956 const StunByteStringAttribute* realm_attr =
955 response->GetByteString(STUN_ATTR_REALM); 957 response->GetByteString(STUN_ATTR_REALM);
956 if (!realm_attr) { 958 if (!realm_attr) {
957 LOG(LS_ERROR) << "Missing STUN_ATTR_REALM attribute in " 959 LOG(LS_ERROR) << "Missing STUN_ATTR_REALM attribute in "
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 if (state_ != STATE_BOUND) { 1470 if (state_ != STATE_BOUND) {
1469 // If we haven't bound the channel yet, we have to use a Send Indication. 1471 // If we haven't bound the channel yet, we have to use a Send Indication.
1470 TurnMessage msg; 1472 TurnMessage msg;
1471 msg.SetType(TURN_SEND_INDICATION); 1473 msg.SetType(TURN_SEND_INDICATION);
1472 msg.SetTransactionID( 1474 msg.SetTransactionID(
1473 rtc::CreateRandomString(kStunTransactionIdLength)); 1475 rtc::CreateRandomString(kStunTransactionIdLength));
1474 msg.AddAttribute(new StunXorAddressAttribute( 1476 msg.AddAttribute(new StunXorAddressAttribute(
1475 STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); 1477 STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
1476 msg.AddAttribute(new StunByteStringAttribute( 1478 msg.AddAttribute(new StunByteStringAttribute(
1477 STUN_ATTR_DATA, data, size)); 1479 STUN_ATTR_DATA, data, size));
1478 VERIFY(msg.Write(&buf)); 1480 const bool success = msg.Write(&buf);
1481 RTC_DCHECK(success);
1479 1482
1480 // If we're sending real data, request a channel bind that we can use later. 1483 // If we're sending real data, request a channel bind that we can use later.
1481 if (state_ == STATE_UNBOUND && payload) { 1484 if (state_ == STATE_UNBOUND && payload) {
1482 SendChannelBindRequest(0); 1485 SendChannelBindRequest(0);
1483 state_ = STATE_BINDING; 1486 state_ = STATE_BINDING;
1484 } 1487 }
1485 } else { 1488 } else {
1486 // If the channel is bound, we can send the data as a Channel Message. 1489 // If the channel is bound, we can send the data as a Channel Message.
1487 buf.WriteUInt16(channel_id_); 1490 buf.WriteUInt16(channel_id_);
1488 buf.WriteUInt16(static_cast<uint16_t>(size)); 1491 buf.WriteUInt16(static_cast<uint16_t>(size));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 } else { 1552 } else {
1550 state_ = STATE_UNBOUND; 1553 state_ = STATE_UNBOUND;
1551 port_->FailAndPruneConnection(ext_addr_); 1554 port_->FailAndPruneConnection(ext_addr_);
1552 } 1555 }
1553 } 1556 }
1554 void TurnEntry::OnChannelBindTimeout() { 1557 void TurnEntry::OnChannelBindTimeout() {
1555 state_ = STATE_UNBOUND; 1558 state_ = STATE_UNBOUND;
1556 port_->FailAndPruneConnection(ext_addr_); 1559 port_->FailAndPruneConnection(ext_addr_);
1557 } 1560 }
1558 } // namespace cricket 1561 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698