summaryrefslogtreecommitdiff
path: root/chromium/components/feature_engagement_tracker/internal/storage_validator.h
blob: 15d2d3dc62bad45586cc93c3b7f853c89a5d3953 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2017 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_FEATURE_ENGAGEMENT_TRACKER_INTERNAL_STORAGE_VALIDATOR_H_
#define COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_INTERNAL_STORAGE_VALIDATOR_H_

#include <string>

#include "base/macros.h"

namespace feature_engagement_tracker {

// A StorageValidator checks the required storage conditions for a given event,
// and checks if all conditions are met for storing it.
class StorageValidator {
 public:
  virtual ~StorageValidator() = default;

  // Returns true iff new events of this type should be stored.
  // This is typically called before storing each incoming event.
  virtual bool ShouldStore(const std::string& event_name) const = 0;

  // Returns true iff events of this type should be kept for the given day.
  // This is typically called during load of the internal database state, to
  // possibly throw away old data.
  virtual bool ShouldKeep(const std::string& event_name,
                          uint32_t event_day,
                          uint32_t current_day) const = 0;

 protected:
  StorageValidator() = default;

 private:
  DISALLOW_COPY_AND_ASSIGN(StorageValidator);
};

}  // namespace feature_engagement_tracker

#endif  // COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_INTERNAL_STORAGE_VALIDATOR_H_