| 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 "jingle/glue/channel_socket_adapter.h" | 5 #include "jingle/glue/channel_socket_adapter.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 DCHECK(!callback.is_null()); | 70 DCHECK(!callback.is_null()); |
| 71 CHECK(write_callback_.is_null()); | 71 CHECK(write_callback_.is_null()); |
| 72 | 72 |
| 73 if (!channel_) { | 73 if (!channel_) { |
| 74 DCHECK(closed_error_code_ != net::OK); | 74 DCHECK(closed_error_code_ != net::OK); |
| 75 return closed_error_code_; | 75 return closed_error_code_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 int result; | 78 int result; |
| 79 if (channel_->writable()) { | 79 if (channel_->writable()) { |
| 80 result = channel_->SendPacket(buffer->data(), buffer_size); | 80 result = channel_->SendPacket(buffer->data(), buffer_size, |
| 81 talk_base::DSCP_NO_CHANGE); |
| 81 if (result < 0) { | 82 if (result < 0) { |
| 82 result = net::MapSystemError(channel_->GetError()); | 83 result = net::MapSystemError(channel_->GetError()); |
| 83 | 84 |
| 84 // If the underlying socket returns IO pending where it shouldn't we | 85 // If the underlying socket returns IO pending where it shouldn't we |
| 85 // pretend the packet is dropped and return as succeeded because no | 86 // pretend the packet is dropped and return as succeeded because no |
| 86 // writeable callback will happen. | 87 // writeable callback will happen. |
| 87 if (result == net::ERR_IO_PENDING) | 88 if (result == net::ERR_IO_PENDING) |
| 88 result = net::OK; | 89 result = net::OK; |
| 89 } | 90 } |
| 90 } else { | 91 } else { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 << "Data was received without a callback. Dropping the packet."; | 165 << "Data was received without a callback. Dropping the packet."; |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 | 168 |
| 168 void TransportChannelSocketAdapter::OnWritableState( | 169 void TransportChannelSocketAdapter::OnWritableState( |
| 169 cricket::TransportChannel* channel) { | 170 cricket::TransportChannel* channel) { |
| 170 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 171 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
| 171 // Try to send the packet if there is a pending write. | 172 // Try to send the packet if there is a pending write. |
| 172 if (!write_callback_.is_null()) { | 173 if (!write_callback_.is_null()) { |
| 173 int result = channel_->SendPacket(write_buffer_->data(), | 174 int result = channel_->SendPacket(write_buffer_->data(), |
| 174 write_buffer_size_); | 175 write_buffer_size_, |
| 176 talk_base::DSCP_NO_CHANGE); |
| 175 if (result < 0) | 177 if (result < 0) |
| 176 result = net::MapSystemError(channel_->GetError()); | 178 result = net::MapSystemError(channel_->GetError()); |
| 177 | 179 |
| 178 if (result != net::ERR_IO_PENDING) { | 180 if (result != net::ERR_IO_PENDING) { |
| 179 net::CompletionCallback callback = write_callback_; | 181 net::CompletionCallback callback = write_callback_; |
| 180 write_callback_.Reset(); | 182 write_callback_.Reset(); |
| 181 write_buffer_ = NULL; | 183 write_buffer_ = NULL; |
| 182 callback.Run(result); | 184 callback.Run(result); |
| 183 } | 185 } |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 void TransportChannelSocketAdapter::OnChannelDestroyed( | 189 void TransportChannelSocketAdapter::OnChannelDestroyed( |
| 188 cricket::TransportChannel* channel) { | 190 cricket::TransportChannel* channel) { |
| 189 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 191 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
| 190 DCHECK_EQ(channel, channel_); | 192 DCHECK_EQ(channel, channel_); |
| 191 Close(net::ERR_CONNECTION_ABORTED); | 193 Close(net::ERR_CONNECTION_ABORTED); |
| 192 } | 194 } |
| 193 | 195 |
| 194 } // namespace jingle_glue | 196 } // namespace jingle_glue |
| OLD | NEW |