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

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
« no previous file with comments | « content/renderer/p2p/socket_client_impl.h ('k') | content/renderer/p2p/socket_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2dc0c7cbdeb59cf84b77222fa76499f20c2b44fe 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,31 +69,33 @@ 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::Send(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::SendWithPacketId, 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));
+ SendWithPacketId(address, data, options, unique_id);
}
+
+ return unique_id;
}
-void P2PSocketClientImpl::Send(const net::IPEndPoint& address,
- const std::vector<char>& data) {
- rtc::PacketOptions options(rtc::DSCP_DEFAULT);
- SendWithDscp(address, data, options);
+void P2PSocketClientImpl::SendWithPacketId(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::SetOption(P2PSocketOption option,
@@ -196,17 +198,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() {
« no previous file with comments | « content/renderer/p2p/socket_client_impl.h ('k') | content/renderer/p2p/socket_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698