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 "jingle/glue/fake_ssl_client_socket.h" | 10 #include "jingle/glue/fake_ssl_client_socket.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 P2PSocketHostTcpBase::P2PSocketHostTcpBase( | 47 P2PSocketHostTcpBase::P2PSocketHostTcpBase( |
48 IPC::Sender* message_sender, | 48 IPC::Sender* message_sender, |
49 int socket_id, | 49 int socket_id, |
50 P2PSocketType type, | 50 P2PSocketType type, |
51 net::URLRequestContextGetter* url_context) | 51 net::URLRequestContextGetter* url_context) |
52 : P2PSocketHost(message_sender, socket_id), | 52 : P2PSocketHost(message_sender, socket_id), |
53 write_pending_(false), | 53 write_pending_(false), |
54 connected_(false), | 54 connected_(false), |
55 type_(type), | 55 type_(type), |
56 url_context_(url_context) { | 56 url_context_(url_context) { |
57 protocol_type_ = P2PSocketHost::TCP; | |
57 } | 58 } |
58 | 59 |
59 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { | 60 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { |
60 if (state_ == STATE_OPEN) { | 61 if (state_ == STATE_OPEN) { |
61 DCHECK(socket_.get()); | 62 DCHECK(socket_.get()); |
62 socket_.reset(); | 63 socket_.reset(); |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 bool P2PSocketHostTcpBase::InitAccepted(const net::IPEndPoint& remote_address, | 67 bool P2PSocketHostTcpBase::InitAccepted(const net::IPEndPoint& remote_address, |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } | 357 } |
357 } | 358 } |
358 | 359 |
359 DoSend(to, data, options); | 360 DoSend(to, data, options); |
360 } | 361 } |
361 | 362 |
362 void P2PSocketHostTcpBase::WriteOrQueue( | 363 void P2PSocketHostTcpBase::WriteOrQueue( |
363 scoped_refptr<net::DrainableIOBuffer>& buffer) { | 364 scoped_refptr<net::DrainableIOBuffer>& buffer) { |
364 if (write_buffer_.get()) { | 365 if (write_buffer_.get()) { |
365 write_queue_.push(buffer); | 366 write_queue_.push(buffer); |
367 if (write_queue_.size() > send_queue_length_max_) { | |
juberti2
2014/10/23 19:38:46
I think we should record the total byte size rathe
guoweis2
2014/10/24 06:08:54
Done. Also changed the WebRTC's socket layer to co
| |
368 send_queue_length_max_ = write_queue_.size(); | |
369 } | |
366 return; | 370 return; |
367 } | 371 } |
368 | 372 |
369 write_buffer_ = buffer; | 373 write_buffer_ = buffer; |
370 DoWrite(); | 374 DoWrite(); |
371 } | 375 } |
372 | 376 |
373 void P2PSocketHostTcpBase::DoWrite() { | 377 void P2PSocketHostTcpBase::DoWrite() { |
374 while (write_buffer_.get() && state_ == STATE_OPEN && !write_pending_) { | 378 while (write_buffer_.get() && state_ == STATE_OPEN && !write_pending_) { |
375 int result = socket_->Write( | 379 int result = socket_->Write( |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 } else { | 605 } else { |
602 packet_size += kTurnChannelDataHeaderSize; | 606 packet_size += kTurnChannelDataHeaderSize; |
603 // Calculate any padding if present. | 607 // Calculate any padding if present. |
604 if (packet_size % 4) | 608 if (packet_size % 4) |
605 *pad_bytes = 4 - packet_size % 4; | 609 *pad_bytes = 4 - packet_size % 4; |
606 } | 610 } |
607 return packet_size; | 611 return packet_size; |
608 } | 612 } |
609 | 613 |
610 } // namespace content | 614 } // namespace content |
OLD | NEW |