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

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: stub out DSCP for windows for now Created 7 years, 3 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 54c2b4cd4edba8b64435ce5a1990ba390916d1ba..0a92c1ea8c72aa2824e63b077f5b081cd8ec48f9 100644
--- a/content/browser/renderer_host/p2p/socket_host_udp.cc
+++ b/content/browser/renderer_host/p2p/socket_host_udp.cc
@@ -51,11 +51,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);
}
@@ -69,7 +73,8 @@ P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender,
socket_(new net::UDPServerSocket(NULL, net::NetLog::Source())),
send_pending_(false),
send_packet_count_(0),
- throttler_(throttler) {
+ throttler_(throttler),
+ last_dscp_(net::DSCP_CS0) {
}
P2PSocketHostUdp::~P2PSocketHostUdp() {
@@ -168,7 +173,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.
@@ -193,9 +199,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_;
@@ -205,6 +211,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_->SetDiffServCodePoint(packet.dscp);
+ if (result == net::OK) {
+ last_dscp_ = packet.dscp;
+ } else if (!IsTransientError(result) && last_dscp_ != net::DSCP_CS0) {
+ // 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