summaryrefslogtreecommitdiffstats
path: root/ppapi/host
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-19 20:42:33 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-19 20:42:33 +0000
commit30e1cb75b8fa46b67cfc7faa146eacdca5e90241 (patch)
tree2b6b293673d938f49843aa6b76143ca7d5950315 /ppapi/host
parentae5df4b22be0cfee27c09c6a1e4721eb0935eab2 (diff)
downloadchromium_src-30e1cb75b8fa46b67cfc7faa146eacdca5e90241.zip
chromium_src-30e1cb75b8fa46b67cfc7faa146eacdca5e90241.tar.gz
chromium_src-30e1cb75b8fa46b67cfc7faa146eacdca5e90241.tar.bz2
Pepper: Use shared memory for ArrayBufferVar.
This change improves performance for sending ArrayBufferVars between the plugin and the host. It copies the data from the var into a shared memory region and sends the shared memory handle over IPC. This required defining a new message for plugins to request the host to create shared memory. BUG= Review URL: https://chromiumcodereview.appspot.com/11827059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/host')
-rw-r--r--ppapi/host/instance_message_filter.cc19
-rw-r--r--ppapi/host/instance_message_filter.h41
-rw-r--r--ppapi/host/ppapi_host.cc20
-rw-r--r--ppapi/host/ppapi_host.h11
4 files changed, 90 insertions, 1 deletions
diff --git a/ppapi/host/instance_message_filter.cc b/ppapi/host/instance_message_filter.cc
new file mode 100644
index 0000000..229235f
--- /dev/null
+++ b/ppapi/host/instance_message_filter.cc
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 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/host/instance_message_filter.h"
+
+#include "ppapi/host/ppapi_host.h"
+
+namespace ppapi {
+namespace host {
+
+InstanceMessageFilter::InstanceMessageFilter(PpapiHost* host) : host_(host) {
+}
+
+InstanceMessageFilter::~InstanceMessageFilter() {
+}
+
+} // namespace host
+} // namespace ppapi
diff --git a/ppapi/host/instance_message_filter.h b/ppapi/host/instance_message_filter.h
new file mode 100644
index 0000000..2b072e9
--- /dev/null
+++ b/ppapi/host/instance_message_filter.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 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.
+
+#ifndef PPAPI_HOST_INSTANCE_MESSAGE_FILTER_H_
+#define PPAPI_HOST_INSTANCE_MESSAGE_FILTER_H_
+
+#include "base/basictypes.h"
+#include "ppapi/host/ppapi_host_export.h"
+
+namespace IPC {
+class Message;
+}
+
+namespace ppapi {
+namespace host {
+
+class PpapiHost;
+
+class PPAPI_HOST_EXPORT InstanceMessageFilter {
+ public:
+ explicit InstanceMessageFilter(PpapiHost* host);
+ virtual ~InstanceMessageFilter();
+
+ // Processes an instance message from the plugin process. Returns true if the
+ // message was handled. On false, the PpapiHost will forward the message to
+ // the next filter.
+ virtual bool OnInstanceMessageReceived(const IPC::Message& msg) = 0;
+
+ PpapiHost* host() { return host_; }
+
+ private:
+ PpapiHost* host_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstanceMessageFilter);
+};
+
+} // namespace host
+} // namespace ppapi
+
+#endif // PPAPI_HOST_INSTANCE_MESSAGE_FILTER_H_
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc
index 6423f1e..87dfb11 100644
--- a/ppapi/host/ppapi_host.cc
+++ b/ppapi/host/ppapi_host.cc
@@ -8,6 +8,7 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/host_factory.h"
#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/instance_message_filter.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/resource_message_params.h"
@@ -33,8 +34,11 @@ PpapiHost::PpapiHost(IPC::Sender* sender,
PpapiHost::~PpapiHost() {
// Delete these explicitly before destruction since then the host is still
- // technically alive in case one of the hosts accesses us from the
+ // technically alive in case one of the filters accesses us from the
// destructor.
+ instance_message_filters_.clear();
+
+ // The resources may also want to use us in their destructors.
resources_.clear();
pending_resource_hosts_.clear();
}
@@ -59,6 +63,15 @@ bool PpapiHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
+ if (!handled) {
+ for (size_t i = 0; i < instance_message_filters_.size(); i++) {
+ if (instance_message_filters_[i]->OnInstanceMessageReceived(msg)) {
+ handled = true;
+ break;
+ }
+ }
+ }
+
return handled;
}
@@ -94,6 +107,11 @@ void PpapiHost::AddHostFactoryFilter(scoped_ptr<HostFactory> filter) {
host_factory_filters_.push_back(filter.release());
}
+void PpapiHost::AddInstanceMessageFilter(
+ scoped_ptr<InstanceMessageFilter> filter) {
+ instance_message_filters_.push_back(filter.release());
+}
+
void PpapiHost::OnHostMsgResourceCall(
const proxy::ResourceMessageCallParams& params,
const IPC::Message& nested_msg) {
diff --git a/ppapi/host/ppapi_host.h b/ppapi/host/ppapi_host.h
index 5e44d1a..c661a9b 100644
--- a/ppapi/host/ppapi_host.h
+++ b/ppapi/host/ppapi_host.h
@@ -30,6 +30,7 @@ namespace host {
class HostFactory;
struct HostMessageContext;
+class InstanceMessageFilter;
struct ReplyMessageContext;
class ResourceHost;
@@ -69,6 +70,10 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener {
// ownership of the pointer.
void AddHostFactoryFilter(scoped_ptr<HostFactory> filter);
+ // Adds the given message filter to the host. The PpapiHost will take
+ // ownership of the pointer.
+ void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter);
+
// Returns null if the resource doesn't exist.
host::ResourceHost* GetResourceHost(PP_Resource resource) const;
@@ -104,6 +109,12 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener {
// an ObserverList.
ScopedVector<HostFactory> host_factory_filters_;
+ // Filters for instance messages. Note that since we don't support deleting
+ // these dynamically we don't need to worry about modifications during
+ // iteration. If we add that capability, this should be replaced with an
+ // ObserverList.
+ ScopedVector<InstanceMessageFilter> instance_message_filters_;
+
typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap;
ResourceMap resources_;