Chromium Code Reviews| 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 cd783abdd25def15c31ed0f8778d4a5337f45815..cb7edec6078e4539e546c31d667c67988f61bc35 100644 |
| --- a/components/policy/core/common/cloud/component_cloud_policy_service.cc |
| +++ b/components/policy/core/common/cloud/component_cloud_policy_service.cc |
| @@ -241,6 +241,11 @@ ComponentCloudPolicyService::ComponentCloudPolicyService( |
| // policies. |
| if (core_->store()->is_initialized()) |
| OnStoreLoaded(core_->store()); |
| + |
| + // Start observing the core and tracking the state of the client. |
| + core_->AddObserver(this); |
| + if (core_->client()) |
| + OnCoreConnected(core_); |
| } |
| ComponentCloudPolicyService::~ComponentCloudPolicyService() { |
| @@ -300,8 +305,9 @@ void ComponentCloudPolicyService::OnCoreConnected(CloudPolicyCore* core) { |
| PolicyNamespaceKey(dm_protocol::kChromeExtensionPolicyType, "")); |
| // Immediately load any PolicyFetchResponses that the client may already |
| - // have. |
| - OnPolicyFetched(core_->client()); |
| + // have if the backend is ready. |
| + if (loaded_initial_policy_) |
| + OnPolicyFetched(core_->client()); |
| } |
| void ComponentCloudPolicyService::OnCoreDisconnecting(CloudPolicyCore* core) { |
| @@ -394,6 +400,7 @@ void ComponentCloudPolicyService::OnPolicyFetched(CloudPolicyClient* client) { |
| current_schema_map_->GetSchema(ns)) { |
| scoped_ptr<em::PolicyFetchResponse> response( |
| new em::PolicyFetchResponse(*it->second)); |
| + LOG(ERROR) << "-- updating external policy for: " << ns.component_id; |
|
bartfab (slow)
2014/06/20 17:03:46
Nit: Remove.
Joao da Silva
2014/06/20 22:28:19
Done
|
| backend_task_runner_->PostTask( |
| FROM_HERE, |
| base::Bind(&Backend::UpdateExternalPolicy, |
| @@ -443,12 +450,6 @@ void ComponentCloudPolicyService::OnBackendInitialized( |
| // Send the current schema to the backend, in case it has changed while the |
| // backend was initializing. |
| ReloadSchema(); |
| - |
| - // Start observing the core and tracking the state of the client. |
| - core_->AddObserver(this); |
| - |
| - if (core_->client()) |
| - OnCoreConnected(core_); |
| } |
| void ComponentCloudPolicyService::ReloadSchema() { |
| @@ -462,10 +463,6 @@ void ComponentCloudPolicyService::ReloadSchema() { |
| current_schema_map_ = new_schema_map; |
| - // 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, |
| @@ -473,6 +470,14 @@ void ComponentCloudPolicyService::ReloadSchema() { |
| base::Unretained(backend_.get()), |
| current_schema_map_, |
| base::Passed(&removed))); |
| + |
| + // Have another look at the client if the core is already connected. |
| + // The client may have already fetched policy for some component and it was |
| + // previously ignored because the component wasn't listed in the schema map. |
| + // There's no point in fetching policy from the server again; the server |
| + // always pushes all the components it knows about. |
| + if (core_->client()) |
| + OnPolicyFetched(core_->client()); |
| } |
| void ComponentCloudPolicyService::OnPolicyUpdated( |