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

Unified Diff: ppapi/proxy/plugin_message_filter.cc

Issue 6628019: Ensure that PP_Instance values are unique within a plugin process in addition... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/plugin_message_filter.h ('k') | ppapi/proxy/ppapi_messages_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/plugin_message_filter.cc
===================================================================
--- ppapi/proxy/plugin_message_filter.cc (revision 0)
+++ ppapi/proxy/plugin_message_filter.cc (revision 0)
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/plugin_message_filter.h"
+
+#include "ppapi/proxy/ppapi_messages.h"
+
+namespace pp {
+namespace proxy {
+
+PluginMessageFilter::PluginMessageFilter(
+ std::set<PP_Instance>* seen_instance_ids)
+ : seen_instance_ids_(seen_instance_ids),
+ channel_(NULL) {
+}
+
+PluginMessageFilter::~PluginMessageFilter() {
+}
+
+void PluginMessageFilter::OnFilterAdded(IPC::Channel* channel) {
+ channel_ = channel;
+}
+
+void PluginMessageFilter::OnFilterRemoved() {
+ channel_ = NULL;
+}
+
+bool PluginMessageFilter::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PluginMessageFilter, message)
+ IPC_MESSAGE_HANDLER(PpapiMsg_ReserveInstanceId, OnMsgReserveInstanceId)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+bool PluginMessageFilter::Send(IPC::Message* msg) {
+ if (channel_)
+ return channel_->Send(msg);
+ delete msg;
+ return false;
+}
+
+void PluginMessageFilter::OnMsgReserveInstanceId(PP_Instance instance,
+ bool* usable) {
+ // See the message definition for how this works.
+ if (seen_instance_ids_->find(instance) != seen_instance_ids_->end()) {
+ // Instance ID already seen, reject it.
+ *usable = false;
+ return;
+ }
+
+ // This instance ID is new so we can return that it's usable and mark it as
+ // used for future reference.
+ seen_instance_ids_->insert(instance);
+ *usable = true;
+}
+
+} // namespace proxy
+} // namespace pp
Property changes on: ppapi/proxy/plugin_message_filter.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « ppapi/proxy/plugin_message_filter.h ('k') | ppapi/proxy/ppapi_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698