Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1409)

Unified Diff: chrome/browser/policy/cloud/component_cloud_policy_updater.cc

Issue 70863002: Refactored the ComponentCloudPolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/cloud/component_cloud_policy_updater.cc
diff --git a/chrome/browser/policy/cloud/component_cloud_policy_updater.cc b/chrome/browser/policy/cloud/component_cloud_policy_updater.cc
index 28c4d68808b995ab637c8b320919126824423961..43cfb271172ad9907560703514f15d134fc41945 100644
--- a/chrome/browser/policy/cloud/component_cloud_policy_updater.cc
+++ b/chrome/browser/policy/cloud/component_cloud_policy_updater.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/policy/cloud/component_cloud_policy_updater.h"
-#include <string>
-
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
@@ -15,7 +13,6 @@
#include "chrome/browser/policy/cloud/external_policy_data_fetcher.h"
#include "chrome/browser/policy/proto/cloud/chrome_extension_policy.pb.h"
#include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
-#include "components/policy/core/common/policy_namespace.h"
namespace em = enterprise_management;
@@ -67,18 +64,14 @@ void ComponentCloudPolicyUpdater::UpdateExternalPolicy(
// Maybe the data for this hash has already been downloaded and cached.
const std::string& cached_hash = store_->GetCachedHash(ns);
- if (!cached_hash.empty() && data.secure_hash() == cached_hash) {
+ if (!cached_hash.empty() && data.secure_hash() == cached_hash)
return;
- }
// TODO(joaodasilva): implement the other two auth methods.
if (data.download_auth_method() != em::ExternalPolicyData::NONE)
return;
- // Encode |ns| into a string |key|.
- const std::string domain = base::IntToString(ns.domain);
- const std::string key =
- base::IntToString(domain.size()) + ":" + domain + ":" + ns.component_id;
+ const std::string key = NamespaceToKey(ns);
if (data.download_url().empty() || !data.has_secure_hash()) {
// If there is no policy for this component or the policy has been removed,
@@ -102,4 +95,15 @@ void ComponentCloudPolicyUpdater::UpdateExternalPolicy(
}
}
+void ComponentCloudPolicyUpdater::CancelUpdate(const PolicyNamespace& ns) {
+ external_policy_data_updater_.CancelExternalDataFetch(NamespaceToKey(ns));
+}
+
+std::string ComponentCloudPolicyUpdater::NamespaceToKey(
+ const PolicyNamespace& ns) {
+ const std::string domain = base::IntToString(ns.domain);
+ const std::string size = base::IntToString(domain.size());
+ return size + ":" + domain + ":" + ns.component_id;
+}
+
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698