summaryrefslogtreecommitdiffstats
path: root/jingle
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 02:50:42 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 02:50:42 +0000
commit5696b83d30a6edace89241c7c9ed28387b072a85 (patch)
tree74dc7ae7276431ce0e0dd2b64a4c4b363e76803f /jingle
parentee0128514bdf06e63bc4a2d01dfc9a08d8c15651 (diff)
downloadchromium_src-5696b83d30a6edace89241c7c9ed28387b072a85.zip
chromium_src-5696b83d30a6edace89241c7c9ed28387b072a85.tar.gz
chromium_src-5696b83d30a6edace89241c7c9ed28387b072a85.tar.bz2
Fix JingleSession to respect net::StreamSocket Read/Write semantics.
Remove some unnecessary state checks in PseudoTcpAdapter. BUG= TEST=Unit tests and Remoting components continue to work. Review URL: http://codereview.chromium.org/7104012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r--jingle/glue/pseudotcp_adapter.cc39
1 files changed, 13 insertions, 26 deletions
diff --git a/jingle/glue/pseudotcp_adapter.cc b/jingle/glue/pseudotcp_adapter.cc
index 4590dff..7136bbc 100644
--- a/jingle/glue/pseudotcp_adapter.cc
+++ b/jingle/glue/pseudotcp_adapter.cc
@@ -110,19 +110,10 @@ int PseudoTcpAdapter::Core::Read(net::IOBuffer* buffer, int buffer_size,
// Reference the Core in case a callback deletes the adapter.
scoped_refptr<Core> core(this);
- // TODO(wez): This is a hack for remoting. See JingleSession.
- PseudoTcp::TcpState state = pseudo_tcp_.State();
- int result;
- if (state == PseudoTcp::TCP_SYN_SENT ||
- state == PseudoTcp::TCP_SYN_RECEIVED) {
- result = net::ERR_IO_PENDING;
-
- } else {
- result = pseudo_tcp_.Recv(buffer->data(), buffer_size);
- if (result < 0) {
- result = net::MapSystemError(pseudo_tcp_.GetError());
- DCHECK(result < 0);
- }
+ int result = pseudo_tcp_.Recv(buffer->data(), buffer_size);
+ if (result < 0) {
+ result = net::MapSystemError(pseudo_tcp_.GetError());
+ DCHECK(result < 0);
}
if (result == net::ERR_IO_PENDING) {
@@ -143,19 +134,10 @@ int PseudoTcpAdapter::Core::Write(net::IOBuffer* buffer, int buffer_size,
// Reference the Core in case a callback deletes the adapter.
scoped_refptr<Core> core(this);
- // TODO(wez): This is a hack for remoting. See JingleSession.
- PseudoTcp::TcpState state = pseudo_tcp_.State();
- int result;
- if (state == PseudoTcp::TCP_SYN_SENT ||
- state == PseudoTcp::TCP_SYN_RECEIVED) {
- result = net::ERR_IO_PENDING;
-
- } else {
- result = pseudo_tcp_.Send(buffer->data(), buffer_size);
- if (result < 0) {
- result = net::MapSystemError(pseudo_tcp_.GetError());
- DCHECK(result < 0);
- }
+ int result = pseudo_tcp_.Send(buffer->data(), buffer_size);
+ if (result < 0) {
+ result = net::MapSystemError(pseudo_tcp_.GetError());
+ DCHECK(result < 0);
}
if (result == net::ERR_IO_PENDING) {
@@ -293,12 +275,17 @@ cricket::IPseudoTcpNotify::WriteResult PseudoTcpAdapter::Core::TcpWritePacket(
size_t len) {
DCHECK_EQ(tcp, &pseudo_tcp_);
+ // If we already have a write pending, we behave like a congested network,
+ // returning success for the write, but dropping the packet. PseudoTcp will
+ // back-off and retransmit, adjusting for the perceived congestion.
if (socket_write_pending_)
return IPseudoTcpNotify::WR_SUCCESS;
scoped_refptr<net::IOBuffer> write_buffer = new net::IOBuffer(len);
memcpy(write_buffer->data(), buffer, len);
+ // Our underlying socket is datagram-oriented, which means it should either
+ // send exactly as many bytes as we requested, or fail.
int result = socket_->Write(write_buffer, len, &socket_write_callback_);
if (result == net::ERR_IO_PENDING) {
socket_write_pending_ = true;