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

Unified Diff: webrtc/p2p/base/port.cc

Issue 1800753003: Port::GetStunMessage: Write to scoped_ptr instead of raw pointer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Let caller worry about clearing the output argument Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index ed26fe494c0b00d0abad104d917eb2de78a96785..a630695b0599b8285fd59a684b62e0e51789012a 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -288,7 +288,7 @@ void Port::OnReadPacket(
// send back a proper binding response.
rtc::scoped_ptr<IceMessage> msg;
std::string remote_username;
- if (!GetStunMessage(data, size, addr, msg.accept(), &remote_username)) {
+ if (!GetStunMessage(data, size, addr, &msg, &remote_username)) {
LOG_J(LS_ERROR, this) << "Received non-STUN packet from unknown address ("
<< addr.ToSensitiveString() << ")";
} else if (!msg) {
@@ -330,15 +330,16 @@ size_t Port::AddPrflxCandidate(const Candidate& local) {
return (candidates_.size() - 1);
}
-bool Port::GetStunMessage(const char* data, size_t size,
+bool Port::GetStunMessage(const char* data,
+ size_t size,
const rtc::SocketAddress& addr,
- IceMessage** out_msg, std::string* out_username) {
+ rtc::scoped_ptr<IceMessage>* out_msg,
+ std::string* out_username) {
// NOTE: This could clearly be optimized to avoid allocating any memory.
// However, at the data rates we'll be looking at on the client side,
// this probably isn't worth worrying about.
ASSERT(out_msg != NULL);
ASSERT(out_username != NULL);
- *out_msg = NULL;
out_username->clear();
// Don't bother parsing the packet if we can tell it's not STUN.
@@ -422,7 +423,7 @@ bool Port::GetStunMessage(const char* data, size_t size,
}
// Return the STUN message found.
- *out_msg = stun_msg.release();
+ *out_msg = std::move(stun_msg);
return true;
}
@@ -902,7 +903,7 @@ void Connection::OnReadPacket(
rtc::scoped_ptr<IceMessage> msg;
std::string remote_ufrag;
const rtc::SocketAddress& addr(remote_candidate_.address());
- if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) {
+ if (!port_->GetStunMessage(data, size, addr, &msg, &remote_ufrag)) {
// The packet did not parse as a valid STUN message
// This is a data packet, pass it along.
set_receiving(true);
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698