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 267d85a40753dac7b501a7463a01ab26367e391c..557828cb9ce3ec0ffce046f9c106593f5a54b62b 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 { |
@@ -451,12 +466,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) { |
@@ -467,12 +477,11 @@ void VideoCaptureController::OnLog(const std::string& message) { |
void VideoCaptureController::OnStarted() { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
state_ = VIDEO_CAPTURE_STATE_STARTED; |
+ 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( |
@@ -547,4 +556,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 |