| Index: content/browser/renderer_host/media/video_capture_controller.cc
|
| diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc
|
| index ec20aa05f04d15f662c7042b303989a8dfc64d4c..8e7d3664ac71f4f6c89ca5ea999260f8d0f5157a 100644
|
| --- a/content/browser/renderer_host/media/video_capture_controller.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_controller.cc
|
| @@ -46,6 +46,21 @@ static const int kInfiniteRatio = 99999;
|
| UMA_HISTOGRAM_SPARSE_SLOWLY( \
|
| name, (height) ? ((width)*100) / (height) : kInfiniteRatio);
|
|
|
| +void CallOnError(VideoCaptureControllerEventHandler* client,
|
| + VideoCaptureControllerID id) {
|
| + client->OnError(id);
|
| +}
|
| +
|
| +void CallOnStarted(VideoCaptureControllerEventHandler* client,
|
| + VideoCaptureControllerID id) {
|
| + client->OnStarted(id);
|
| +}
|
| +
|
| +void CallOnStartedUsingGpuDecode(VideoCaptureControllerEventHandler* client,
|
| + VideoCaptureControllerID id) {
|
| + client->OnStartedUsingGpuDecode(id);
|
| +}
|
| +
|
| } // anonymous namespace
|
|
|
| struct VideoCaptureController::ControllerClient {
|
| @@ -448,12 +463,7 @@ void VideoCaptureController::OnBufferRetired(int buffer_id) {
|
| void VideoCaptureController::OnError() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| state_ = VIDEO_CAPTURE_STATE_ERROR;
|
| -
|
| - for (const auto& client : controller_clients_) {
|
| - if (client->session_closed)
|
| - continue;
|
| - client->event_handler->OnError(client->controller_id);
|
| - }
|
| + PerformForClientsWithOpenSession(base::Bind(&CallOnError));
|
| }
|
|
|
| void VideoCaptureController::OnLog(const std::string& message) {
|
| @@ -462,13 +472,11 @@ void VideoCaptureController::OnLog(const std::string& message) {
|
| }
|
|
|
| void VideoCaptureController::OnStarted() {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + PerformForClientsWithOpenSession(base::Bind(&CallOnStarted));
|
| +}
|
|
|
| - for (const auto& client : controller_clients_) {
|
| - if (client->session_closed)
|
| - continue;
|
| - client->event_handler->OnStarted(client->controller_id);
|
| - }
|
| +void VideoCaptureController::OnStartedUsingGpuDecode() {
|
| + PerformForClientsWithOpenSession(base::Bind(&CallOnStartedUsingGpuDecode));
|
| }
|
|
|
| VideoCaptureController::ControllerClient* VideoCaptureController::FindClient(
|
| @@ -543,4 +551,14 @@ void VideoCaptureController::ReleaseBufferContext(
|
| buffer_contexts_.erase(buffer_context_iter);
|
| }
|
|
|
| +void VideoCaptureController::PerformForClientsWithOpenSession(
|
| + EventHandlerAction action) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + for (const auto& client : controller_clients_) {
|
| + if (client->session_closed)
|
| + continue;
|
| + action.Run(client->event_handler, client->controller_id);
|
| + }
|
| +}
|
| +
|
| } // namespace content
|
|
|