Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: media/cast/logging/log_event_dispatcher.h

Issue 1905763002: Convert //media/cast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/logging/log_deserializer.cc ('k') | media/cast/logging/log_event_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_LOG_EVENT_DISPATCHER_H_ 5 #ifndef MEDIA_CAST_LOGGING_LOG_EVENT_DISPATCHER_H_
6 #define MEDIA_CAST_LOGGING_LOG_EVENT_DISPATCHER_H_ 6 #define MEDIA_CAST_LOGGING_LOG_EVENT_DISPATCHER_H_
7 7
8 #include <memory>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "media/cast/logging/logging_defines.h" 13 #include "media/cast/logging/logging_defines.h"
14 #include "media/cast/logging/raw_event_subscriber.h" 14 #include "media/cast/logging/raw_event_subscriber.h"
15 15
16 namespace media { 16 namespace media {
17 namespace cast { 17 namespace cast {
18 18
19 class CastEnvironment; 19 class CastEnvironment;
20 20
21 // A thread-safe receiver of logging events that manages an active list of 21 // A thread-safe receiver of logging events that manages an active list of
22 // EventSubscribers and dispatches the logging events to them on the MAIN 22 // EventSubscribers and dispatches the logging events to them on the MAIN
23 // thread. All methods, constructor, and destructor can be invoked on any 23 // thread. All methods, constructor, and destructor can be invoked on any
24 // thread. 24 // thread.
25 class LogEventDispatcher { 25 class LogEventDispatcher {
26 public: 26 public:
27 // |env| outlives this instance (and generally owns this instance). 27 // |env| outlives this instance (and generally owns this instance).
28 explicit LogEventDispatcher(CastEnvironment* env); 28 explicit LogEventDispatcher(CastEnvironment* env);
29 29
30 ~LogEventDispatcher(); 30 ~LogEventDispatcher();
31 31
32 // Called on any thread to schedule the sending of event(s) to all 32 // Called on any thread to schedule the sending of event(s) to all
33 // EventSubscribers on the MAIN thread. 33 // EventSubscribers on the MAIN thread.
34 void DispatchFrameEvent(scoped_ptr<FrameEvent> event) const; 34 void DispatchFrameEvent(std::unique_ptr<FrameEvent> event) const;
35 void DispatchPacketEvent(scoped_ptr<PacketEvent> event) const; 35 void DispatchPacketEvent(std::unique_ptr<PacketEvent> event) const;
36 void DispatchBatchOfEvents( 36 void DispatchBatchOfEvents(
37 scoped_ptr<std::vector<FrameEvent>> frame_events, 37 std::unique_ptr<std::vector<FrameEvent>> frame_events,
38 scoped_ptr<std::vector<PacketEvent>> packet_events) const; 38 std::unique_ptr<std::vector<PacketEvent>> packet_events) const;
39 39
40 // Adds |subscriber| to the active list to begin receiving events on MAIN 40 // Adds |subscriber| to the active list to begin receiving events on MAIN
41 // thread. Unsubscribe() must be called before |subscriber| is destroyed. 41 // thread. Unsubscribe() must be called before |subscriber| is destroyed.
42 void Subscribe(RawEventSubscriber* subscriber); 42 void Subscribe(RawEventSubscriber* subscriber);
43 43
44 // Removes |subscriber| from the active list. Once this method returns, the 44 // Removes |subscriber| from the active list. Once this method returns, the
45 // |subscriber| is guaranteed not to receive any more events. 45 // |subscriber| is guaranteed not to receive any more events.
46 void Unsubscribe(RawEventSubscriber* subscriber); 46 void Unsubscribe(RawEventSubscriber* subscriber);
47 47
48 private: 48 private:
49 // The part of the implementation that runs exclusively on the MAIN thread. 49 // The part of the implementation that runs exclusively on the MAIN thread.
50 class Impl : public base::RefCountedThreadSafe<Impl> { 50 class Impl : public base::RefCountedThreadSafe<Impl> {
51 public: 51 public:
52 Impl(); 52 Impl();
53 53
54 void DispatchFrameEvent(scoped_ptr<FrameEvent> event) const; 54 void DispatchFrameEvent(std::unique_ptr<FrameEvent> event) const;
55 void DispatchPacketEvent(scoped_ptr<PacketEvent> event) const; 55 void DispatchPacketEvent(std::unique_ptr<PacketEvent> event) const;
56 void DispatchBatchOfEvents( 56 void DispatchBatchOfEvents(
57 scoped_ptr<std::vector<FrameEvent>> frame_events, 57 std::unique_ptr<std::vector<FrameEvent>> frame_events,
58 scoped_ptr<std::vector<PacketEvent>> packet_events) const; 58 std::unique_ptr<std::vector<PacketEvent>> packet_events) const;
59 void Subscribe(RawEventSubscriber* subscriber); 59 void Subscribe(RawEventSubscriber* subscriber);
60 void Unsubscribe(RawEventSubscriber* subscriber); 60 void Unsubscribe(RawEventSubscriber* subscriber);
61 61
62 private: 62 private:
63 friend class base::RefCountedThreadSafe<Impl>; 63 friend class base::RefCountedThreadSafe<Impl>;
64 64
65 ~Impl(); 65 ~Impl();
66 66
67 std::vector<RawEventSubscriber*> subscribers_; 67 std::vector<RawEventSubscriber*> subscribers_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(Impl); 69 DISALLOW_COPY_AND_ASSIGN(Impl);
70 }; 70 };
71 71
72 CastEnvironment* const env_; // Owner of this instance. 72 CastEnvironment* const env_; // Owner of this instance.
73 const scoped_refptr<Impl> impl_; 73 const scoped_refptr<Impl> impl_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(LogEventDispatcher); 75 DISALLOW_COPY_AND_ASSIGN(LogEventDispatcher);
76 }; 76 };
77 77
78 } // namespace cast 78 } // namespace cast
79 } // namespace media 79 } // namespace media
80 80
81 #endif // MEDIA_CAST_LOGGING_LOG_EVENT_DISPATCHER_H_ 81 #endif // MEDIA_CAST_LOGGING_LOG_EVENT_DISPATCHER_H_
OLDNEW
« no previous file with comments | « media/cast/logging/log_deserializer.cc ('k') | media/cast/logging/log_event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698