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

Side by Side Diff: content/renderer/p2p/socket_client.cc

Issue 22381012: Allow p2p UDP packages to set DSCP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/p2p/socket_client.h ('k') | net/base/net_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/p2p/socket_client.h" 5 #include "content/renderer/p2p/socket_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "content/common/p2p_messages.h" 9 #include "content/common/p2p_messages.h"
10 #include "content/renderer/p2p/socket_dispatcher.h" 10 #include "content/renderer/p2p/socket_dispatcher.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const net::IPEndPoint& local_address, 56 const net::IPEndPoint& local_address,
57 const net::IPEndPoint& remote_address) { 57 const net::IPEndPoint& remote_address) {
58 DCHECK_EQ(state_, STATE_UNINITIALIZED); 58 DCHECK_EQ(state_, STATE_UNINITIALIZED);
59 DCHECK(delegate_); 59 DCHECK(delegate_);
60 state_ = STATE_OPENING; 60 state_ = STATE_OPENING;
61 socket_id_ = dispatcher_->RegisterClient(this); 61 socket_id_ = dispatcher_->RegisterClient(this);
62 dispatcher_->SendP2PMessage(new P2PHostMsg_CreateSocket( 62 dispatcher_->SendP2PMessage(new P2PHostMsg_CreateSocket(
63 type, socket_id_, local_address, remote_address)); 63 type, socket_id_, local_address, remote_address));
64 } 64 }
65 65
66 void P2PSocketClient::Send(const net::IPEndPoint& address, 66 void P2PSocketClient::SendWithDscp(
67 const std::vector<char>& data) { 67 const net::IPEndPoint& address,
68 const std::vector<char>& data,
69 net::DiffServCodePoint dscp) {
68 if (!ipc_message_loop_->BelongsToCurrentThread()) { 70 if (!ipc_message_loop_->BelongsToCurrentThread()) {
69 ipc_message_loop_->PostTask( 71 ipc_message_loop_->PostTask(
70 FROM_HERE, base::Bind(&P2PSocketClient::Send, this, address, data)); 72 FROM_HERE, base::Bind(&P2PSocketClient::Send, this, address, data));
71 return; 73 return;
72 } 74 }
73 75
74 // Can send data only when the socket is open. 76 // Can send data only when the socket is open.
75 DCHECK(state_ == STATE_OPEN || state_ == STATE_ERROR); 77 DCHECK(state_ == STATE_OPEN || state_ == STATE_ERROR);
76 if (state_ == STATE_OPEN) { 78 if (state_ == STATE_OPEN) {
77 uint64 unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_); 79 uint64 unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_);
78 TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", unique_id); 80 TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", unique_id);
79 dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data, 81 dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data,
80 unique_id)); 82 dscp, unique_id));
81 } 83 }
82 } 84 }
83 85
86 void P2PSocketClient::Send(const net::IPEndPoint& address,
87 const std::vector<char>& data) {
88 SendWithDscp(address, data, net::DSCP_DEFAULT);
89 }
90
84 void P2PSocketClient::Close() { 91 void P2PSocketClient::Close() {
85 DCHECK(delegate_message_loop_->BelongsToCurrentThread()); 92 DCHECK(delegate_message_loop_->BelongsToCurrentThread());
86 93
87 delegate_ = NULL; 94 delegate_ = NULL;
88 95
89 ipc_message_loop_->PostTask( 96 ipc_message_loop_->PostTask(
90 FROM_HERE, base::Bind(&P2PSocketClient::DoClose, this)); 97 FROM_HERE, base::Bind(&P2PSocketClient::DoClose, this));
91 } 98 }
92 99
93 void P2PSocketClient::DoClose() { 100 void P2PSocketClient::DoClose() {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 delegate_->OnDataReceived(address, data); 202 delegate_->OnDataReceived(address, data);
196 } 203 }
197 204
198 void P2PSocketClient::Detach() { 205 void P2PSocketClient::Detach() {
199 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); 206 DCHECK(ipc_message_loop_->BelongsToCurrentThread());
200 dispatcher_ = NULL; 207 dispatcher_ = NULL;
201 OnError(); 208 OnError();
202 } 209 }
203 210
204 } // namespace content 211 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/p2p/socket_client.h ('k') | net/base/net_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698