| Index: remoting/host/simple_host.cc
|
| diff --git a/remoting/host/simple_host.cc b/remoting/host/simple_host.cc
|
| index 945b663fa6e78454b63d237f4a13b10a403fcf13..b9ea7a5404838d17e2976a77699ce5b281c090c6 100644
|
| --- a/remoting/host/simple_host.cc
|
| +++ b/remoting/host/simple_host.cc
|
| @@ -44,11 +44,16 @@ void SimpleHost::DestroySession() {
|
|
|
| // First we tell the session to pause and then we wait until all
|
| // the tasks are done.
|
| - session_->Pause();
|
| + if (session_.get()) {
|
| + session_->Pause();
|
|
|
| - // TODO(hclam): Revise the order.
|
| - encode_thread_.Stop();
|
| - capture_thread_.Stop();
|
| + // TODO(hclam): Revise the order.
|
| + DCHECK(encode_thread_.IsRunning());
|
| + encode_thread_.Stop();
|
| +
|
| + DCHECK(capture_thread_.IsRunning());
|
| + capture_thread_.Stop();
|
| + }
|
| }
|
|
|
| // This method talks to the cloud to register the host process. If
|
| @@ -67,7 +72,7 @@ void SimpleHost::OnClientConnected(ClientConnection* client) {
|
| DCHECK_EQ(&main_loop_, MessageLoop::current());
|
|
|
| // Create a new RecordSession if there was none.
|
| - if (!session_) {
|
| + if (!session_.get()) {
|
| // The first we need to make sure capture and encode thread are
|
| // running.
|
| capture_thread_.Start();
|
| @@ -99,8 +104,8 @@ void SimpleHost::OnClientDisconnected(ClientConnection* client) {
|
| DCHECK_EQ(&main_loop_, MessageLoop::current());
|
|
|
| // Remove the client from the session manager.
|
| - DCHECK(session_);
|
| - session_->RemoveClient(client);
|
| + if (session_.get())
|
| + session_->RemoveClient(client);
|
|
|
| // Also remove reference to ClientConnection from this object.
|
| client_ = NULL;
|
| @@ -155,10 +160,8 @@ void SimpleHost::OnStateChange(JingleClient* jingle_client,
|
| DCHECK_EQ(jingle_client_.get(), jingle_client);
|
|
|
| if (state == JingleClient::CONNECTED) {
|
| - // TODO(hclam): Change to use LOG(INFO).
|
| - // LOG(INFO) << "Host connected as "
|
| - // << jingle_client->GetFullJid() << "." << std::endl;
|
| - printf("Host connected as %s\n", jingle_client->GetFullJid().c_str());
|
| + LOG(INFO) << "Host connected as "
|
| + << jingle_client->GetFullJid() << "." << std::endl;
|
|
|
| // Start heartbeating after we connected
|
| heartbeat_sender_ = new HeartbeatSender();
|
| @@ -166,8 +169,10 @@ void SimpleHost::OnStateChange(JingleClient* jingle_client,
|
| heartbeat_sender_->Start(jingle_client_.get(), "HostID");
|
| } else if (state == JingleClient::CLOSED) {
|
| LOG(INFO) << "Host disconnected from talk network." << std::endl;
|
| -
|
| heartbeat_sender_ = NULL;
|
| +
|
| + // Quit the message loop if disconected.
|
| + main_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask());
|
| }
|
| }
|
|
|
| @@ -176,6 +181,7 @@ bool SimpleHost::OnAcceptConnection(
|
| JingleChannel::Callback** channel_callback) {
|
| DCHECK_EQ(jingle_client_.get(), jingle_client);
|
|
|
| + // TODO(hclam): Allow multiple clients to connect to the host.
|
| if (client_.get())
|
| return false;
|
|
|
|
|