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. 4 5 #ifndef MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ 6 #define MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ 7 8 #include <vector> 9 10 #include "base/compiler_specific.h" 11 #include "base/threading/thread_checker.h" 12 #include "media/cast/logging/raw_event_subscriber.h" 13 14 namespace media { 15 namespace cast { 16 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(); 24 25 virtual ~SimpleEventSubscriber(); 26 27 // RawEventSubscriber implementations. 28 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; 29 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; 30 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); 34 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); 38 39 private: 40 std::vector<FrameEvent> frame_events_; 41 std::vector<PacketEvent> packet_events_; 42 43 // All functions must be called on the main thread. 44 base::ThreadChecker thread_checker_; 45 46 DISALLOW_COPY_AND_ASSIGN(SimpleEventSubscriber); 47 }; 48 49 } // namespace cast 50 } // namespace media 51 52 #endif // MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ 53