| Index: components/policy/core/common/cloud/component_cloud_policy_service.cc
|
| diff --git a/components/policy/core/common/cloud/component_cloud_policy_service.cc b/components/policy/core/common/cloud/component_cloud_policy_service.cc
|
| index 05f9cc6114e43b4fabf99a52e4efc137643beec5..a945301cd16014d314ccb8dd7a8598f175561ebd 100644
|
| --- a/components/policy/core/common/cloud/component_cloud_policy_service.cc
|
| +++ b/components/policy/core/common/cloud/component_cloud_policy_service.cc
|
| @@ -35,13 +35,6 @@ bool NotInSchemaMap(const scoped_refptr<SchemaMap> schema_map,
|
| return schema_map->GetSchema(PolicyNamespace(domain, component_id)) == NULL;
|
| }
|
|
|
| -bool ToPolicyNamespaceKey(const PolicyNamespace& ns, PolicyNamespaceKey* key) {
|
| - if (!ComponentCloudPolicyStore::GetPolicyType(ns.domain, &key->first))
|
| - return false;
|
| - key->second = ns.component_id;
|
| - return true;
|
| -}
|
| -
|
| bool ToPolicyNamespace(const PolicyNamespaceKey& key, PolicyNamespace* ns) {
|
| if (!ComponentCloudPolicyStore::GetPolicyDomain(key.first, &ns->domain))
|
| return false;
|
| @@ -314,19 +307,7 @@ void ComponentCloudPolicyService::OnCoreConnected(CloudPolicyCore* core) {
|
| void ComponentCloudPolicyService::OnCoreDisconnecting(CloudPolicyCore* core) {
|
| DCHECK(CalledOnValidThread());
|
| DCHECK_EQ(core_, core);
|
| -
|
| core_->client()->RemoveObserver(this);
|
| -
|
| - // Remove all the namespaces from the client.
|
| - scoped_refptr<SchemaMap> empty = new SchemaMap();
|
| - PolicyNamespaceList removed;
|
| - PolicyNamespaceList added;
|
| - empty->GetChanges(current_schema_map_, &removed, &added);
|
| - for (size_t i = 0; i < removed.size(); ++i) {
|
| - PolicyNamespaceKey key;
|
| - if (ToPolicyNamespaceKey(removed[i], &key))
|
| - core_->client()->RemoveNamespaceToFetch(key);
|
| - }
|
| }
|
|
|
| void ComponentCloudPolicyService::OnRefreshSchedulerStarted(
|
| @@ -478,26 +459,12 @@ void ComponentCloudPolicyService::SetCurrentSchema() {
|
|
|
| current_schema_map_ = new_schema_map;
|
|
|
| - if (core_->client()) {
|
| - for (size_t i = 0; i < removed->size(); ++i) {
|
| - PolicyNamespaceKey key;
|
| - if (ToPolicyNamespaceKey((*removed)[i], &key))
|
| - core_->client()->RemoveNamespaceToFetch(key);
|
| - }
|
| -
|
| - bool added_namespaces_to_client = false;
|
| - for (size_t i = 0; i < added.size(); ++i) {
|
| - PolicyNamespaceKey key;
|
| - if (ToPolicyNamespaceKey(added[i], &key)) {
|
| - core_->client()->AddNamespaceToFetch(key);
|
| - added_namespaces_to_client = true;
|
| - }
|
| - }
|
| -
|
| - if (added_namespaces_to_client)
|
| - core_->RefreshSoon();
|
| - }
|
| + // Schedule a policy refresh if a new managed component was added.
|
| + if (core_->client() && !added.empty())
|
| + core_->RefreshSoon();
|
|
|
| + // Send the updated SchemaMap and a list of removed components to the
|
| + // backend.
|
| backend_task_runner_->PostTask(FROM_HERE,
|
| base::Bind(&Backend::OnSchemasUpdated,
|
| base::Unretained(backend_.get()),
|
|
|