Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / cast / logging / simple_event_subscriber.h
blob1bdce4539f9d2b5eaf524314e7db2cb6c00b3532
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_
8 #include <vector>
10 #include "base/compiler_specific.h"
11 #include "base/threading/thread_checker.h"
12 #include "media/cast/logging/raw_event_subscriber.h"
14 namespace media {
15 namespace cast {
17 // RawEventSubscriber implementation that records all incoming raw events
18 // in std::vector's.
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 {
22 public:
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
32 // from this object.
33 void GetFrameEventsAndReset(std::vector<FrameEvent>* frame_events);
35 // Assigns packet events received so far to |packet_events| and clears them
36 // from this object.
37 void GetPacketEventsAndReset(std::vector<PacketEvent>* packet_events);
39 private:
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);
49 } // namespace cast
50 } // namespace media
52 #endif // MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_