| Index: ppapi/host/resource_message_filter.h
|
| diff --git a/ppapi/host/resource_message_filter.h b/ppapi/host/resource_message_filter.h
|
| index ef00cf7ae22f7ee33430b9cfa48c46ca7f532591..49d0a6ee64c520515dba4bd2ad1bedb34664f598 100644
|
| --- a/ppapi/host/resource_message_filter.h
|
| +++ b/ppapi/host/resource_message_filter.h
|
| @@ -24,6 +24,15 @@ namespace ppapi {
|
| namespace host {
|
|
|
| class ResourceHost;
|
| +class ResourceMessageFilter;
|
| +
|
| +namespace internal {
|
| +
|
| +struct ResourceMessageFilterDeleteTraits {
|
| + static void Destruct(const ResourceMessageFilter* filter);
|
| +};
|
| +
|
| +} // namespace internal
|
|
|
| // This is the base class of resource message filters that can handle resource
|
| // messages on another thread. ResourceHosts can handle most messages
|
| @@ -65,17 +74,27 @@ class ResourceHost;
|
| // AddFilter(make_scoped_refptr(new MyMessageFilter));
|
| class PPAPI_HOST_EXPORT ResourceMessageFilter
|
| : public ResourceMessageHandler,
|
| - public base::RefCountedThreadSafe<ResourceMessageFilter> {
|
| + public base::RefCountedThreadSafe<
|
| + ResourceMessageFilter, internal::ResourceMessageFilterDeleteTraits> {
|
| public:
|
| + enum DeletionThread {
|
| + // This object could be deleted on any thread.
|
| + DELETE_ON_ANY_THREAD,
|
| + // This object should be deleted on the same thread as it was created.
|
| + DELETE_ON_CREATION_THREAD
|
| + };
|
| +
|
| // This object must be constructed on the same thread that a reply message
|
| // should be sent, i.e. the IO thread when constructed in the browser process
|
| // or the main thread when constructed in the renderer process. Since
|
| // ResourceMessageFilters are usually constructed in the constructor of the
|
| // owning ResourceHost, this will almost always be the case anyway.
|
| - ResourceMessageFilter();
|
| + // |deletion_thread| specifies on which thread the object should be deleted.
|
| + explicit ResourceMessageFilter(DeletionThread deletion_thread);
|
| // Test constructor. Allows you to specify the message loop which will be used
|
| // to dispatch replies on.
|
| ResourceMessageFilter(
|
| + DeletionThread deletion_thread,
|
| scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy);
|
|
|
| // Called when a filter is added to a ResourceHost.
|
| @@ -93,7 +112,6 @@ class PPAPI_HOST_EXPORT ResourceMessageFilter
|
| const IPC::Message& msg) OVERRIDE;
|
|
|
| protected:
|
| - friend class base::RefCountedThreadSafe<ResourceMessageFilter>;
|
| virtual ~ResourceMessageFilter();
|
|
|
| // If you want the message to be handled on another thread, return a non-null
|
| @@ -102,10 +120,20 @@ class PPAPI_HOST_EXPORT ResourceMessageFilter
|
| const IPC::Message& message);
|
|
|
| private:
|
| + friend class base::DeleteHelper<ResourceMessageFilter>;
|
| + friend class base::RefCountedThreadSafe<
|
| + ResourceMessageFilter, internal::ResourceMessageFilterDeleteTraits>;
|
| + friend struct internal::ResourceMessageFilterDeleteTraits;
|
| +
|
| // This method is posted to the target thread and runs the message handler.
|
| void DispatchMessage(const IPC::Message& msg,
|
| HostMessageContext context);
|
|
|
| + void InternalDestruct() const;
|
| +
|
| + // Set to NULL if the object can be deleted on any thread.
|
| + scoped_refptr<base::MessageLoopProxy> deletion_message_loop_proxy_;
|
| +
|
| // Message loop to send resource message replies on. This will be the message
|
| // loop proxy of the IO thread for the browser process or the main thread for
|
| // the renderer process.
|
|
|