Fix iOS build for XCode 4.6.
[chromium-blink-merge.git] / ppapi / proxy / device_enumeration_resource_helper.h
blob6c266eb5d634001039818f599732a1884daf4679
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_
8 #include <vector>
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"
16 namespace IPC {
17 class Message;
20 struct PP_ArrayOutput;
22 namespace ppapi {
24 struct DeviceRefData;
25 class TrackedCallback;
27 namespace proxy {
29 class PluginResource;
30 class ResourceMessageReplyParams;
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();
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,
45 void* user_data);
47 // Returns true if the message has been handled.
48 bool HandleReply(const ResourceMessageReplyParams& params,
49 const IPC::Message& msg);
51 void LastPluginRefWasDeleted();
53 private:
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,
65 uint32_t callback_id,
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);
83 } // namespace proxy
84 } // namespace ppapi
86 #endif // PPAPI_PROXY_DEVICE_ENUMERATION_RESOURCE_HELPER_H_