Chromium Code Reviews| 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..309d4e1620a424705bec84d9d7665715c0ff484e 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,13 +74,15 @@ 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: |
| // 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. |
| + // The object will be deleted on the creation thread. |
| ResourceMessageFilter(); |
| // Test constructor. Allows you to specify the message loop which will be used |
| // to dispatch replies on. |
| @@ -93,7 +104,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 +112,19 @@ class PPAPI_HOST_EXPORT ResourceMessageFilter |
| const IPC::Message& message); |
| private: |
| + friend class base::DeleteHelper<ResourceMessageFilter>; |
| + friend class base::RefCountedThreadSafe< |
| + ResourceMessageFilter, internal::ResourceMessageFilterDeleteTraits>; |
|
dmichael (off chromium)
2013/11/01 20:30:39
Are these friend decls both still necessary?
yzshen1
2013/11/01 20:43:37
Yeah, unfortunately all of them are necessary. :/
|
| + friend struct internal::ResourceMessageFilterDeleteTraits; |
|
dmichael (off chromium)
2013/11/01 20:30:39
Optional: strictly speaking, you could do the work
yzshen1
2013/11/01 20:43:37
Done. Thanks!
On 2013/11/01 20:30:39, dmichael wr
|
| + |
| // This method is posted to the target thread and runs the message handler. |
| void DispatchMessage(const IPC::Message& msg, |
| HostMessageContext context); |
| + void InternalDestruct() const; |
| + |
| + 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. |