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 CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
6 #define CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ | 6 #define CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "ipc/ipc_channel_proxy.h" | 10 #include "ipc/ipc_channel_proxy.h" |
| 11 #include "ipc/message_filter.h" |
11 #include "media/cast/cast_sender.h" | 12 #include "media/cast/cast_sender.h" |
12 #include "media/cast/logging/logging_defines.h" | 13 #include "media/cast/logging/logging_defines.h" |
13 #include "media/cast/transport/cast_transport_sender.h" | 14 #include "media/cast/transport/cast_transport_sender.h" |
14 | 15 |
15 class CastTransportSenderIPC; | 16 class CastTransportSenderIPC; |
16 | 17 |
17 // This dispatcher listens to incoming IPC messages and sends | 18 // This dispatcher listens to incoming IPC messages and sends |
18 // the call to the correct CastTransportSenderIPC instance. | 19 // the call to the correct CastTransportSenderIPC instance. |
19 class CastIPCDispatcher : public IPC::ChannelProxy::MessageFilter { | 20 class CastIPCDispatcher : public IPC::MessageFilter { |
20 public: | 21 public: |
21 explicit CastIPCDispatcher( | 22 explicit CastIPCDispatcher( |
22 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); | 23 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
23 | 24 |
24 static CastIPCDispatcher* Get(); | 25 static CastIPCDispatcher* Get(); |
25 void Send(IPC::Message* message); | 26 void Send(IPC::Message* message); |
26 int32 AddSender(CastTransportSenderIPC* sender); | 27 int32 AddSender(CastTransportSenderIPC* sender); |
27 void RemoveSender(int32 channel_id); | 28 void RemoveSender(int32 channel_id); |
28 | 29 |
29 // IPC::ChannelProxy::MessageFilter implementation | 30 // IPC::MessageFilter implementation |
30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
31 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 32 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
32 virtual void OnFilterRemoved() OVERRIDE; | 33 virtual void OnFilterRemoved() OVERRIDE; |
33 virtual void OnChannelClosing() OVERRIDE; | 34 virtual void OnChannelClosing() OVERRIDE; |
34 | 35 |
35 protected: | 36 protected: |
36 virtual ~CastIPCDispatcher(); | 37 virtual ~CastIPCDispatcher(); |
37 | 38 |
38 private: | 39 private: |
39 void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet); | 40 void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet); |
(...skipping 17 matching lines...) Expand all Loading... |
57 // Message loop on which IPC calls are driven. | 58 // Message loop on which IPC calls are driven. |
58 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 59 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
59 | 60 |
60 // A map of stream ids to delegates; must only be accessed on | 61 // A map of stream ids to delegates; must only be accessed on |
61 // |io_message_loop_|. | 62 // |io_message_loop_|. |
62 IDMap<CastTransportSenderIPC> id_map_; | 63 IDMap<CastTransportSenderIPC> id_map_; |
63 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher); | 64 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher); |
64 }; | 65 }; |
65 | 66 |
66 #endif // CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ | 67 #endif // CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
OLD | NEW |