| Index: remoting/client/host_connection.cc
|
| diff --git a/remoting/client/host_connection.cc b/remoting/client/host_connection.cc
|
| index f858af634b9f5044b3e1b2b74c9c4fb23ffebbd4..2b47f0d08f7e8c5b1ab8559149f3efb0d39be0f2 100644
|
| --- a/remoting/client/host_connection.cc
|
| +++ b/remoting/client/host_connection.cc
|
| @@ -24,22 +24,28 @@ void HostConnection::Connect(const std::string& username,
|
| }
|
|
|
| void HostConnection::Disconnect() {
|
| - if (jingle_channel_.get())
|
| + // TODO(hclam): It's not thread safe to read the state.
|
| + if (jingle_channel_.get() &&
|
| + jingle_channel_->state() != JingleChannel::CLOSED) {
|
| jingle_channel_->Close();
|
| + }
|
|
|
| - if (jingle_client_.get())
|
| + // TODO(hclam): It's not thread safe to read the state.
|
| + if (jingle_client_.get() &&
|
| + jingle_client_->state() != JingleClient::CLOSED) {
|
| jingle_client_->Close();
|
| + }
|
| }
|
|
|
| void HostConnection::OnStateChange(JingleChannel* channel,
|
| JingleChannel::State state) {
|
| DCHECK(handler_);
|
| - if (state == JingleChannel::FAILED)
|
| + if (state == JingleChannel::OPEN)
|
| + handler_->OnConnectionOpened(this);
|
| + else if (state == JingleChannel::FAILED)
|
| handler_->OnConnectionFailed(this);
|
| else if (state == JingleChannel::CLOSED)
|
| handler_->OnConnectionClosed(this);
|
| - else if (state == JingleChannel::OPEN)
|
| - handler_->OnConnectionOpened(this);
|
| }
|
|
|
| void HostConnection::OnPacketReceived(JingleChannel* channel,
|
|
|