| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_HOST_RESOURCE_MESSAGE_FILTER_H_ | 5 #ifndef PPAPI_HOST_RESOURCE_MESSAGE_FILTER_H_ |
| 6 #define PPAPI_HOST_RESOURCE_MESSAGE_FILTER_H_ | 6 #define PPAPI_HOST_RESOURCE_MESSAGE_FILTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "ppapi/c/pp_stdint.h" | 9 #include "ppapi/c/pp_stdint.h" |
| 10 #include "ppapi/host/host_message_context.h" | 10 #include "ppapi/host/host_message_context.h" |
| 11 #include "ppapi/host/ppapi_host_export.h" | 11 #include "ppapi/host/ppapi_host_export.h" |
| 12 #include "ppapi/host/resource_message_handler.h" | 12 #include "ppapi/host/resource_message_handler.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class MessageLoopProxy; | 15 class SingleThreadTaskRunner; |
| 16 class TaskRunner; | 16 class TaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace IPC { | 19 namespace IPC { |
| 20 class Message; | 20 class Message; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ppapi { | 23 namespace ppapi { |
| 24 namespace host { | 24 namespace host { |
| 25 | 25 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // This object must be constructed on the same thread that a reply message | 79 // This object must be constructed on the same thread that a reply message |
| 80 // should be sent, i.e. the IO thread when constructed in the browser process | 80 // should be sent, i.e. the IO thread when constructed in the browser process |
| 81 // or the main thread when constructed in the renderer process. Since | 81 // or the main thread when constructed in the renderer process. Since |
| 82 // ResourceMessageFilters are usually constructed in the constructor of the | 82 // ResourceMessageFilters are usually constructed in the constructor of the |
| 83 // owning ResourceHost, this will almost always be the case anyway. | 83 // owning ResourceHost, this will almost always be the case anyway. |
| 84 // The object will be deleted on the creation thread. | 84 // The object will be deleted on the creation thread. |
| 85 ResourceMessageFilter(); | 85 ResourceMessageFilter(); |
| 86 // Test constructor. Allows you to specify the message loop which will be used | 86 // Test constructor. Allows you to specify the message loop which will be used |
| 87 // to dispatch replies on. | 87 // to dispatch replies on. |
| 88 ResourceMessageFilter( | 88 ResourceMessageFilter( |
| 89 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy); | 89 scoped_refptr<base::SingleThreadTaskRunner> reply_thread_task_runner); |
| 90 | 90 |
| 91 // Called when a filter is added to a ResourceHost. | 91 // Called when a filter is added to a ResourceHost. |
| 92 void OnFilterAdded(ResourceHost* resource_host); | 92 void OnFilterAdded(ResourceHost* resource_host); |
| 93 // Called when a filter is removed from a ResourceHost. | 93 // Called when a filter is removed from a ResourceHost. |
| 94 void OnFilterDestroyed(); | 94 void OnFilterDestroyed(); |
| 95 | 95 |
| 96 // This will dispatch the message handler on the target thread. It returns | 96 // This will dispatch the message handler on the target thread. It returns |
| 97 // true if the message was handled by this filter and false otherwise. | 97 // true if the message was handled by this filter and false otherwise. |
| 98 bool HandleMessage(const IPC::Message& msg, | 98 bool HandleMessage(const IPC::Message& msg, |
| 99 HostMessageContext* context) override; | 99 HostMessageContext* context) override; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 private: | 117 private: |
| 118 friend class base::DeleteHelper<ResourceMessageFilter>; | 118 friend class base::DeleteHelper<ResourceMessageFilter>; |
| 119 friend class base::RefCountedThreadSafe< | 119 friend class base::RefCountedThreadSafe< |
| 120 ResourceMessageFilter, internal::ResourceMessageFilterDeleteTraits>; | 120 ResourceMessageFilter, internal::ResourceMessageFilterDeleteTraits>; |
| 121 friend struct internal::ResourceMessageFilterDeleteTraits; | 121 friend struct internal::ResourceMessageFilterDeleteTraits; |
| 122 | 122 |
| 123 // This method is posted to the target thread and runs the message handler. | 123 // This method is posted to the target thread and runs the message handler. |
| 124 void DispatchMessage(const IPC::Message& msg, | 124 void DispatchMessage(const IPC::Message& msg, |
| 125 HostMessageContext context); | 125 HostMessageContext context); |
| 126 | 126 |
| 127 scoped_refptr<base::MessageLoopProxy> deletion_message_loop_proxy_; | 127 scoped_refptr<base::SingleThreadTaskRunner> deletion_task_runner_; |
| 128 | 128 |
| 129 // Message loop to send resource message replies on. This will be the message | 129 // Message loop to send resource message replies on. This will be the message |
| 130 // loop proxy of the IO thread for the browser process or the main thread for | 130 // loop proxy of the IO thread for the browser process or the main thread for |
| 131 // the renderer process. | 131 // the renderer process. |
| 132 scoped_refptr<base::MessageLoopProxy> reply_thread_message_loop_proxy_; | 132 scoped_refptr<base::SingleThreadTaskRunner> reply_thread_task_runner_; |
| 133 | 133 |
| 134 // Non-owning pointer to the resource host owning this filter. Should only be | 134 // Non-owning pointer to the resource host owning this filter. Should only be |
| 135 // accessed from the thread which sends messages to the plugin resource (i.e. | 135 // accessed from the thread which sends messages to the plugin resource (i.e. |
| 136 // the IO thread for the browser process or the main thread for the renderer). | 136 // the IO thread for the browser process or the main thread for the renderer). |
| 137 // This will be NULL upon creation of the filter and is set to the owning | 137 // This will be NULL upon creation of the filter and is set to the owning |
| 138 // ResourceHost when |OnFilterAdded| is called. When the owning ResourceHost | 138 // ResourceHost when |OnFilterAdded| is called. When the owning ResourceHost |
| 139 // is destroyed, |OnFilterDestroyed| is called and this will be set to NULL. | 139 // is destroyed, |OnFilterDestroyed| is called and this will be set to NULL. |
| 140 ResourceHost* resource_host_; | 140 ResourceHost* resource_host_; |
| 141 | 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(ResourceMessageFilter); | 142 DISALLOW_COPY_AND_ASSIGN(ResourceMessageFilter); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 } // namespace host | 145 } // namespace host |
| 146 } // namespace ppapi | 146 } // namespace ppapi |
| 147 | 147 |
| 148 #endif // PPAPI_HOST_RESOURCE_MESSAGE_FILTER_H_ | 148 #endif // PPAPI_HOST_RESOURCE_MESSAGE_FILTER_H_ |
| OLD | NEW |