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

Unified Diff: content/browser/renderer_host/p2p/socket_host_udp.cc

Issue 13584008: Send notification about outgoing p2p packets from browser to renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: content/browser/renderer_host/p2p/socket_host_udp.cc
diff --git a/content/browser/renderer_host/p2p/socket_host_udp.cc b/content/browser/renderer_host/p2p/socket_host_udp.cc
index b84ee688e5dc064df1004268a50c6d2c1b846cc4..21ae1d9d25a66bc79f014c366c76a2b847b6b8fa 100644
--- a/content/browser/renderer_host/p2p/socket_host_udp.cc
+++ b/content/browser/renderer_host/p2p/socket_host_udp.cc
@@ -42,7 +42,6 @@ P2PSocketHostUdp::PendingPacket::~PendingPacket() {
P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, int id)
: P2PSocketHost(message_sender, id),
socket_(new net::UDPServerSocket(NULL, net::NetLog::Source())),
- send_queue_bytes_(0),
send_pending_(false) {
}
@@ -139,6 +138,7 @@ void P2PSocketHostUdp::DidCompleteRead(int result) {
}
}
+
Ronghua Wu (Left Chromium) 2013/04/04 05:23:59 remove extra line
Sergey Ulanov 2013/04/04 18:40:34 Done.
void P2PSocketHostUdp::Send(const net::IPEndPoint& to,
const std::vector<char>& data) {
if (!socket_.get()) {
@@ -159,13 +159,7 @@ void P2PSocketHostUdp::Send(const net::IPEndPoint& to,
}
if (send_pending_) {
- if (send_queue_bytes_ + static_cast<int>(data.size()) >
- kMaxSendBufferSize) {
- LOG(WARNING) << "Send buffer is full. Dropping a packet.";
- return;
- }
send_queue_.push_back(PendingPacket(to, data));
- send_queue_bytes_ += data.size();
} else {
PendingPacket packet(to, data);
DoSend(packet);
@@ -188,12 +182,8 @@ void P2PSocketHostUdp::DoSend(const PendingPacket& packet) {
if (result == net::ERR_IO_PENDING) {
send_pending_ = true;
- } else if (IsTransientError(result)) {
- LOG(INFO) << "sendto() has failed twice returning a "
- " transient error. Dropping the packet.";
- } else if (result < 0) {
- LOG(ERROR) << "Error when sending data in UDP socket: " << result;
- OnError();
+ } else {
+ DidCompleteSend(result);
}
}
@@ -203,19 +193,27 @@ void P2PSocketHostUdp::OnSend(int result) {
send_pending_ = false;
- if (result < 0 && !IsTransientError(result)) {
- OnError();
- return;
- }
+ DidCompleteSend(result);
// Send next packets if we have them waiting in the buffer.
- while (!send_queue_.empty() && !send_pending_) {
+ while (state_ == STATE_OPEN && !send_queue_.empty() && !send_pending_) {
DoSend(send_queue_.front());
- send_queue_bytes_ -= send_queue_.front().size;
send_queue_.pop_front();
}
}
+void P2PSocketHostUdp::DidCompleteSend(int result) {
Ronghua Wu (Left Chromium) 2013/04/04 05:23:59 HandleSendResult?
Sergey Ulanov 2013/04/04 18:40:34 Done. Also renamed DidReadComplete().
+ if (result > 0) {
+ message_sender_->Send(new P2PMsg_OnSendComplete(id_));
+ } else if (IsTransientError(result)) {
+ LOG(INFO) << "sendto() has failed twice returning a "
+ " transient error. Dropping the packet.";
Ronghua Wu (Left Chromium) 2013/04/04 05:23:59 indent
Sergey Ulanov 2013/04/04 18:40:34 I believe it's indented correctly (there is no <<
+ } else if (result < 0) {
+ LOG(ERROR) << "Error when sending data in UDP socket: " << result;
+ OnError();
+ }
+}
+
P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection(
const net::IPEndPoint& remote_address, int id) {
NOTREACHED();

Powered by Google App Engine
This is Rietveld 408576698