Fix crash in CreateAuthenticatorFactory().

CreateAuthenticatorFactory() is called asynchronously, but it didn't handle
the case when it's called after host object is destroyed.

BUG=150644

Review URL: https://codereview.chromium.org/11090036

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161077 0039d316-1c4b-4281-b951-d872f2087c98
  void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
    if (!context_->network_task_runner()->BelongsToCurrentThread()) {
      context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
          &HostProcess::OnPolicyUpdate, base::Unretained(this),
          base::Passed(&policies)));
      return;
    }

    bool restart_required = false;
    bool bool_value;
    std::string string_value;
    if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName,
                            &string_value)) {
      restart_required |= OnHostDomainPolicyUpdate(string_value);
    }
    if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
                             &bool_value)) {
      restart_required |= OnNatPolicyUpdate(bool_value);
    }
    if (policies->GetString(
            policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
            &string_value)) {
      restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value);
    }
    if (policies->GetBoolean(
            policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName,
            &bool_value)) {
      restart_required |= OnCurtainPolicyUpdate(bool_value);
    }
    if (!host_) {
      StartHost();
    } else if (restart_required) {
      RestartHost();
    }
  }

  void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
    if (!context_->network_task_runner()->BelongsToCurrentThread()) {
      context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
          &HostProcess::OnPolicyUpdate, base::Unretained(this),
          base::Passed(&policies)));
      return;
    }

    bool restart_required = false;
    bool bool_value;
    std::string string_value;
    if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName,
                            &string_value)) {
      restart_required |= OnHostDomainPolicyUpdate(string_value);
    }
    if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
                             &bool_value)) {
      restart_required |= OnNatPolicyUpdate(bool_value);
    }
    if (policies->GetString(
            policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
            &string_value)) {
      restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value);
    }
    if (policies->GetBoolean(
            policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName,
            &bool_value)) {
      restart_required |= OnCurtainPolicyUpdate(bool_value);
    }
    if (!host_) {
      StartHost();
    } else if (restart_required) {
      RestartHost();
    }
  }
