summaryrefslogtreecommitdiff
path: root/chromium/components/cryptauth/data_with_timestamp.h
blob: e341ede98b2ee816ea40b54f77a4ed9495bfb1ad (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
41
42
43
// 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_CRYPTAUTH_BLE_DATA_WITH_TIMESTAMP_H_
#define COMPONENTS_CRYPTAUTH_BLE_DATA_WITH_TIMESTAMP_H_

#include <string>
#include <vector>

namespace cryptauth {

// Stores EID-related data and timestamps at which time this data becomes
// active or inactive.
struct DataWithTimestamp {
  DataWithTimestamp(const std::string& data,
                    const int64_t start_timestamp_ms,
                    const int64_t end_timestamp_ms);
  DataWithTimestamp(const DataWithTimestamp& other);

  // Helper function to convert a vector of DataWithTimestamp objects to a human
  // readable debug string.
  static std::string ToDebugString(
      const std::vector<DataWithTimestamp>& data_with_timestamps);

  bool ContainsTime(const int64_t timestamp_ms) const;
  std::string DataInHex() const;

  bool operator==(const DataWithTimestamp& other) const;

  // The data valid for a given time period.
  std::string data;

  // The start time for which the data is valid, inclusive.
  int64_t start_timestamp_ms;

  // The end time for which the data is valid, exclusive.
  int64_t end_timestamp_ms;
};

}  // namespace

#endif  // COMPONENTS_CRYPTAUTH_BLE_DATA_WITH_TIMESTAMP_H_