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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_udp.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/p2p/socket_host_udp.h" 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "content/common/p2p_messages.h" 9 #include "content/common/p2p_messages.h"
10 #include "ipc/ipc_sender.h" 10 #include "ipc/ipc_sender.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 if (state_ == STATE_UNINITIALIZED || state_ == STATE_OPEN) 103 if (state_ == STATE_UNINITIALIZED || state_ == STATE_OPEN)
104 message_sender_->Send(new P2PMsg_OnError(id_)); 104 message_sender_->Send(new P2PMsg_OnError(id_));
105 105
106 state_ = STATE_ERROR; 106 state_ = STATE_ERROR;
107 } 107 }
108 108
109 void P2PSocketHostUdp::DoRead() { 109 void P2PSocketHostUdp::DoRead() {
110 int result; 110 int result;
111 do { 111 do {
112 result = socket_->RecvFrom(recv_buffer_, kReadBufferSize, &recv_address_, 112 result = socket_->RecvFrom(
113 base::Bind(&P2PSocketHostUdp::OnRecv, 113 recv_buffer_.get(),
114 base::Unretained(this))); 114 kReadBufferSize,
115 &recv_address_,
116 base::Bind(&P2PSocketHostUdp::OnRecv, base::Unretained(this)));
115 if (result == net::ERR_IO_PENDING) 117 if (result == net::ERR_IO_PENDING)
116 return; 118 return;
117 HandleReadResult(result); 119 HandleReadResult(result);
118 } while (state_ == STATE_OPEN); 120 } while (state_ == STATE_OPEN);
119 } 121 }
120 122
121 void P2PSocketHostUdp::OnRecv(int result) { 123 void P2PSocketHostUdp::OnRecv(int result) {
122 HandleReadResult(result); 124 HandleReadResult(result);
123 if (state_ == STATE_OPEN) { 125 if (state_ == STATE_OPEN) {
124 DoRead(); 126 DoRead();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 send_queue_.push_back(PendingPacket(to, data)); 176 send_queue_.push_back(PendingPacket(to, data));
175 } else { 177 } else {
176 PendingPacket packet(to, data); 178 PendingPacket packet(to, data);
177 DoSend(packet); 179 DoSend(packet);
178 } 180 }
179 } 181 }
180 182
181 void P2PSocketHostUdp::DoSend(const PendingPacket& packet) { 183 void P2PSocketHostUdp::DoSend(const PendingPacket& packet) {
182 TRACE_EVENT_ASYNC_BEGIN2("p2p", "Udp::DoSend", this, 184 TRACE_EVENT_ASYNC_BEGIN2("p2p", "Udp::DoSend", this,
183 "id", id_, "size", packet.size); 185 "id", id_, "size", packet.size);
184 int result = socket_->SendTo(packet.data, packet.size, packet.to, 186 int result = socket_->SendTo(
185 base::Bind(&P2PSocketHostUdp::OnSend, 187 packet.data.get(),
186 base::Unretained(this))); 188 packet.size,
189 packet.to,
190 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this)));
187 191
188 // sendto() may return an error, e.g. if we've received an ICMP Destination 192 // sendto() may return an error, e.g. if we've received an ICMP Destination
189 // Unreachable message. When this happens try sending the same packet again, 193 // Unreachable message. When this happens try sending the same packet again,
190 // and just drop it if it fails again. 194 // and just drop it if it fails again.
191 if (IsTransientError(result)) { 195 if (IsTransientError(result)) {
192 result = socket_->SendTo(packet.data, packet.size, packet.to, 196 result = socket_->SendTo(
193 base::Bind(&P2PSocketHostUdp::OnSend, 197 packet.data.get(),
194 base::Unretained(this))); 198 packet.size,
199 packet.to,
200 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this)));
195 } 201 }
196 202
197 if (result == net::ERR_IO_PENDING) { 203 if (result == net::ERR_IO_PENDING) {
198 send_pending_ = true; 204 send_pending_ = true;
199 } else { 205 } else {
200 HandleSendResult(result); 206 HandleSendResult(result);
201 } 207 }
202 } 208 }
203 209
204 void P2PSocketHostUdp::OnSend(int result) { 210 void P2PSocketHostUdp::OnSend(int result) {
(...skipping 25 matching lines...) Expand all
230 } 236 }
231 237
232 P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection( 238 P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection(
233 const net::IPEndPoint& remote_address, int id) { 239 const net::IPEndPoint& remote_address, int id) {
234 NOTREACHED(); 240 NOTREACHED();
235 OnError(); 241 OnError();
236 return NULL; 242 return NULL;
237 } 243 }
238 244
239 } // namespace content 245 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_tcp.cc ('k') | content/browser/renderer_host/pepper/pepper_tcp_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698