| 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 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" | 5 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 8 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return PP_DEVICETYPE_DEV_INVALID; | 120 return PP_DEVICETYPE_DEV_INVALID; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 void PepperDeviceEnumerationEventHandler::NotifyDevicesEnumerated( | 124 void PepperDeviceEnumerationEventHandler::NotifyDevicesEnumerated( |
| 125 int request_id, | 125 int request_id, |
| 126 bool succeeded, | 126 bool succeeded, |
| 127 const media_stream::StreamDeviceInfoArray& device_array) { | 127 const media_stream::StreamDeviceInfoArray& device_array) { |
| 128 EnumerateCallbackMap::iterator iter = enumerate_callbacks_.find(request_id); | 128 EnumerateCallbackMap::iterator iter = enumerate_callbacks_.find(request_id); |
| 129 if (iter == enumerate_callbacks_.end()) { | 129 if (iter == enumerate_callbacks_.end()) { |
| 130 NOTREACHED(); | 130 // This might be enumerated result sent before StopEnumerateDevices is |
| 131 // called since EnumerateDevices is persistent request. |
| 131 return; | 132 return; |
| 132 } | 133 } |
| 133 | 134 |
| 134 webkit::ppapi::PluginDelegate::EnumerateDevicesCallback callback = | 135 webkit::ppapi::PluginDelegate::EnumerateDevicesCallback callback = |
| 135 iter->second; | 136 iter->second; |
| 136 enumerate_callbacks_.erase(iter); | 137 enumerate_callbacks_.erase(iter); |
| 137 | 138 |
| 138 std::vector<ppapi::DeviceRefData> devices; | 139 std::vector<ppapi::DeviceRefData> devices; |
| 139 if (succeeded) { | 140 if (succeeded) { |
| 140 devices.reserve(device_array.size()); | 141 devices.reserve(device_array.size()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 156 return; | 157 return; |
| 157 } | 158 } |
| 158 | 159 |
| 159 PepperPluginDelegateImpl::OpenDeviceCallback callback = iter->second; | 160 PepperPluginDelegateImpl::OpenDeviceCallback callback = iter->second; |
| 160 open_callbacks_.erase(iter); | 161 open_callbacks_.erase(iter); |
| 161 | 162 |
| 162 callback.Run(request_id, succeeded, label); | 163 callback.Run(request_id, succeeded, label); |
| 163 } | 164 } |
| 164 | 165 |
| 165 } // namespace content | 166 } // namespace content |
| OLD | NEW |