• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_METRICS_STRUCTURED_TEST_TEST_EVENT_STORAGE_H_
6 #define COMPONENTS_METRICS_STRUCTURED_TEST_TEST_EVENT_STORAGE_H_
7 
8 #include "components/metrics/structured/event_storage.h"
9 #include "components/metrics/structured/storage.pb.h"
10 
11 namespace metrics::structured {
12 
13 // Simple in-memory event storage for unit and some browser tests.
14 class TestEventStorage final : public EventStorage {
15  public:
16   TestEventStorage();
17 
18   ~TestEventStorage() override;
19 
20   // EventStorage:
21   void AddEvent(StructuredEventProto&& event) override;
22   void MoveEvents(ChromeUserMetricsExtension& uma_proto) override;
23   int RecordedEventsCount() const override;
24   void Purge() override;
25   void AddBatchEvents(
26       const google::protobuf::RepeatedPtrField<StructuredEventProto>& events)
27       override;
28 
events()29   EventsProto* events() { return &events_; }
events()30   const EventsProto* events() const { return &events_; }
31 
32  private:
33   EventsProto events_;
34 };
35 
36 }  // namespace metrics::structured
37 
38 #endif  // COMPONENTS_METRICS_STRUCTURED_TEST_TEST_EVENT_STORAGE_H_
39