| Index: remoting/protocol/connection_to_client.cc
|
| diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
|
| index fab898015c6c38eecb7887fcdbcf35b2bf1c2dc9..a6086cfadacc4514bec947850434d12edb7b6d80 100644
|
| --- a/remoting/protocol/connection_to_client.cc
|
| +++ b/remoting/protocol/connection_to_client.cc
|
| @@ -34,8 +34,6 @@ ConnectionToClient::ConnectionToClient(base::MessageLoopProxy* message_loop,
|
| }
|
|
|
| ConnectionToClient::~ConnectionToClient() {
|
| - // TODO(hclam): When we shut down the viewer we may have to close the
|
| - // connection.
|
| }
|
|
|
| void ConnectionToClient::SetEventHandler(EventHandler* event_handler) {
|
| @@ -48,19 +46,18 @@ protocol::Session* ConnectionToClient::session() {
|
| }
|
|
|
| void ConnectionToClient::Disconnect() {
|
| - // This method can be called from main thread so perform threading switching.
|
| - if (!message_loop_->BelongsToCurrentThread()) {
|
| - message_loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this, &ConnectionToClient::Disconnect));
|
| - return;
|
| - }
|
| + DCHECK(message_loop_->BelongsToCurrentThread());
|
|
|
| CloseChannels();
|
|
|
| // If there is a session then release it, causing it to close.
|
| - if (session_.get())
|
| - session_.reset();
|
| + if (session_.get()) {
|
| + session_->Close();
|
| + // It may not be safe to delete |session_| here becase this method
|
| + // may be invoked in resonse to a libjingle event and libjingle's
|
| + // sigslot doesn't handle it properly, so postpone the deletion.
|
| + message_loop_->DeleteSoon(FROM_HERE, session_.release());
|
| + }
|
| }
|
|
|
| void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) {
|
|
|