xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/test_tools/simulator/alarm_factory.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2012 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 
5 #ifndef QUICHE_QUIC_TEST_TOOLS_SIMULATOR_ALARM_FACTORY_H_
6 #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_ALARM_FACTORY_H_
7 
8 #include "quiche/quic/core/quic_alarm_factory.h"
9 #include "quiche/quic/test_tools/simulator/actor.h"
10 
11 namespace quic {
12 namespace simulator {
13 
14 // AlarmFactory allows to schedule QuicAlarms using the simulation event queue.
15 class AlarmFactory : public QuicAlarmFactory {
16  public:
17   AlarmFactory(Simulator* simulator, std::string name);
18   AlarmFactory(const AlarmFactory&) = delete;
19   AlarmFactory& operator=(const AlarmFactory&) = delete;
20   ~AlarmFactory() override;
21 
22   QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) override;
23   QuicArenaScopedPtr<QuicAlarm> CreateAlarm(
24       QuicArenaScopedPtr<QuicAlarm::Delegate> delegate,
25       QuicConnectionArena* arena) override;
26 
27  private:
28   // Automatically generate a name for a new alarm.
29   std::string GetNewAlarmName();
30 
31   Simulator* simulator_;
32   std::string name_;
33   int counter_;
34 };
35 
36 }  // namespace simulator
37 }  // namespace quic
38 
39 #endif  // QUICHE_QUIC_TEST_TOOLS_SIMULATOR_ALARM_FACTORY_H_
40