[invalidation] Update invalidation type names
Bug: b:341376574 b:341376574 b:351754537
Change-Id: I8c2a98feeb4e8af595233dcd23b256ecb40375c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5701250
Reviewed-by: Igor <igorcov@chromium.org>
Auto-Submit: Artem Sumaneev <asumaneev@google.com>
Commit-Queue: Igor <igorcov@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1331740}
diff --git a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
index 2973c0e..fa782fc 100644
--- a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
@@ -96,7 +96,7 @@
namespace {
constexpr char kPolicyInvalidationTopic[] = "test_policy_topic";
-constexpr char kPolicyInvalidationType[] = "policy";
+constexpr char kPolicyInvalidationType[] = "USER_POLICY_FETCH";
struct FeaturesTestParam {
std::vector<base::test::FeatureRef> enabled_features;
diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
index 013532f..9ce2987 100644
--- a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
@@ -12,7 +12,7 @@
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
-#include "base/strings/strcat.h"
+#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/clock.h"
#include "base/time/time.h"
@@ -32,6 +32,12 @@
namespace {
+constexpr char kDevicePolicyInvalidatorTypeName[] = "DEVICE_POLICY_FETCH";
+constexpr char kBrowserPolicyInvalidatorTypeName[] = "BROWSER_POLICY_FETCH";
+constexpr char kUserPolicyInvalidatorTypeName[] = "USER_POLICY_FETCH";
+constexpr char kDeviceLocalAccountPolicyInvalidatorTypeNameTemplate[] =
+ "PUBLIC_ACCOUNT_POLICY_FETCH-%s";
+
MetricPolicyRefresh GetPolicyRefreshMetric(bool invalidations_enabled,
bool policy_changed,
bool invalidated) {
@@ -381,12 +387,15 @@
std::string CloudPolicyInvalidator::GetType() const {
switch (scope_) {
case PolicyInvalidationScope::kUser:
+ return kUserPolicyInvalidatorTypeName;
case PolicyInvalidationScope::kDevice:
+ return kDevicePolicyInvalidatorTypeName;
case PolicyInvalidationScope::kCBCM:
- return "policy";
+ return kBrowserPolicyInvalidatorTypeName;
case PolicyInvalidationScope::kDeviceLocalAccount:
- return base::StrCat(
- {"device_local_account_policy-", device_local_account_id_});
+ return base::StringPrintf(
+ kDeviceLocalAccountPolicyInvalidatorTypeNameTemplate,
+ device_local_account_id_.c_str());
}
}
diff --git a/components/policy/core/common/remote_commands/remote_commands_invalidator.cc b/components/policy/core/common/remote_commands/remote_commands_invalidator.cc
index 8bf23597..6fcad21 100644
--- a/components/policy/core/common/remote_commands/remote_commands_invalidator.cc
+++ b/components/policy/core/common/remote_commands/remote_commands_invalidator.cc
@@ -9,6 +9,7 @@
#include "base/functional/overloaded.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
+#include "base/notreached.h"
#include "base/scoped_observation.h"
#include "components/invalidation/invalidation_factory.h"
#include "components/invalidation/invalidation_listener.h"
@@ -24,13 +25,17 @@
namespace {
-// TODO(b/351754537): Decide on final invalidation type name.
-constexpr char RemoteCommandsInvalidatorType[] = "remote_command";
+constexpr char kDeiceRemoteCommandsInvalidatorTypeName[] =
+ "DEVICE_REMOTE_COMMAND";
+constexpr char kUserRemoteCommandsInvalidatorTypeName[] =
+ "CONSUMER_USER_REMOTE_COMMAND";
} // namespace
-RemoteCommandsInvalidator::RemoteCommandsInvalidator(std::string owner_name)
- : owner_name_(std::move(owner_name)) {}
+RemoteCommandsInvalidator::RemoteCommandsInvalidator(
+ std::string owner_name,
+ PolicyInvalidationScope scope)
+ : owner_name_(std::move(owner_name)), scope_(scope) {}
RemoteCommandsInvalidator::~RemoteCommandsInvalidator() {
CHECK_EQ(SHUT_DOWN, state_);
@@ -172,7 +177,16 @@
}
std::string RemoteCommandsInvalidator::GetType() const {
- return RemoteCommandsInvalidatorType;
+ switch (scope_) {
+ case PolicyInvalidationScope::kUser:
+ return kUserRemoteCommandsInvalidatorTypeName;
+ case PolicyInvalidationScope::kDevice:
+ case PolicyInvalidationScope::kCBCM:
+ return kDeiceRemoteCommandsInvalidatorTypeName;
+ case PolicyInvalidationScope::kDeviceLocalAccount:
+ NOTREACHED_NORETURN()
+ << "Device local account commands are not supported.";
+ }
}
void RemoteCommandsInvalidator::ReloadPolicyData(
diff --git a/components/policy/core/common/remote_commands/remote_commands_invalidator.h b/components/policy/core/common/remote_commands/remote_commands_invalidator.h
index 1e49de1..49b99fe 100644
--- a/components/policy/core/common/remote_commands/remote_commands_invalidator.h
+++ b/components/policy/core/common/remote_commands/remote_commands_invalidator.h
@@ -14,6 +14,7 @@
#include "components/invalidation/public/invalidation_handler.h"
#include "components/invalidation/public/invalidation_service.h"
#include "components/invalidation/public/invalidation_util.h"
+#include "components/policy/core/common/cloud/policy_invalidation_scope.h"
#include "components/policy/policy_export.h"
#include "components/policy/proto/device_management_backend.pb.h"
@@ -31,7 +32,8 @@
: public invalidation::InvalidationHandler,
public invalidation::InvalidationListener::Observer {
public:
- explicit RemoteCommandsInvalidator(std::string owner_name);
+ RemoteCommandsInvalidator(std::string owner_name,
+ PolicyInvalidationScope scope);
RemoteCommandsInvalidator(const RemoteCommandsInvalidator&) = delete;
RemoteCommandsInvalidator& operator=(const RemoteCommandsInvalidator&) =
delete;
@@ -129,6 +131,8 @@
// `invalidation::InvalidationHandler`.
const std::string owner_name_;
+ const PolicyInvalidationScope scope_;
+
// The invalidation service or listener.
std::variant<raw_ptr<invalidation::InvalidationService>,
raw_ptr<invalidation::InvalidationListener>>
diff --git a/components/policy/core/common/remote_commands/remote_commands_invalidator_impl.cc b/components/policy/core/common/remote_commands/remote_commands_invalidator_impl.cc
index 89b9d12..bbb6c1c 100644
--- a/components/policy/core/common/remote_commands/remote_commands_invalidator_impl.cc
+++ b/components/policy/core/common/remote_commands/remote_commands_invalidator_impl.cc
@@ -55,7 +55,7 @@
CloudPolicyCore* core,
const base::Clock* clock,
PolicyInvalidationScope scope)
- : RemoteCommandsInvalidator(ComposeOwnerName(scope)),
+ : RemoteCommandsInvalidator(ComposeOwnerName(scope), scope),
core_(core),
clock_(clock),
scope_(scope) {
diff --git a/components/policy/core/common/remote_commands/remote_commands_invalidator_unittest.cc b/components/policy/core/common/remote_commands/remote_commands_invalidator_unittest.cc
index b3dbf08b..c732291 100644
--- a/components/policy/core/common/remote_commands/remote_commands_invalidator_unittest.cc
+++ b/components/policy/core/common/remote_commands/remote_commands_invalidator_unittest.cc
@@ -30,7 +30,8 @@
class MockRemoteCommandInvalidator : public RemoteCommandsInvalidator {
public:
MockRemoteCommandInvalidator()
- : RemoteCommandsInvalidator("RemoteCommands.Test") {}
+ : RemoteCommandsInvalidator("RemoteCommands.Test",
+ PolicyInvalidationScope::kDevice) {}
MockRemoteCommandInvalidator(const MockRemoteCommandInvalidator&) = delete;
MockRemoteCommandInvalidator& operator=(const MockRemoteCommandInvalidator&) =
delete;
diff --git a/components/policy/core/common/remote_commands/remote_commands_invalidator_with_listener_unittest.cc b/components/policy/core/common/remote_commands/remote_commands_invalidator_with_listener_unittest.cc
index 1f46614..135b948 100644
--- a/components/policy/core/common/remote_commands/remote_commands_invalidator_with_listener_unittest.cc
+++ b/components/policy/core/common/remote_commands/remote_commands_invalidator_with_listener_unittest.cc
@@ -26,7 +26,7 @@
namespace policy {
-constexpr char kRemoteCommandsInvalidationType[] = "remote_command";
+constexpr char kRemoteCommandsInvalidationType[] = "DEVICE_REMOTE_COMMAND";
constexpr PolicyInvalidationScope kInvalidationScope =
PolicyInvalidationScope::kDevice;