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

Side by Side Diff: trunk/src/content/renderer/p2p/socket_client_impl.cc

Issue 177603002: Revert 252408 "Adding talk_base::PacketOptions to P2P IPC Send m..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/content/renderer/p2p/socket_client_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_impl.h" 5 #include "content/renderer/p2p/socket_client_impl.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/public/renderer/p2p_socket_client_delegate.h" 10 #include "content/public/renderer/p2p_socket_client_delegate.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const net::IPEndPoint& local_address, 72 const net::IPEndPoint& local_address,
73 const net::IPEndPoint& remote_address) { 73 const net::IPEndPoint& remote_address) {
74 DCHECK_EQ(state_, STATE_UNINITIALIZED); 74 DCHECK_EQ(state_, STATE_UNINITIALIZED);
75 DCHECK(delegate_); 75 DCHECK(delegate_);
76 state_ = STATE_OPENING; 76 state_ = STATE_OPENING;
77 socket_id_ = dispatcher_->RegisterClient(this); 77 socket_id_ = dispatcher_->RegisterClient(this);
78 dispatcher_->SendP2PMessage(new P2PHostMsg_CreateSocket( 78 dispatcher_->SendP2PMessage(new P2PHostMsg_CreateSocket(
79 type, socket_id_, local_address, remote_address)); 79 type, socket_id_, local_address, remote_address));
80 } 80 }
81 81
82 void P2PSocketClientImpl::SendWithOptions( 82 void P2PSocketClientImpl::SendWithDscp(
83 const net::IPEndPoint& address, 83 const net::IPEndPoint& address,
84 const std::vector<char>& data, 84 const std::vector<char>& data,
85 const talk_base::PacketOptions& options) { 85 net::DiffServCodePoint dscp) {
86 if (!ipc_message_loop_->BelongsToCurrentThread()) { 86 if (!ipc_message_loop_->BelongsToCurrentThread()) {
87 ipc_message_loop_->PostTask( 87 ipc_message_loop_->PostTask(
88 FROM_HERE, base::Bind( 88 FROM_HERE, base::Bind(
89 &P2PSocketClientImpl::SendWithOptions, this, address, 89 &P2PSocketClientImpl::SendWithDscp, this, address, data, dscp));
90 data, options));
91 return; 90 return;
92 } 91 }
93 92
94 // Can send data only when the socket is open. 93 // Can send data only when the socket is open.
95 DCHECK(state_ == STATE_OPEN || state_ == STATE_ERROR); 94 DCHECK(state_ == STATE_OPEN || state_ == STATE_ERROR);
96 if (state_ == STATE_OPEN) { 95 if (state_ == STATE_OPEN) {
97 uint64 unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_); 96 uint64 unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_);
98 TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", unique_id); 97 TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", unique_id);
99 dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data, 98 dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data,
100 options, unique_id)); 99 dscp, unique_id));
101 } 100 }
102 } 101 }
103 102
104 void P2PSocketClientImpl::Send(const net::IPEndPoint& address, 103 void P2PSocketClientImpl::Send(const net::IPEndPoint& address,
105 const std::vector<char>& data) { 104 const std::vector<char>& data) {
106 talk_base::PacketOptions options(talk_base::DSCP_DEFAULT); 105 SendWithDscp(address, data, net::DSCP_DEFAULT);
107 SendWithOptions(address, data, options);
108 } 106 }
109 107
110 void P2PSocketClientImpl::SetOption(P2PSocketOption option, 108 void P2PSocketClientImpl::SetOption(P2PSocketOption option,
111 int value) { 109 int value) {
112 if (!ipc_message_loop_->BelongsToCurrentThread()) { 110 if (!ipc_message_loop_->BelongsToCurrentThread()) {
113 ipc_message_loop_->PostTask( 111 ipc_message_loop_->PostTask(
114 FROM_HERE, base::Bind( 112 FROM_HERE, base::Bind(
115 &P2PSocketClientImpl::SetOption, this, option, value)); 113 &P2PSocketClientImpl::SetOption, this, option, value));
116 return; 114 return;
117 } 115 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 delegate_->OnDataReceived(address, data, timestamp); 250 delegate_->OnDataReceived(address, data, timestamp);
253 } 251 }
254 252
255 void P2PSocketClientImpl::Detach() { 253 void P2PSocketClientImpl::Detach() {
256 DCHECK(ipc_message_loop_->BelongsToCurrentThread()); 254 DCHECK(ipc_message_loop_->BelongsToCurrentThread());
257 dispatcher_ = NULL; 255 dispatcher_ = NULL;
258 OnError(); 256 OnError();
259 } 257 }
260 258
261 } // namespace content 259 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/renderer/p2p/socket_client_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698