summaryrefslogtreecommitdiff
path: root/chromium/components/federated_learning/floc_id.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/federated_learning/floc_id.h
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/federated_learning/floc_id.h')
-rw-r--r--chromium/components/federated_learning/floc_id.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/chromium/components/federated_learning/floc_id.h b/chromium/components/federated_learning/floc_id.h
new file mode 100644
index 00000000000..ad2d9942641
--- /dev/null
+++ b/chromium/components/federated_learning/floc_id.h
@@ -0,0 +1,46 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_FEDERATED_LEARNING_FLOC_ID_H_
+#define COMPONENTS_FEDERATED_LEARNING_FLOC_ID_H_
+
+#include "base/optional.h"
+
+#include <stdint.h>
+
+#include <string>
+#include <unordered_set>
+
+namespace federated_learning {
+
+// ID used to represent a cohort of people with similar browsing habits. For
+// more context, see the explainer at
+// https://github.com/jkarlin/floc/blob/master/README.md
+class FlocId {
+ public:
+ static FlocId CreateFromHistory(
+ const std::unordered_set<std::string>& domains);
+
+ FlocId();
+ explicit FlocId(uint64_t id);
+ FlocId(const FlocId& id);
+
+ ~FlocId();
+ FlocId& operator=(const FlocId& id);
+ FlocId& operator=(FlocId&& id);
+
+ bool IsValid() const;
+ uint64_t ToUint64() const;
+
+ std::string ToDebugHeaderValue() const;
+
+ private:
+ std::string ToHeaderValue() const;
+
+ base::Optional<uint64_t> id_;
+};
+
+} // namespace federated_learning
+
+#endif // COMPONENTS_FEDERATED_LEARNING_FLOC_ID_H_