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 CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 public: | 42 public: |
43 class Delegate { | 43 class Delegate { |
44 public: | 44 public: |
45 virtual ~Delegate() {} | 45 virtual ~Delegate() {} |
46 | 46 |
47 using DevicesCallback = base::Callback<void( | 47 using DevicesCallback = base::Callback<void( |
48 const std::vector<ppapi::DeviceRefData>& /* devices */)>; | 48 const std::vector<ppapi::DeviceRefData>& /* devices */)>; |
49 | 49 |
50 // Enumerates devices of the specified type. | 50 // Enumerates devices of the specified type. |
51 virtual void EnumerateDevices(PP_DeviceType_Dev type, | 51 virtual void EnumerateDevices(PP_DeviceType_Dev type, |
52 const GURL& document_url, | |
53 const DevicesCallback& callback) = 0; | 52 const DevicesCallback& callback) = 0; |
54 | 53 |
55 // Starts monitoring devices of the specified |type|. Returns a | 54 // Starts monitoring devices of the specified |type|. Returns a |
56 // subscription ID that must be used to stop monitoring for the device | 55 // subscription ID that must be used to stop monitoring for the device |
57 // |type|. Does not invoke |callback| synchronously. |callback| is invoked | 56 // |type|. Does not invoke |callback| synchronously. |callback| is invoked |
58 // when device changes of the specified |type| occur. | 57 // when device changes of the specified |type| occur. |
59 virtual uint32_t StartMonitoringDevices( | 58 virtual uint32_t StartMonitoringDevices( |
60 PP_DeviceType_Dev type, | 59 PP_DeviceType_Dev type, |
61 const GURL& document_url, | |
62 const DevicesCallback& callback) = 0; | 60 const DevicesCallback& callback) = 0; |
63 | 61 |
64 // Stops monitoring devices of the specified |type|. The | 62 // Stops monitoring devices of the specified |type|. The |
65 // |subscription_id| is the return value of StartMonitoringDevices. | 63 // |subscription_id| is the return value of StartMonitoringDevices. |
66 virtual void StopMonitoringDevices(PP_DeviceType_Dev type, | 64 virtual void StopMonitoringDevices(PP_DeviceType_Dev type, |
67 uint32_t subscription_id) = 0; | 65 uint32_t subscription_id) = 0; |
68 }; | 66 }; |
69 | 67 |
70 // |resource_host| and |delegate| must outlive this object. | 68 // |resource_host| and |delegate| must outlive this object. |
71 PepperDeviceEnumerationHostHelper(ppapi::host::ResourceHost* resource_host, | 69 PepperDeviceEnumerationHostHelper(ppapi::host::ResourceHost* resource_host, |
(...skipping 27 matching lines...) Expand all Loading... |
99 void OnEnumerateDevicesComplete( | 97 void OnEnumerateDevicesComplete( |
100 const std::vector<ppapi::DeviceRefData>& devices); | 98 const std::vector<ppapi::DeviceRefData>& devices); |
101 void OnNotifyDeviceChange(uint32_t callback_id, | 99 void OnNotifyDeviceChange(uint32_t callback_id, |
102 const std::vector<ppapi::DeviceRefData>& devices); | 100 const std::vector<ppapi::DeviceRefData>& devices); |
103 | 101 |
104 // Non-owning pointers. | 102 // Non-owning pointers. |
105 ppapi::host::ResourceHost* resource_host_; | 103 ppapi::host::ResourceHost* resource_host_; |
106 base::WeakPtr<Delegate> delegate_; | 104 base::WeakPtr<Delegate> delegate_; |
107 | 105 |
108 PP_DeviceType_Dev device_type_; | 106 PP_DeviceType_Dev device_type_; |
109 GURL document_url_; | |
110 | 107 |
111 std::unique_ptr<ScopedEnumerationRequest> enumerate_; | 108 std::unique_ptr<ScopedEnumerationRequest> enumerate_; |
112 std::unique_ptr<ScopedMonitoringRequest> monitor_; | 109 std::unique_ptr<ScopedMonitoringRequest> monitor_; |
113 | 110 |
114 ppapi::host::ReplyMessageContext enumerate_devices_context_; | 111 ppapi::host::ReplyMessageContext enumerate_devices_context_; |
115 | 112 |
116 DISALLOW_COPY_AND_ASSIGN(PepperDeviceEnumerationHostHelper); | 113 DISALLOW_COPY_AND_ASSIGN(PepperDeviceEnumerationHostHelper); |
117 }; | 114 }; |
118 | 115 |
119 } // namespace content | 116 } // namespace content |
120 | 117 |
121 #endif // CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_ | 118 #endif // CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_ |
OLD | NEW |