OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "ppapi/proxy/plugin_message_filter.h" | 5 #include "ppapi/proxy/plugin_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ipc/ipc_channel.h" | 9 #include "ipc/ipc_channel.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
11 #include "ppapi/proxy/resource_message_params.h" | 11 #include "ppapi/proxy/resource_message_params.h" |
12 #include "ppapi/proxy/resource_reply_thread_registrar.h" | 12 #include "ppapi/proxy/resource_reply_thread_registrar.h" |
13 #include "ppapi/shared_impl/ppapi_globals.h" | 13 #include "ppapi/shared_impl/ppapi_globals.h" |
14 #include "ppapi/shared_impl/proxy_lock.h" | 14 #include "ppapi/shared_impl/proxy_lock.h" |
15 #include "ppapi/shared_impl/resource.h" | 15 #include "ppapi/shared_impl/resource.h" |
16 #include "ppapi/shared_impl/resource_tracker.h" | 16 #include "ppapi/shared_impl/resource_tracker.h" |
17 | 17 |
18 namespace ppapi { | 18 namespace ppapi { |
19 namespace proxy { | 19 namespace proxy { |
20 | 20 |
21 PluginMessageFilter::PluginMessageFilter( | 21 PluginMessageFilter::PluginMessageFilter( |
22 std::set<PP_Instance>* seen_instance_ids, | 22 std::set<PP_Instance>* seen_instance_ids, |
23 scoped_refptr<ResourceReplyThreadRegistrar> registrar) | 23 scoped_refptr<ResourceReplyThreadRegistrar> registrar) |
24 : seen_instance_ids_(seen_instance_ids), | 24 : seen_instance_ids_(seen_instance_ids), |
25 resource_reply_thread_registrar_(registrar), | 25 resource_reply_thread_registrar_(registrar), |
26 channel_(NULL) { | 26 sender_(NULL) { |
27 } | 27 } |
28 | 28 |
29 PluginMessageFilter::~PluginMessageFilter() { | 29 PluginMessageFilter::~PluginMessageFilter() { |
30 } | 30 } |
31 | 31 |
32 void PluginMessageFilter::OnFilterAdded(IPC::Channel* channel) { | 32 void PluginMessageFilter::OnFilterAdded(IPC::Sender* sender) { |
33 channel_ = channel; | 33 sender_ = sender; |
34 } | 34 } |
35 | 35 |
36 void PluginMessageFilter::OnFilterRemoved() { | 36 void PluginMessageFilter::OnFilterRemoved() { |
37 channel_ = NULL; | 37 sender_ = NULL; |
38 } | 38 } |
39 | 39 |
40 bool PluginMessageFilter::OnMessageReceived(const IPC::Message& message) { | 40 bool PluginMessageFilter::OnMessageReceived(const IPC::Message& message) { |
41 bool handled = true; | 41 bool handled = true; |
42 IPC_BEGIN_MESSAGE_MAP(PluginMessageFilter, message) | 42 IPC_BEGIN_MESSAGE_MAP(PluginMessageFilter, message) |
43 IPC_MESSAGE_HANDLER(PpapiMsg_ReserveInstanceId, OnMsgReserveInstanceId) | 43 IPC_MESSAGE_HANDLER(PpapiMsg_ReserveInstanceId, OnMsgReserveInstanceId) |
44 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) | 44 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) |
45 IPC_MESSAGE_UNHANDLED(handled = false) | 45 IPC_MESSAGE_UNHANDLED(handled = false) |
46 IPC_END_MESSAGE_MAP() | 46 IPC_END_MESSAGE_MAP() |
47 return handled; | 47 return handled; |
48 } | 48 } |
49 | 49 |
50 bool PluginMessageFilter::Send(IPC::Message* msg) { | 50 bool PluginMessageFilter::Send(IPC::Message* msg) { |
51 if (channel_) | 51 if (sender_) |
52 return channel_->Send(msg); | 52 return sender_->Send(msg); |
53 delete msg; | 53 delete msg; |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 // static | 57 // static |
58 void PluginMessageFilter::DispatchResourceReplyForTest( | 58 void PluginMessageFilter::DispatchResourceReplyForTest( |
59 const ResourceMessageReplyParams& reply_params, | 59 const ResourceMessageReplyParams& reply_params, |
60 const IPC::Message& nested_msg) { | 60 const IPC::Message& nested_msg) { |
61 DispatchResourceReply(reply_params, nested_msg); | 61 DispatchResourceReply(reply_params, nested_msg); |
62 } | 62 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 DVLOG_IF(1, reply_params.sequence() != 0) | 102 DVLOG_IF(1, reply_params.sequence() != 0) |
103 << "Pepper resource reply message received but the resource doesn't " | 103 << "Pepper resource reply message received but the resource doesn't " |
104 "exist (probably has been destroyed)."; | 104 "exist (probably has been destroyed)."; |
105 return; | 105 return; |
106 } | 106 } |
107 resource->OnReplyReceived(reply_params, nested_msg); | 107 resource->OnReplyReceived(reply_params, nested_msg); |
108 } | 108 } |
109 | 109 |
110 } // namespace proxy | 110 } // namespace proxy |
111 } // namespace ppapi | 111 } // namespace ppapi |
OLD | NEW |