| Index: ppapi/host/resource_message_handler.h
|
| diff --git a/ppapi/host/resource_host.h b/ppapi/host/resource_message_handler.h
|
| similarity index 51%
|
| copy from ppapi/host/resource_host.h
|
| copy to ppapi/host/resource_message_handler.h
|
| index 27d87b366b36b847c96c3f5e94ab917bd570eac6..73f7f842aed54dd0b6ffa5dec87747296925ec58 100644
|
| --- a/ppapi/host/resource_host.h
|
| +++ b/ppapi/host/resource_message_handler.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_MESSAGE_HANDLER_H_
|
| +#define PPAPI_HOST_RESOURCE_MESSAGE_HANDLER_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 ResourceMessageHandler {
|
| public:
|
| - ResourceHost(PpapiHost* host, PP_Instance instance, PP_Resource resource);
|
| - virtual ~ResourceHost();
|
| + ResourceMessageHandler();
|
| + virtual ~ResourceMessageHandler();
|
|
|
| - PpapiHost* host() { return host_; }
|
| - PP_Instance pp_instance() const { return pp_instance_; }
|
| - PP_Resource pp_resource() const { return pp_resource_; }
|
| + // Called when this handler 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(ResourceMessageHandler);
|
| };
|
|
|
| } // namespace host
|
| } // namespace ppapi
|
|
|
| -#endif // PPAPI_HOST_RESOURCE_HOST_H_
|
| +#endif // PPAPI_HOST_RESOURCE_MESSAGE_HANDLER_H_
|
|
|