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
3 // found in the LICENSE file.
5 #include "ppapi/proxy/plugin_message_filter.h"
7 #include "ppapi/proxy/ppapi_messages.h"
12 PluginMessageFilter::PluginMessageFilter(
13 std::set
<PP_Instance
>* seen_instance_ids
)
14 : seen_instance_ids_(seen_instance_ids
),
18 PluginMessageFilter::~PluginMessageFilter() {
21 void PluginMessageFilter::OnFilterAdded(IPC::Channel
* channel
) {
25 void PluginMessageFilter::OnFilterRemoved() {
29 bool PluginMessageFilter::OnMessageReceived(const IPC::Message
& message
) {
31 IPC_BEGIN_MESSAGE_MAP(PluginMessageFilter
, message
)
32 IPC_MESSAGE_HANDLER(PpapiMsg_ReserveInstanceId
, OnMsgReserveInstanceId
)
33 IPC_MESSAGE_UNHANDLED(handled
= false)
38 bool PluginMessageFilter::Send(IPC::Message
* msg
) {
40 return channel_
->Send(msg
);
45 void PluginMessageFilter::OnMsgReserveInstanceId(PP_Instance instance
,
47 // See the message definition for how this works.
48 if (seen_instance_ids_
->find(instance
) != seen_instance_ids_
->end()) {
49 // Instance ID already seen, reject it.
54 // This instance ID is new so we can return that it's usable and mark it as
55 // used for future reference.
56 seen_instance_ids_
->insert(instance
);