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.
5 #ifndef PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_
6 #define PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_
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"
20 struct PP_ArrayOutput
;
25 class TrackedCallback
;
30 class ResourceMessageReplyParams
;
32 class PPAPI_PROXY_EXPORT DeviceEnumerationResourceHelper
33 : public base::SupportsWeakPtr
<DeviceEnumerationResourceHelper
> {
35 // |owner| must outlive this object.
36 explicit DeviceEnumerationResourceHelper(PluginResource
* owner
);
37 ~DeviceEnumerationResourceHelper();
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 EnumerateDevicesSync(const PP_ArrayOutput
& output
);
44 int32_t MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback
,
47 // Returns true if the message has been handled.
48 bool HandleReply(const ResourceMessageReplyParams
& params
,
49 const IPC::Message
& msg
);
51 void LastPluginRefWasDeleted();
54 void OnPluginMsgEnumerateDevicesReply0_2(
55 PP_Resource
* devices_resource
,
56 scoped_refptr
<TrackedCallback
> callback
,
57 const ResourceMessageReplyParams
& params
,
58 const std::vector
<DeviceRefData
>& devices
);
59 void OnPluginMsgEnumerateDevicesReply(
60 const PP_ArrayOutput
& output
,
61 scoped_refptr
<TrackedCallback
> callback
,
62 const ResourceMessageReplyParams
& params
,
63 const std::vector
<DeviceRefData
>& devices
);
64 void OnPluginMsgNotifyDeviceChange(const ResourceMessageReplyParams
& params
,
66 const std::vector
<DeviceRefData
>& devices
);
68 int32_t WriteToArrayOutput(const std::vector
<DeviceRefData
>& devices
,
69 const PP_ArrayOutput
& output
);
71 // Not owned by this object.
72 PluginResource
* owner_
;
74 bool pending_enumerate_devices_
;
76 uint32_t monitor_callback_id_
;
77 PP_MonitorDeviceChangeCallback monitor_callback_
;
78 void* monitor_user_data_
;
80 DISALLOW_COPY_AND_ASSIGN(DeviceEnumerationResourceHelper
);
86 #endif // PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_