OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ | 5 #ifndef MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ |
6 #define MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ | 6 #define MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/single_thread_task_runner.h" | |
12 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
13 #include "media/cast/logging/raw_event_subscriber.h" | 11 #include "media/cast/logging/raw_event_subscriber.h" |
14 | 12 |
15 namespace media { | 13 namespace media { |
16 namespace cast { | 14 namespace cast { |
17 | 15 |
18 // RawEventSubscriber implementation that records all incoming raw events | 16 // RawEventSubscriber implementation that records all incoming raw events |
19 // in std::vector's. | 17 // in std::vector's. |
20 // The user of this class can call the GetXXXEventsAndReset functions to get | 18 // The user of this class can call the GetXXXEventsAndReset functions to get |
21 // list of events that have acccumulated since last inovcation. | 19 // list of events that have acccumulated since last inovcation. |
22 class SimpleEventSubscriber : public RawEventSubscriber { | 20 class SimpleEventSubscriber : public RawEventSubscriber { |
23 public: | 21 public: |
24 // |main_thread_proxy|: Only used for ensuring the subscriber is only called | 22 SimpleEventSubscriber(); |
25 // on the main thread. This object does not keep a reference on it. | |
26 explicit SimpleEventSubscriber( | |
27 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_proxy); | |
28 | 23 |
29 virtual ~SimpleEventSubscriber(); | 24 virtual ~SimpleEventSubscriber(); |
30 | 25 |
| 26 // RawEventSubscriber implementations. |
31 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; | 27 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; |
32 | |
33 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; | 28 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; |
34 | |
35 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) | 29 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) |
36 OVERRIDE; | 30 OVERRIDE; |
37 | 31 |
38 // Assigns frame events received so far to |frame_events| and clears them | 32 // Assigns frame events received so far to |frame_events| and clears them |
39 // from this object. | 33 // from this object. |
40 void GetFrameEventsAndReset(std::vector<FrameEvent>* frame_events); | 34 void GetFrameEventsAndReset(std::vector<FrameEvent>* frame_events); |
41 | 35 |
42 // Assigns packet events received so far to |packet_events| and clears them | 36 // Assigns packet events received so far to |packet_events| and clears them |
43 // from this object. | 37 // from this object. |
44 void GetPacketEventsAndReset(std::vector<PacketEvent>* packet_events); | 38 void GetPacketEventsAndReset(std::vector<PacketEvent>* packet_events); |
(...skipping 10 matching lines...) Expand all Loading... |
55 // All functions must be called on the main thread. | 49 // All functions must be called on the main thread. |
56 base::ThreadChecker thread_checker_; | 50 base::ThreadChecker thread_checker_; |
57 | 51 |
58 DISALLOW_COPY_AND_ASSIGN(SimpleEventSubscriber); | 52 DISALLOW_COPY_AND_ASSIGN(SimpleEventSubscriber); |
59 }; | 53 }; |
60 | 54 |
61 } // namespace cast | 55 } // namespace cast |
62 } // namespace media | 56 } // namespace media |
63 | 57 |
64 #endif // MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ | 58 #endif // MEDIA_CAST_LOGGING_SIMPLE_EVENT_SUBSCRIBER_H_ |
OLD | NEW |