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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/plugin_message_filter.h ('k') | ppapi/proxy/ppapi_messages_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #include "ppapi/proxy/plugin_message_filter.h"
6
7 #include "ppapi/proxy/ppapi_messages.h"
8
9 namespace pp {
10 namespace proxy {
11
12 PluginMessageFilter::PluginMessageFilter(
13 std::set<PP_Instance>* seen_instance_ids)
14 : seen_instance_ids_(seen_instance_ids),
15 channel_(NULL) {
16 }
17
18 PluginMessageFilter::~PluginMessageFilter() {
19 }
20
21 void PluginMessageFilter::OnFilterAdded(IPC::Channel* channel) {
22 channel_ = channel;
23 }
24
25 void PluginMessageFilter::OnFilterRemoved() {
26 channel_ = NULL;
27 }
28
29 bool PluginMessageFilter::OnMessageReceived(const IPC::Message& message) {
30 bool handled = true;
31 IPC_BEGIN_MESSAGE_MAP(PluginMessageFilter, message)
32 IPC_MESSAGE_HANDLER(PpapiMsg_ReserveInstanceId, OnMsgReserveInstanceId)
33 IPC_MESSAGE_UNHANDLED(handled = false)
34 IPC_END_MESSAGE_MAP()
35 return handled;
36 }
37
38 bool PluginMessageFilter::Send(IPC::Message* msg) {
39 if (channel_)
40 return channel_->Send(msg);
41 delete msg;
42 return false;
43 }
44
45 void PluginMessageFilter::OnMsgReserveInstanceId(PP_Instance instance,
46 bool* usable) {
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.
50 *usable = false;
51 return;
52 }
53
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);
57 *usable = true;
58 }
59
60 } // namespace proxy
61 } // namespace pp
OLDNEW
« 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