Commit 5f896797 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Add unique OTR profile id creator.

Adds a OTRProfileID::CreateUnique to create a unique OffTheRecrord
profile id with the given prefix.

Bug: 1033903
Change-Id: Iaa6408a17d72521b8c22feec82843ad4081abece
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145875Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758766}
parent 874a55af
......@@ -111,6 +111,16 @@ const Profile::OTRProfileID Profile::OTRProfileID::PrimaryID() {
return OTRProfileID("profile::primary_otr");
}
// static
int Profile::OTRProfileID::first_unused_index_ = 0;
// static
Profile::OTRProfileID Profile::OTRProfileID::CreateUnique(
const std::string& profile_id_prefix) {
return OTRProfileID(base::StringPrintf("%s-%i", profile_id_prefix.c_str(),
first_unused_index_++));
}
const std::string& Profile::OTRProfileID::ToString() const {
return profile_id_;
}
......
......@@ -115,6 +115,9 @@ class Profile : public content::BrowserContext {
// |GuestID| when the use cases are reduced.
static const OTRProfileID PrimaryID();
// Creates a unique OTR profile id with the given profile id prefix.
static OTRProfileID CreateUnique(const std::string& profile_id_prefix);
bool operator==(const OTRProfileID& other) const {
return profile_id_ == other.profile_id_;
}
......@@ -137,6 +140,8 @@ class Profile : public content::BrowserContext {
// message.
const std::string& ToString() const;
static int first_unused_index_;
const std::string profile_id_;
};
......
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