OLD | NEW |
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_tcp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
6 | 6 |
7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
8 #include "content/common/p2p_messages.h" | 8 #include "content/common/p2p_messages.h" |
9 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // We've consumed all complete packets from the buffer; now move any remaining | 179 // We've consumed all complete packets from the buffer; now move any remaining |
180 // bytes to the head of the buffer and set offset to reflect this. | 180 // bytes to the head of the buffer and set offset to reflect this. |
181 if (consumed && consumed <= read_buffer_->offset()) { | 181 if (consumed && consumed <= read_buffer_->offset()) { |
182 memmove(head, head + consumed, read_buffer_->offset() - consumed); | 182 memmove(head, head + consumed, read_buffer_->offset() - consumed); |
183 read_buffer_->set_offset(read_buffer_->offset() - consumed); | 183 read_buffer_->set_offset(read_buffer_->offset() - consumed); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 void P2PSocketHostTcp::Send(const net::IPEndPoint& to, | 187 void P2PSocketHostTcp::Send(const net::IPEndPoint& to, |
188 const std::vector<char>& data) { | 188 const std::vector<char>& data) { |
189 if (!socket_.get()) { | 189 if (!socket_) { |
190 // The Send message may be sent after the an OnError message was | 190 // The Send message may be sent after the an OnError message was |
191 // sent by hasn't been processed the renderer. | 191 // sent by hasn't been processed the renderer. |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 if (!(to == remote_address_)) { | 195 if (!(to == remote_address_)) { |
196 // Renderer should use this socket only to send data to |remote_address_|. | 196 // Renderer should use this socket only to send data to |remote_address_|. |
197 NOTREACHED(); | 197 NOTREACHED(); |
198 OnError(); | 198 OnError(); |
199 return; | 199 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 | 261 |
262 P2PSocketHost* P2PSocketHostTcp::AcceptIncomingTcpConnection( | 262 P2PSocketHost* P2PSocketHostTcp::AcceptIncomingTcpConnection( |
263 const net::IPEndPoint& remote_address, int id) { | 263 const net::IPEndPoint& remote_address, int id) { |
264 NOTREACHED(); | 264 NOTREACHED(); |
265 OnError(); | 265 OnError(); |
266 return NULL; | 266 return NULL; |
267 } | 267 } |
268 | 268 |
269 } // namespace content | 269 } // namespace content |
OLD | NEW |