Commit e081a3c1 authored by avi's avatar avi Committed by Commit bot

Remove base::ScopedPtrHashMap from components/policy/.

BUG=579229

Review-Url: https://codereview.chromium.org/2600783002
Cr-Commit-Position: refs/heads/master@{#441406}
parent b4ef1f06
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#include <stddef.h> #include <stddef.h>
#include <unordered_map>
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -31,9 +31,10 @@ ...@@ -31,9 +31,10 @@
namespace em = enterprise_management; namespace em = enterprise_management;
typedef base::ScopedPtrHashMap<policy::PolicyNamespace, using ScopedResponseMap =
std::unique_ptr<em::PolicyFetchResponse>> std::unordered_map<policy::PolicyNamespace,
ScopedResponseMap; std::unique_ptr<em::PolicyFetchResponse>,
policy::PolicyNamespaceHash>;
namespace policy { namespace policy {
...@@ -42,7 +43,7 @@ namespace { ...@@ -42,7 +43,7 @@ namespace {
bool NotInResponseMap(const ScopedResponseMap& map, bool NotInResponseMap(const ScopedResponseMap& map,
PolicyDomain domain, PolicyDomain domain,
const std::string& component_id) { const std::string& component_id) {
return !map.contains(PolicyNamespace(domain, component_id)); return map.find(PolicyNamespace(domain, component_id)) == map.end();
} }
bool NotInSchemaMap(const scoped_refptr<SchemaMap> schema_map, bool NotInSchemaMap(const scoped_refptr<SchemaMap> schema_map,
...@@ -260,7 +261,7 @@ void ComponentCloudPolicyService::Backend::UpdateWithMostRecentPolicies() { ...@@ -260,7 +261,7 @@ void ComponentCloudPolicyService::Backend::UpdateWithMostRecentPolicies() {
base::Bind(&NotInResponseMap, base::ConstRef(*most_recent_policies_), base::Bind(&NotInResponseMap, base::ConstRef(*most_recent_policies_),
POLICY_DOMAIN_SIGNIN_EXTENSIONS)); POLICY_DOMAIN_SIGNIN_EXTENSIONS));
for (ScopedResponseMap::iterator it = most_recent_policies_->begin(); for (auto it = most_recent_policies_->begin();
it != most_recent_policies_->end(); ++it) { it != most_recent_policies_->end(); ++it) {
updater_->UpdateExternalPolicy( updater_->UpdateExternalPolicy(
it->first, base::MakeUnique<em::PolicyFetchResponse>(*it->second)); it->first, base::MakeUnique<em::PolicyFetchResponse>(*it->second));
...@@ -470,7 +471,8 @@ void ComponentCloudPolicyService::OnPolicyFetched(CloudPolicyClient* client) { ...@@ -470,7 +471,8 @@ void ComponentCloudPolicyService::OnPolicyFetched(CloudPolicyClient* client) {
// Pass a complete list of all the currently managed extensions to the // Pass a complete list of all the currently managed extensions to the
// backend. The cache will purge the storage for any extensions that are not // backend. The cache will purge the storage for any extensions that are not
// in this list. // in this list.
std::unique_ptr<ScopedResponseMap> valid_responses(new ScopedResponseMap()); std::unique_ptr<ScopedResponseMap> valid_responses =
base::MakeUnique<ScopedResponseMap>();
const CloudPolicyClient::ResponseMap& responses = const CloudPolicyClient::ResponseMap& responses =
core_->client()->responses(); core_->client()->responses();
...@@ -480,8 +482,8 @@ void ComponentCloudPolicyService::OnPolicyFetched(CloudPolicyClient* client) { ...@@ -480,8 +482,8 @@ void ComponentCloudPolicyService::OnPolicyFetched(CloudPolicyClient* client) {
!current_schema_map_->GetSchema(ns)) { !current_schema_map_->GetSchema(ns)) {
continue; continue;
} }
valid_responses->set( (*valid_responses)[ns] =
ns, base::MakeUnique<em::PolicyFetchResponse>(*it->second)); base::MakeUnique<em::PolicyFetchResponse>(*it->second);
} }
backend_task_runner_->PostTask( backend_task_runner_->PostTask(
......
...@@ -54,20 +54,13 @@ struct POLICY_EXPORT PolicyNamespace { ...@@ -54,20 +54,13 @@ struct POLICY_EXPORT PolicyNamespace {
typedef std::vector<PolicyNamespace> PolicyNamespaceList; typedef std::vector<PolicyNamespace> PolicyNamespaceList;
} // namespace policy struct PolicyNamespaceHash {
size_t operator()(const policy::PolicyNamespace& ns) const {
// Define a custom std::hash for PolicyNamespace so that it can be used as return std::hash<std::string>()(ns.component_id) ^
// a key in hash_maps, and in particular in ScopedPtrHashMaps (which uses the (UINT64_C(1) << ns.domain);
// default std::hash).
namespace BASE_HASH_NAMESPACE {
template <>
struct hash<policy::PolicyNamespace> {
std::size_t operator()(const policy::PolicyNamespace& ns) const {
return hash<std::string>()(ns.component_id) ^ (UINT64_C(1) << ns.domain);
} }
}; };
} // namespace BASE_HASH_NAMESPACE } // namespace policy
#endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment