Access ChromotingHost::clients_ only on network thread.

Previously ChromotingHost was doing some work on the main thread and
some on the network thread. |clients_| and some other members were
accessed without lock on both of these threads. Moved most of the
ChromotingHost activity to the network thread to avoid possible
race conditions.

BUG=96325
TEST=Chromoting works

Review URL: http://codereview.chromium.org/8495024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109556 0039d316-1c4b-4281-b951-d872f2087c98
HostNPScriptObject::~HostNPScriptObject() {
  CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);

  if (desktop_environment_.get()) {
    desktop_environment_->Shutdown();
  }

  HostLogHandler::UnregisterLoggingScriptObject(this);

  plugin_message_loop_proxy_->Detach();

  if (nat_policy_.get()) {
    base::WaitableEvent nat_policy_stopped_(true, false);
    nat_policy_->StopWatching(&nat_policy_stopped_);
    nat_policy_stopped_.Wait();
    nat_policy_.reset();
  }

  disconnected_event_.Reset();
  DisconnectInternal();
  disconnected_event_.Wait();

  host_context_.Stop();
}

HostNPScriptObject::~HostNPScriptObject() {
  CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);

  if (desktop_environment_.get()) {
    desktop_environment_->Shutdown();
  }

  HostLogHandler::UnregisterLoggingScriptObject(this);

  plugin_message_loop_proxy_->Detach();

  if (nat_policy_.get()) {
    base::WaitableEvent nat_policy_stopped_(true, false);
    nat_policy_->StopWatching(&nat_policy_stopped_);
    nat_policy_stopped_.Wait();
    nat_policy_.reset();
  }

  disconnected_event_.Reset();
  DisconnectInternal();
  disconnected_event_.Wait();

  host_context_.Stop();
}
