diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 22:15:10 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 22:15:10 +0000 |
commit | 33eccce577eb48d787df7ec5dd0651e87d2eb567 (patch) | |
tree | 6bac12cce99cb325dc2cd9529da83cdce8a99368 /ppapi/proxy/device_enumeration_resource_helper.cc | |
parent | 52ce533c5f826a0e0cbee12fda81ec8952a19563 (diff) | |
download | chromium_src-33eccce577eb48d787df7ec5dd0651e87d2eb567.zip chromium_src-33eccce577eb48d787df7ec5dd0651e87d2eb567.tar.gz chromium_src-33eccce577eb48d787df7ec5dd0651e87d2eb567.tar.bz2 |
Introduce PPB_VideoCapture_Dev v0.3:
- Add MonitorDeviceChange().
- Change EnumerateDevices() to use PP_ArrayOutput.
- Update the video_capture manual test.
TEST=None
BUG=137799
Review URL: https://chromiumcodereview.appspot.com/11437036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172150 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/device_enumeration_resource_helper.cc')
-rw-r--r-- | ppapi/proxy/device_enumeration_resource_helper.cc | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/ppapi/proxy/device_enumeration_resource_helper.cc b/ppapi/proxy/device_enumeration_resource_helper.cc index 2796439..2b51c27 100644 --- a/ppapi/proxy/device_enumeration_resource_helper.cc +++ b/ppapi/proxy/device_enumeration_resource_helper.cc @@ -71,6 +71,21 @@ int32_t DeviceEnumerationResourceHelper::EnumerateDevices( return PP_OK_COMPLETIONPENDING; } +int32_t DeviceEnumerationResourceHelper::EnumerateDevicesSync( + const PP_ArrayOutput& output) { + std::vector<DeviceRefData> devices; + int32_t result = + owner_->SyncCall<PpapiPluginMsg_DeviceEnumeration_EnumerateDevicesReply>( + PluginResource::RENDERER, + PpapiHostMsg_DeviceEnumeration_EnumerateDevices(), + &devices); + + if (result == PP_OK) + result = WriteToArrayOutput(devices, output); + + return result; +} + int32_t DeviceEnumerationResourceHelper::MonitorDeviceChange( PP_MonitorDeviceChangeCallback callback, void* user_data) { @@ -148,22 +163,10 @@ void DeviceEnumerationResourceHelper::OnPluginMsgEnumerateDevicesReply( return; int32_t result = params.result(); - if (result == PP_OK) { - ArrayWriter writer(output); - if (writer.is_valid()) { - std::vector<scoped_refptr<Resource> > device_resources; - for (size_t i = 0; i < devices.size(); ++i) { - device_resources.push_back(new PPB_DeviceRef_Shared( - OBJECT_IS_PROXY, owner_->pp_instance(), devices[i])); - } - if (!writer.StoreResourceVector(device_resources)) - result = PP_ERROR_FAILED; - } else { - result = PP_ERROR_BADARGUMENT; - } - } + if (result == PP_OK) + result = WriteToArrayOutput(devices, output); - callback->Run(params.result()); + callback->Run(result); } void DeviceEnumerationResourceHelper::OnPluginMsgNotifyDeviceChange( @@ -196,5 +199,23 @@ void DeviceEnumerationResourceHelper::OnPluginMsgNotifyDeviceChange( PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(elements[index]); } +int32_t DeviceEnumerationResourceHelper::WriteToArrayOutput( + const std::vector<DeviceRefData>& devices, + const PP_ArrayOutput& output) { + ArrayWriter writer(output); + if (!writer.is_valid()) + return PP_ERROR_BADARGUMENT; + + std::vector<scoped_refptr<Resource> > device_resources; + for (size_t i = 0; i < devices.size(); ++i) { + device_resources.push_back(new PPB_DeviceRef_Shared( + OBJECT_IS_PROXY, owner_->pp_instance(), devices[i])); + } + if (!writer.StoreResourceVector(device_resources)) + return PP_ERROR_FAILED; + + return PP_OK; +} + } // namespace proxy } // namespace ppapi |