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
void HostNPScriptObject::OnReceivedSupportID(
    SupportAccessVerifier* access_verifier,
    bool success,
    const std::string& support_id,
    const base::TimeDelta& lifetime) {
  DCHECK(host_context_.network_message_loop()->BelongsToCurrentThread());

  if (!success) {
    host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
        &HostNPScriptObject::NotifyAccessCode, base::Unretained(this), false));
    DisconnectInternal();
    return;
  }

  access_verifier->OnIT2MeHostRegistered(success, support_id);
  std::string access_code = support_id + access_verifier->host_secret();
  host_->set_access_code(access_code);

  {
    base::AutoLock lock(access_code_lock_);
    access_code_ = access_code;
    access_code_lifetime_ = lifetime;
  }

  host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
      &HostNPScriptObject::NotifyAccessCode, base::Unretained(this), true));
}

void HostNPScriptObject::OnReceivedSupportID(
    SupportAccessVerifier* access_verifier,
    bool success,
    const std::string& support_id,
    const base::TimeDelta& lifetime) {
  DCHECK(host_context_.network_message_loop()->BelongsToCurrentThread());

  if (!success) {
    host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
        &HostNPScriptObject::NotifyAccessCode, base::Unretained(this), false));
    DisconnectInternal();
    return;
  }

  access_verifier->OnIT2MeHostRegistered(success, support_id);
  std::string access_code = support_id + access_verifier->host_secret();
  host_->set_access_code(access_code);

  {
    base::AutoLock lock(access_code_lock_);
    access_code_ = access_code;
    access_code_lifetime_ = lifetime;
  }

  host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
      &HostNPScriptObject::NotifyAccessCode, base::Unretained(this), true));
}
