supplementary_branding.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef RLZ_LIB_SUPPLEMENTARY_BRANDING_H_
  5. #define RLZ_LIB_SUPPLEMENTARY_BRANDING_H_
  6. #include <string>
  7. #include "base/memory/raw_ptr.h"
  8. namespace rlz_lib {
  9. class ScopedRlzValueStoreLock;
  10. // Segment RLZ persistence based on branding information.
  11. // All information for a given product is persisted under keys with the either
  12. // product's name or its access point's name. This assumes that only
  13. // one instance of the product is installed on the machine, and that only one
  14. // product brand is associated with it.
  15. //
  16. // In some cases, a given product may be using supplementary brands. The RLZ
  17. // information must be kept separately for each of these brands. To achieve
  18. // this segmentation, scope all RLZ library calls that deal with supplementary
  19. // brands within the lifetime of an rlz_lib::ProductBranding instance.
  20. //
  21. // For example, to record events for a supplementary brand, do the following:
  22. //
  23. // {
  24. // rlz_lib::SupplementaryBranding branding("AAAA");
  25. // // This call to RecordProductEvent is scoped to the AAAA brand.
  26. // rlz_lib::RecordProductEvent(rlz_lib::DESKTOP, rlz_lib::GD_DESKBAND,
  27. // rlz_lib::INSTALL);
  28. // }
  29. //
  30. // // This call to RecordProductEvent is not scoped to any supplementary brand.
  31. // rlz_lib::RecordProductEvent(rlz_lib::DESKTOP, rlz_lib::GD_DESKBAND,
  32. // rlz_lib::INSTALL);
  33. //
  34. // In particular, this affects the recording of stateful events and the sending
  35. // of financial pings. In the former case, a stateful event recorded while
  36. // scoped to a supplementary brand will be recorded again when scoped to a
  37. // different supplementary brand (or not scoped at all). In the latter case,
  38. // the time skip check is specific to each supplementary brand.
  39. class SupplementaryBranding {
  40. public:
  41. explicit SupplementaryBranding(const char* brand);
  42. ~SupplementaryBranding();
  43. static const std::string& GetBrand();
  44. private:
  45. raw_ptr<ScopedRlzValueStoreLock> lock_;
  46. };
  47. } // namespace rlz_lib
  48. #endif // RLZ_LIB_SUPPLEMENTARY_BRANDING_H_