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

Unified Diff: content/renderer/p2p/socket_client_impl.cc

Issue 759923003: Detect situation when there is no missing send completion signal in P2PSocket implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
Index: content/renderer/p2p/socket_client_impl.cc
diff --git a/content/renderer/p2p/socket_client_impl.cc b/content/renderer/p2p/socket_client_impl.cc
index 1425151089cf42930e66dfd190dff516af893b44..6e802aabf72fc1b151fe4f6eb951864b6ed0e95a 100644
--- a/content/renderer/p2p/socket_client_impl.cc
+++ b/content/renderer/p2p/socket_client_impl.cc
@@ -15,8 +15,8 @@
namespace {
-uint64 GetUniqueId(uint32 random_socket_id, uint32 packet_id) {
- uint64 uid = random_socket_id;
+uint64_t GetUniqueId(uint32 random_socket_id, uint32 packet_id) {
+ uint64_t uid = random_socket_id;
uid <<= 32;
uid |= packet_id;
return uid;
@@ -69,25 +69,34 @@ void P2PSocketClientImpl::DoInit(P2PSocketType type,
type, socket_id_, local_address, remote_address));
}
-void P2PSocketClientImpl::SendWithDscp(
- const net::IPEndPoint& address,
- const std::vector<char>& data,
- const rtc::PacketOptions& options) {
+uint64_t P2PSocketClientImpl::SendWithDscp(const net::IPEndPoint& address,
+ const std::vector<char>& data,
+ const rtc::PacketOptions& options) {
+ uint64_t unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_);
if (!ipc_message_loop_->BelongsToCurrentThread()) {
ipc_message_loop_->PostTask(
- FROM_HERE, base::Bind(
- &P2PSocketClientImpl::SendWithDscp, this, address, data, options));
- return;
+ FROM_HERE, base::Bind(&P2PSocketClientImpl::SendWithDscpAndPacketId,
+ this, address, data, options, unique_id));
+ return unique_id;
}
// Can send data only when the socket is open.
DCHECK(state_ == STATE_OPEN || state_ == STATE_ERROR);
if (state_ == STATE_OPEN) {
- uint64 unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_);
- TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", unique_id);
- dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data,
- options, unique_id));
+ SendWithDscpAndPacketId(address, data, options, unique_id);
}
+
+ return unique_id;
+}
+
+void P2PSocketClientImpl::SendWithDscpAndPacketId(
+ const net::IPEndPoint& address,
+ const std::vector<char>& data,
+ const rtc::PacketOptions& options,
+ uint64_t packet_id) {
+ TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", packet_id);
+ dispatcher_->SendP2PMessage(
+ new P2PHostMsg_Send(socket_id_, address, data, options, packet_id));
}
void P2PSocketClientImpl::Send(const net::IPEndPoint& address,
@@ -196,17 +205,20 @@ void P2PSocketClientImpl::DeliverOnIncomingTcpConnection(
}
}
-void P2PSocketClientImpl::OnSendComplete() {
+void P2PSocketClientImpl::OnSendComplete(
+ const P2PSendPacketMetrics& send_metrics) {
DCHECK(ipc_message_loop_->BelongsToCurrentThread());
delegate_message_loop_->PostTask(
- FROM_HERE, base::Bind(&P2PSocketClientImpl::DeliverOnSendComplete, this));
+ FROM_HERE, base::Bind(&P2PSocketClientImpl::DeliverOnSendComplete, this,
+ send_metrics));
}
-void P2PSocketClientImpl::DeliverOnSendComplete() {
+void P2PSocketClientImpl::DeliverOnSendComplete(
+ const P2PSendPacketMetrics& send_metrics) {
DCHECK(delegate_message_loop_->BelongsToCurrentThread());
if (delegate_)
- delegate_->OnSendComplete();
+ delegate_->OnSendComplete(send_metrics);
}
void P2PSocketClientImpl::OnError() {

Powered by Google App Engine
This is Rietveld 408576698