diff options
Diffstat (limited to 'chromium/components/federated_learning/floc_id.h')
-rw-r--r-- | chromium/components/federated_learning/floc_id.h | 46 |
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_ |