Index: components/policy/core/common/cloud/cloud_policy_client.cc |
diff --git a/components/policy/core/common/cloud/cloud_policy_client.cc b/components/policy/core/common/cloud/cloud_policy_client.cc |
index 3014fd7f1585755d8825c7c6ad01341d57aec0e5..498b4c7f4f4b77ee591ff29d522b69ae3d3f3be6 100644 |
--- a/components/policy/core/common/cloud/cloud_policy_client.cc |
+++ b/components/policy/core/common/cloud/cloud_policy_client.cc |
@@ -65,8 +65,8 @@ CloudPolicyClient::CloudPolicyClient( |
public_key_version_valid_(false), |
invalidation_version_(0), |
fetched_invalidation_version_(0), |
- service_(service), // Can be NULL for unit tests. |
- status_provider_(status_provider), // Can be NULL for unit tests. |
+ service_(service), // Can be null for unit tests. |
+ status_provider_(status_provider), // Can be null for unit tests. |
status_(DM_STATUS_SUCCESS), |
request_context_(request_context) { |
} |
@@ -146,7 +146,7 @@ void CloudPolicyClient::SetInvalidationInfo( |
void CloudPolicyClient::FetchPolicy() { |
CHECK(is_registered()); |
- CHECK(!namespaces_to_fetch_.empty()); |
+ CHECK(!types_to_fetch_.empty()); |
request_job_.reset( |
service_->CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH, |
@@ -159,12 +159,11 @@ void CloudPolicyClient::FetchPolicy() { |
// Build policy fetch requests. |
em::DevicePolicyRequest* policy_request = request->mutable_policy_request(); |
- for (NamespaceSet::iterator it = namespaces_to_fetch_.begin(); |
- it != namespaces_to_fetch_.end(); ++it) { |
+ for (const auto& type_to_fetch : types_to_fetch_) { |
em::PolicyFetchRequest* fetch_request = policy_request->add_request(); |
- fetch_request->set_policy_type(it->first); |
- if (!it->second.empty()) |
- fetch_request->set_settings_entity_id(it->second); |
+ fetch_request->set_policy_type(type_to_fetch.first); |
+ if (!type_to_fetch.second.empty()) |
+ fetch_request->set_settings_entity_id(type_to_fetch.second); |
// Request signed policy blobs to help prevent tampering on the client. |
fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); |
@@ -175,7 +174,7 @@ void CloudPolicyClient::FetchPolicy() { |
fetch_request->set_verification_key_hash(verification_key_hash_); |
// These fields are included only in requests for chrome policy. |
- if (IsChromePolicy(it->first)) { |
+ if (IsChromePolicy(type_to_fetch.first)) { |
Mattias Nissler (ping if slow)
2014/11/27 08:34:10
Side note: We may eventually change this to not ha
Joao da Silva
2014/11/27 12:19:31
Ack
|
if (submit_machine_id_ && !machine_id_.empty()) |
fetch_request->set_machine_id(machine_id_); |
if (!last_policy_timestamp_.is_null()) { |
@@ -288,12 +287,16 @@ void CloudPolicyClient::RemoveObserver(Observer* observer) { |
observers_.RemoveObserver(observer); |
} |
-void CloudPolicyClient::AddNamespaceToFetch(const PolicyNamespaceKey& key) { |
- namespaces_to_fetch_.insert(key); |
+void CloudPolicyClient::AddPolicyTypeToFetch( |
+ const std::string& policy_type, |
+ const std::string& settings_entity_id) { |
+ types_to_fetch_.insert(std::make_pair(policy_type, settings_entity_id)); |
} |
-void CloudPolicyClient::RemoveNamespaceToFetch(const PolicyNamespaceKey& key) { |
- namespaces_to_fetch_.erase(key); |
+void CloudPolicyClient::RemovePolicyTypeToFetch( |
+ const std::string& policy_type, |
+ const std::string& settings_entity_id) { |
+ types_to_fetch_.erase(std::make_pair(policy_type, settings_entity_id)); |
} |
void CloudPolicyClient::SetStateKeysToUpload( |
@@ -302,9 +305,11 @@ void CloudPolicyClient::SetStateKeysToUpload( |
} |
const em::PolicyFetchResponse* CloudPolicyClient::GetPolicyFor( |
- const PolicyNamespaceKey& key) const { |
- ResponseMap::const_iterator it = responses_.find(key); |
- return it == responses_.end() ? NULL : it->second; |
+ const std::string& policy_type, |
+ const std::string& settings_entity_id) const { |
+ ResponseMap::const_iterator it = |
+ responses_.find(std::make_pair(policy_type, settings_entity_id)); |
+ return it == responses_.end() ? nullptr : it->second; |
} |
scoped_refptr<net::URLRequestContextGetter> |
@@ -405,7 +410,7 @@ void CloudPolicyClient::OnPolicyFetchCompleted( |
std::string entity_id; |
if (policy_data.has_settings_entity_id()) |
entity_id = policy_data.settings_entity_id(); |
- PolicyNamespaceKey key(type, entity_id); |
+ std::pair<std::string, std::string> key(type, entity_id); |
if (ContainsKey(responses_, key)) { |
LOG(WARNING) << "Duplicate PolicyFetchResponse for type: " |
<< type << ", entity: " << entity_id << ", ignoring"; |