| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 channel_->SignalReadPacket.connect( | 25 channel_->SignalReadPacket.connect( |
| 26 this, &TransportChannelSocketAdapter::OnNewPacket); | 26 this, &TransportChannelSocketAdapter::OnNewPacket); |
| 27 channel_->SignalWritableState.connect( | 27 channel_->SignalWritableState.connect( |
| 28 this, &TransportChannelSocketAdapter::OnWritableState); | 28 this, &TransportChannelSocketAdapter::OnWritableState); |
| 29 channel_->SignalDestroyed.connect( | 29 channel_->SignalDestroyed.connect( |
| 30 this, &TransportChannelSocketAdapter::OnChannelDestroyed); | 30 this, &TransportChannelSocketAdapter::OnChannelDestroyed); |
| 31 } | 31 } |
| 32 | 32 |
| 33 TransportChannelSocketAdapter::~TransportChannelSocketAdapter() { | 33 TransportChannelSocketAdapter::~TransportChannelSocketAdapter() { |
| 34 if (!destruction_callback_.is_null()) | |
| 35 destruction_callback_.Run(); | |
| 36 } | |
| 37 | |
| 38 void TransportChannelSocketAdapter::SetOnDestroyedCallback( | |
| 39 const base::Closure& callback) { | |
| 40 destruction_callback_ = callback; | |
| 41 } | 34 } |
| 42 | 35 |
| 43 int TransportChannelSocketAdapter::Read( | 36 int TransportChannelSocketAdapter::Read( |
| 44 net::IOBuffer* buf, | 37 net::IOBuffer* buf, |
| 45 int buffer_size, | 38 int buffer_size, |
| 46 const net::CompletionCallback& callback) { | 39 const net::CompletionCallback& callback) { |
| 47 DCHECK_EQ(MessageLoop::current(), message_loop_); | 40 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 48 DCHECK(buf); | 41 DCHECK(buf); |
| 49 DCHECK(!callback.is_null()); | 42 DCHECK(!callback.is_null()); |
| 50 CHECK(read_callback_.is_null()); | 43 CHECK(read_callback_.is_null()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 175 } |
| 183 | 176 |
| 184 void TransportChannelSocketAdapter::OnChannelDestroyed( | 177 void TransportChannelSocketAdapter::OnChannelDestroyed( |
| 185 cricket::TransportChannel* channel) { | 178 cricket::TransportChannel* channel) { |
| 186 DCHECK_EQ(MessageLoop::current(), message_loop_); | 179 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 187 DCHECK_EQ(channel, channel_); | 180 DCHECK_EQ(channel, channel_); |
| 188 Close(net::ERR_CONNECTION_ABORTED); | 181 Close(net::ERR_CONNECTION_ABORTED); |
| 189 } | 182 } |
| 190 | 183 |
| 191 } // namespace jingle_glue | 184 } // namespace jingle_glue |
| OLD | NEW |