| 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 // Implementation notes about interactions with VideoCaptureImpl. | 5 // Implementation notes about interactions with VideoCaptureImpl. |
| 6 // | 6 // |
| 7 // How is VideoCaptureImpl used: | 7 // How is VideoCaptureImpl used: |
| 8 // | 8 // |
| 9 // VideoCaptureImpl is an IO thread object while VideoCaptureImplManager | 9 // VideoCaptureImpl is an IO thread object while VideoCaptureImplManager |
| 10 // lives only on the render thread. It is only possible to access an | 10 // lives only on the render thread. It is only possible to access an |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 DCHECK(it != devices_.end()); | 227 DCHECK(it != devices_.end()); |
| 228 DCHECK_GT(it->client_count, 0); | 228 DCHECK_GT(it->client_count, 0); |
| 229 --it->client_count; | 229 --it->client_count; |
| 230 if (it->client_count > 0) | 230 if (it->client_count > 0) |
| 231 return; | 231 return; |
| 232 ChildProcess::current()->io_task_runner()->DeleteSoon(FROM_HERE, | 232 ChildProcess::current()->io_task_runner()->DeleteSoon(FROM_HERE, |
| 233 it->impl.release()); | 233 it->impl.release()); |
| 234 devices_.erase(it); | 234 devices_.erase(it); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void VideoCaptureImplManager::SuspendDevices(bool suspend) { | 237 void VideoCaptureImplManager::SuspendDevices( |
| 238 const StreamDeviceInfoArray& video_device_array, |
| 239 bool suspend) { |
| 238 DCHECK(render_main_task_runner_->BelongsToCurrentThread()); | 240 DCHECK(render_main_task_runner_->BelongsToCurrentThread()); |
| 239 if (is_suspending_all_ == suspend) | 241 if (is_suspending_all_ == suspend) |
| 240 return; | 242 return; |
| 241 is_suspending_all_ = suspend; | 243 is_suspending_all_ = suspend; |
| 242 for (auto& entry : devices_) { | 244 for (const StreamDeviceInfo& device_info : video_device_array) { |
| 243 if (entry.is_individually_suspended) | 245 const media::VideoCaptureSessionId id = device_info.session_id; |
| 246 const auto it = std::find_if( |
| 247 devices_.begin(), devices_.end(), |
| 248 [id](const DeviceEntry& entry) { return entry.session_id == id; }); |
| 249 DCHECK(it != devices_.end()); |
| 250 if (it->is_individually_suspended) |
| 244 continue; // Either: 1) Already suspended; or 2) Should not be resumed. | 251 continue; // Either: 1) Already suspended; or 2) Should not be resumed. |
| 245 ChildProcess::current()->io_task_runner()->PostTask( | 252 ChildProcess::current()->io_task_runner()->PostTask( |
| 246 FROM_HERE, base::Bind(&VideoCaptureImpl::SuspendCapture, | 253 FROM_HERE, base::Bind(&VideoCaptureImpl::SuspendCapture, |
| 247 base::Unretained(entry.impl.get()), suspend)); | 254 base::Unretained(it->impl.get()), suspend)); |
| 248 } | 255 } |
| 249 } | 256 } |
| 250 | 257 |
| 251 } // namespace content | 258 } // namespace content |
| OLD | NEW |