OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_PROXY_RESOURCE_MESSAGE_FILTER_H_ |
| 6 #define PPAPI_PROXY_RESOURCE_MESSAGE_FILTER_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 10 |
| 11 namespace IPC { |
| 12 class Message; |
| 13 } |
| 14 |
| 15 namespace ppapi { |
| 16 namespace proxy { |
| 17 class ResourceMessageReplyParams; |
| 18 |
| 19 // A ResourceMessageFilter lives on the IO thread and handles messages for a |
| 20 // particular resource type. This is necessary in some cases where we want to |
| 21 // reduce latency by doing some work on the IO thread rather than having to |
| 22 // PostTask to the main Pepper thread. |
| 23 // |
| 24 // Note: In some cases we can rely on a reply being associated with a |
| 25 // particular TrackedCallback, in which case we can dispatch directly to the |
| 26 // TrackedCallback's thread. See ReplyThreadRegistrar. That should be the first |
| 27 // choice for avoiding an unecessary jump to the main-thread. |
| 28 // |
| 29 // ResourceMessageFilter is for cases where there is not a one-to-one |
| 30 // relationship between a reply message and a TrackedCallback. For example, for |
| 31 // UDP Socket resources, the browser pushes data to the plugin even when the |
| 32 // plugin does not have a pending callback. We can't use the |
| 33 // ReplyThreadRegistrar, because data may arrive when there's not yet a |
| 34 // TrackedCallback to tell us what thread to use. So instead, we define a |
| 35 // UDPSocketFilter which accepts and queues UDP data on the IO thread. |
| 36 class PPAPI_PROXY_EXPORT ResourceMessageFilter |
| 37 : public base::RefCountedThreadSafe<ResourceMessageFilter> { |
| 38 public: |
| 39 virtual bool OnResourceReplyReceived( |
| 40 const ResourceMessageReplyParams& reply_params, |
| 41 const IPC::Message& nested_msg) = 0; |
| 42 |
| 43 protected: |
| 44 friend class base::RefCountedThreadSafe<ResourceMessageFilter>; |
| 45 virtual ~ResourceMessageFilter() {} |
| 46 }; |
| 47 |
| 48 } // namespace proxy |
| 49 } // namespace ppapi |
| 50 |
| 51 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_FILTER_H_ |
OLD | NEW |