1 // Copyright 2014 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.
5 #ifndef MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_
6 #define MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_
10 #include "base/compiler_specific.h"
11 #include "base/threading/thread_checker.h"
12 #include "media/cast/logging/raw_event_subscriber.h"
17 // RawEventSubscriber implementation that records all incoming raw events
19 // The user of this class can call the GetXXXEventsAndReset functions to get
20 // list of events that have acccumulated since last inovcation.
21 class SimpleEventSubscriber
: public RawEventSubscriber
{
23 SimpleEventSubscriber();
25 ~SimpleEventSubscriber() final
;
27 // RawEventSubscriber implementations.
28 void OnReceiveFrameEvent(const FrameEvent
& frame_event
) final
;
29 void OnReceivePacketEvent(const PacketEvent
& packet_event
) final
;
31 // Assigns frame events received so far to |frame_events| and clears them
33 void GetFrameEventsAndReset(std::vector
<FrameEvent
>* frame_events
);
35 // Assigns packet events received so far to |packet_events| and clears them
37 void GetPacketEventsAndReset(std::vector
<PacketEvent
>* packet_events
);
40 std::vector
<FrameEvent
> frame_events_
;
41 std::vector
<PacketEvent
> packet_events_
;
43 // All functions must be called on the main thread.
44 base::ThreadChecker thread_checker_
;
46 DISALLOW_COPY_AND_ASSIGN(SimpleEventSubscriber
);
52 #endif // MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_