OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_ |
| 6 #define PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "ppapi/c/dev/ppb_device_ref_dev.h" |
| 14 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 15 |
| 16 namespace IPC { |
| 17 class Message; |
| 18 } |
| 19 |
| 20 struct PP_ArrayOutput; |
| 21 |
| 22 namespace ppapi { |
| 23 |
| 24 struct DeviceRefData; |
| 25 class TrackedCallback; |
| 26 |
| 27 namespace proxy { |
| 28 |
| 29 class PluginResource; |
| 30 class ResourceMessageReplyParams; |
| 31 |
| 32 class PPAPI_PROXY_EXPORT DeviceEnumerationResourceHelper |
| 33 : public base::SupportsWeakPtr<DeviceEnumerationResourceHelper> { |
| 34 public: |
| 35 // |owner| must outlive this object. |
| 36 explicit DeviceEnumerationResourceHelper(PluginResource* owner); |
| 37 ~DeviceEnumerationResourceHelper(); |
| 38 |
| 39 int32_t EnumerateDevices0_2(PP_Resource* devices, |
| 40 scoped_refptr<TrackedCallback> callback); |
| 41 int32_t EnumerateDevices(const PP_ArrayOutput& output, |
| 42 scoped_refptr<TrackedCallback> callback); |
| 43 int32_t MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback, |
| 44 void* user_data); |
| 45 |
| 46 // Returns true if the message has been handled. |
| 47 bool HandleReply(const ResourceMessageReplyParams& params, |
| 48 const IPC::Message& msg); |
| 49 |
| 50 void LastPluginRefWasDeleted(); |
| 51 |
| 52 private: |
| 53 void OnPluginMsgEnumerateDevicesReply0_2( |
| 54 PP_Resource* devices_resource, |
| 55 scoped_refptr<TrackedCallback> callback, |
| 56 const ResourceMessageReplyParams& params, |
| 57 const std::vector<DeviceRefData>& devices); |
| 58 void OnPluginMsgEnumerateDevicesReply( |
| 59 const PP_ArrayOutput& output, |
| 60 scoped_refptr<TrackedCallback> callback, |
| 61 const ResourceMessageReplyParams& params, |
| 62 const std::vector<DeviceRefData>& devices); |
| 63 void OnPluginMsgNotifyDeviceChange(const ResourceMessageReplyParams& params, |
| 64 uint32_t callback_id, |
| 65 const std::vector<DeviceRefData>& devices); |
| 66 |
| 67 // Not owned by this object. |
| 68 PluginResource* owner_; |
| 69 |
| 70 bool pending_enumerate_devices_; |
| 71 |
| 72 uint32_t monitor_callback_id_; |
| 73 PP_MonitorDeviceChangeCallback monitor_callback_; |
| 74 void* monitor_user_data_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(DeviceEnumerationResourceHelper); |
| 77 }; |
| 78 |
| 79 } // namespace proxy |
| 80 } // namespace ppapi |
| 81 |
| 82 #endif // PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_ |
OLD | NEW |