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/threading/thread_checker.h"
11 #include "media/cast/logging/raw_event_subscriber.h"
16 // RawEventSubscriber implementation that records all incoming raw events
18 // The user of this class can call the GetXXXEventsAndReset functions to get
19 // list of events that have acccumulated since last inovcation.
20 class SimpleEventSubscriber
: public RawEventSubscriber
{
22 SimpleEventSubscriber();
24 virtual ~SimpleEventSubscriber();
26 // RawEventSubscriber implementations.
27 virtual void OnReceiveFrameEvent(const FrameEvent
& frame_event
) OVERRIDE
;
28 virtual void OnReceivePacketEvent(const PacketEvent
& packet_event
) OVERRIDE
;
29 virtual void OnReceiveGenericEvent(const GenericEvent
& generic_event
)
32 // Assigns frame events received so far to |frame_events| and clears them
34 void GetFrameEventsAndReset(std::vector
<FrameEvent
>* frame_events
);
36 // Assigns packet events received so far to |packet_events| and clears them
38 void GetPacketEventsAndReset(std::vector
<PacketEvent
>* packet_events
);
40 // Assigns generic events received so far to |generic_events| and clears them
42 void GetGenericEventsAndReset(std::vector
<GenericEvent
>* generic_events
);
45 std::vector
<FrameEvent
> frame_events_
;
46 std::vector
<PacketEvent
> packet_events_
;
47 std::vector
<GenericEvent
> generic_events_
;
49 // All functions must be called on the main thread.
50 base::ThreadChecker thread_checker_
;
52 DISALLOW_COPY_AND_ASSIGN(SimpleEventSubscriber
);
58 #endif // MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_