Chromium Code Reviews| Index: ppapi/host/resource_host_message_filter.h |
| diff --git a/ppapi/host/resource_host.h b/ppapi/host/resource_host_message_filter.h |
| similarity index 51% |
| copy from ppapi/host/resource_host.h |
| copy to ppapi/host/resource_host_message_filter.h |
| index 27d87b366b36b847c96c3f5e94ab917bd570eac6..52b4be4b5b5f1d55303e143d49f8b8fe316eea91 100644 |
| --- a/ppapi/host/resource_host.h |
| +++ b/ppapi/host/resource_host_message_filter.h |
| @@ -2,13 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef PPAPI_HOST_RESOURCE_HOST_H_ |
| -#define PPAPI_HOST_RESOURCE_HOST_H_ |
| +#ifndef PPAPI_HOST_RESOURCE_HOST_MESSAGE_FILTER_H_ |
| +#define PPAPI_HOST_RESOURCE_HOST_MESSAGE_FILTER_H_ |
| #include "base/basictypes.h" |
| -#include "ppapi/c/pp_resource.h" |
| +#include "ppapi/c/pp_stdint.h" |
| #include "ppapi/host/ppapi_host_export.h" |
| -#include "ppapi/shared_impl/host_resource.h" |
| namespace IPC { |
| class Message; |
| @@ -18,19 +17,32 @@ namespace ppapi { |
| namespace host { |
| struct HostMessageContext; |
| -class PpapiHost; |
| +struct ReplyMessageContext; |
| -// Some (but not all) resources have a corresponding object in the host side |
| -// that is kept alive as long as the resource in the plugin is alive. This is |
| -// the base class for such objects. |
| -class PPAPI_HOST_EXPORT ResourceHost { |
| +// This is the base class of classes that can handle resource messages. It |
| +// mainly exists at present to share code for checking replies to resource |
| +// messages are valid. |
| +class PPAPI_HOST_EXPORT ResourceHostMessageFilter { |
|
yzshen1
2012/11/13 21:51:48
[nit; just for discussion] Resource(Host)?MessageH
raymes
2012/11/16 18:56:35
I agree the last names were bad. I like your sugge
|
| public: |
| - ResourceHost(PpapiHost* host, PP_Instance instance, PP_Resource resource); |
| - virtual ~ResourceHost(); |
| + ResourceHostMessageFilter(); |
| + virtual ~ResourceHostMessageFilter(); |
| - PpapiHost* host() { return host_; } |
| - PP_Instance pp_instance() const { return pp_instance_; } |
| - PP_Resource pp_resource() const { return pp_resource_; } |
| + // Called when this filter should handle a particular message. This should |
| + // call into the the message handler implemented by subclasses (i.e. |
| + // |OnResourceMessageReceived|) and perform any additional work necessary to |
| + // handle the message (e.g. checking resource replies are valid). True is |
| + // returned if the message is handled and false otherwise. |
| + virtual bool HandleMessage(const IPC::Message& msg, |
| + HostMessageContext* context) = 0; |
| + |
| + // Send a resource reply message. |
| + virtual void SendReply(const ReplyMessageContext& context, |
| + const IPC::Message& msg) = 0; |
| + |
| + protected: |
| + // Runs the message handler and checks that a reply was sent if necessary. |
| + void RunMessageHandlerAndReply(const IPC::Message& msg, |
| + HostMessageContext* context); |
| // Handles messages associated with a given resource object. If the flags |
| // indicate that a response is required, the return value of this function |
| @@ -53,16 +65,10 @@ class PPAPI_HOST_EXPORT ResourceHost { |
| HostMessageContext* context); |
| private: |
| - // The host that owns this object. |
| - PpapiHost* host_; |
| - |
| - PP_Instance pp_instance_; |
| - PP_Resource pp_resource_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(ResourceHost); |
| + DISALLOW_COPY_AND_ASSIGN(ResourceHostMessageFilter); |
| }; |
| } // namespace host |
| } // namespace ppapi |
| -#endif // PPAPI_HOST_RESOURCE_HOST_H_ |
| +#endif // PPAPI_HOST_RESOURCE_HOST_MESSAGE_FILTER_H_ |