summaryrefslogtreecommitdiffstats
path: root/ppapi/host
diff options
context:
space:
mode:
authorraymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 01:53:57 +0000
committerraymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 01:53:57 +0000
commitb9ce9dd6dc531ffd20714610f18ad2e8766f1ff7 (patch)
tree22f09c1be4e3ca9a1fc8c330dfdca709a5ba6fd0 /ppapi/host
parentddc6d877066d01a136e1b40c86865760d8cf414a (diff)
downloadchromium_src-b9ce9dd6dc531ffd20714610f18ad2e8766f1ff7.zip
chromium_src-b9ce9dd6dc531ffd20714610f18ad2e8766f1ff7.tar.gz
chromium_src-b9ce9dd6dc531ffd20714610f18ad2e8766f1ff7.tar.bz2
Introduce MessageFilterHost for Pepper ResourceHosts.
This introduces a MessageFilterHost which is a generic Pepper ResourceHost which can be used when all the ResourceHost does is forward messages to a message filter. It seems good to keep the logic for handling resource messages on a background thread separate in the ResourceMessageFilter class. However, currently when writing a ResourceHost that uses a ResourceMessageFilter, the host ends up being empty. Also, we've been putting the code for the host and the message filter in the same file which is bad for code readability. MessageFilterHost can be used as a generic host in this case such that only the ResourceMessageFilter needs to be written. This reduces the amount of boilerplate needed in cases like this. BUG= Review URL: https://codereview.chromium.org/11601004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/host')
-rw-r--r--ppapi/host/message_filter_host.cc26
-rw-r--r--ppapi/host/message_filter_host.h38
2 files changed, 64 insertions, 0 deletions
diff --git a/ppapi/host/message_filter_host.cc b/ppapi/host/message_filter_host.cc
new file mode 100644
index 0000000..78ebd23
--- /dev/null
+++ b/ppapi/host/message_filter_host.cc
@@ -0,0 +1,26 @@
+// 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/message_filter_host.h"
+
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_message_filter.h"
+
+namespace ppapi {
+namespace host {
+
+MessageFilterHost::MessageFilterHost(
+ PpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource,
+ const scoped_refptr<ResourceMessageFilter>& message_filter)
+ : ResourceHost(host, instance, resource) {
+ AddFilter(message_filter);
+}
+
+MessageFilterHost::~MessageFilterHost() {
+}
+
+} // namespace host
+} // namespace ppapi \ No newline at end of file
diff --git a/ppapi/host/message_filter_host.h b/ppapi/host/message_filter_host.h
new file mode 100644
index 0000000..9aa1c5b
--- /dev/null
+++ b/ppapi/host/message_filter_host.h
@@ -0,0 +1,38 @@
+// 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_MESSAGE_FILTER_HOST_H_
+#define PPAPI_HOST_MESSAGE_FILTER_HOST_H_
+
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "ppapi/host/ppapi_host_export.h"
+#include "ppapi/host/resource_host.h"
+
+namespace ppapi {
+namespace host {
+
+class PpapiHost;
+class ResourceMessageFilter;
+
+// This class is a generic ResourceHost that is composed of a single
+// ResourceMessageFilter. There are cases where ResourceHosts only serve the
+// purpose of passing messages onto a message filter to be handled on another
+// thread. This class can be used as the host in those cases.
+class PPAPI_HOST_EXPORT MessageFilterHost : public ResourceHost {
+ public:
+ MessageFilterHost(PpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource,
+ const scoped_refptr<ResourceMessageFilter>& message_filter);
+ virtual ~MessageFilterHost();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MessageFilterHost);
+};
+
+} // namespace host
+} // namespace ppapi
+
+#endif // PPAPI_HOST_MESSAGE_FILTER_HOST_H_