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

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

Issue 22381012: Allow p2p UDP packages to set DSCP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: extra newline removed Created 7 years, 4 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 bcfb282a2c42c52b3bf34de53a68ed25c05f2402..52ca71b01493d950c792e180427dce6ee9d81c00 100644
--- a/content/browser/renderer_host/p2p/socket_host_udp.cc
+++ b/content/browser/renderer_host/p2p/socket_host_udp.cc
@@ -50,11 +50,15 @@ uint64 GetUniqueEventId(const content::P2PSocketHostUdp* obj,
namespace content {
P2PSocketHostUdp::PendingPacket::PendingPacket(
- const net::IPEndPoint& to, const std::vector<char>& content, uint64 id)
+ const net::IPEndPoint& to,
+ const std::vector<char>& content,
+ uint64 id,
+ net::DiffServCodePoint dscp_)
: to(to),
data(new net::IOBuffer(content.size())),
size(content.size()),
- id(id) {
+ id(id),
+ dscp(dscp_) {
memcpy(data->data(), &content[0], size);
}
@@ -65,7 +69,8 @@ P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, int id)
: P2PSocketHost(message_sender, id),
socket_(new net::UDPServerSocket(NULL, net::NetLog::Source())),
send_pending_(false),
- send_packet_count_(0) {
+ send_packet_count_(0),
+ last_dscp_(net::DSCP_CS0) {
}
P2PSocketHostUdp::~P2PSocketHostUdp() {
@@ -164,7 +169,8 @@ void P2PSocketHostUdp::HandleReadResult(int result) {
}
void P2PSocketHostUdp::Send(const net::IPEndPoint& to,
- const std::vector<char>& data) {
+ const std::vector<char>& data,
+ net::DiffServCodePoint dscp) {
if (!socket_) {
// The Send message may be sent after the an OnError message was
// sent by hasn't been processed the renderer.
@@ -183,9 +189,9 @@ void P2PSocketHostUdp::Send(const net::IPEndPoint& to,
}
if (send_pending_) {
- send_queue_.push_back(PendingPacket(to, data, send_packet_count_));
+ send_queue_.push_back(PendingPacket(to, data, send_packet_count_, dscp));
} else {
- PendingPacket packet(to, data, send_packet_count_);
+ PendingPacket packet(to, data, send_packet_count_, dscp);
DoSend(packet);
}
++send_packet_count_;
@@ -195,6 +201,17 @@ void P2PSocketHostUdp::DoSend(const PendingPacket& packet) {
TRACE_EVENT_ASYNC_BEGIN1("p2p", "Udp::DoSend",
GetUniqueEventId(this, packet.id),
"size", packet.size);
+ if (last_dscp_ != packet.dscp && last_dscp_ != net::DSCP_NO_CHANGE) {
+ int result = socket_->SetToS(packet.dscp);
+ if (result == net::OK) {
+ last_dscp_ = packet.dscp;
+ } else if (!IsTransientError(result) && last_dscp_ != net::DSCP_CS0) {
Sergey Ulanov 2013/08/17 05:50:04 IsTransientError() is used for errors returned fro
hubbe 2013/08/21 18:51:36 On some platforms setsockopt() IP_TOS is a privile
+ // We receieved a non-transient error, and it seems we have
+ // not changed the DSCP in the past, disable DSCP as it unlikely
+ // to work in the future.
+ last_dscp_ = net::DSCP_NO_CHANGE;
+ }
+ }
int result = socket_->SendTo(
packet.data.get(),
packet.size,

Powered by Google App Engine
This is Rietveld 408576698