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

Unified Diff: components/policy/core/common/cloud/component_cloud_policy_store.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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: components/policy/core/common/cloud/component_cloud_policy_store.cc
diff --git a/components/policy/core/common/cloud/component_cloud_policy_store.cc b/components/policy/core/common/cloud/component_cloud_policy_store.cc
index dbcff3bdf2b4941d8519df4942da6d49a9affe82..257e7e689c126eec17a97e532e76e14e9fc4a936 100644
--- a/components/policy/core/common/cloud/component_cloud_policy_store.cc
+++ b/components/policy/core/common/cloud/component_cloud_policy_store.cc
@@ -66,7 +66,8 @@ ComponentCloudPolicyStore::ComponentCloudPolicyStore(
Delegate* delegate,
ResourceCache* cache)
: delegate_(delegate),
- cache_(cache) {
+ cache_(cache),
+ user_id_(std::string(), std::string()) {
// Allow the store to be created on a different thread than the thread that
// will end up using it.
DetachFromThread();
@@ -107,12 +108,12 @@ const std::string& ComponentCloudPolicyStore::GetCachedHash(
return it == cached_hashes_.end() ? base::EmptyString() : it->second;
}
-void ComponentCloudPolicyStore::SetCredentials(const std::string& username,
+void ComponentCloudPolicyStore::SetCredentials(const user_manager::UserID& user_id,
const std::string& dm_token) {
DCHECK(CalledOnValidThread());
- DCHECK(username_.empty() || username == username_);
+ DCHECK(user_id_.empty() || user_id == user_id_);
DCHECK(dm_token_.empty() || dm_token == dm_token_);
- username_ = username;
+ user_id_ = user_id_;
dm_token_ = dm_token;
}
@@ -273,13 +274,13 @@ bool ComponentCloudPolicyStore::ValidateProto(
const std::string& settings_entity_id,
em::ExternalPolicyData* payload,
em::PolicyData* policy_data) {
- if (username_.empty() || dm_token_.empty())
+ if (user_id_.empty() || dm_token_.empty())
return false;
scoped_ptr<ComponentCloudPolicyValidator> validator(
ComponentCloudPolicyValidator::Create(
proto.Pass(), scoped_refptr<base::SequencedTaskRunner>()));
- validator->ValidateUsername(username_, true);
+ validator->ValidateUsername(user_id_, true);
validator->ValidateDMToken(dm_token_,
ComponentCloudPolicyValidator::DM_TOKEN_REQUIRED);
if (!policy_type.empty())

Powered by Google App Engine
This is Rietveld 408576698