| 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 d72cb3dea7174a2c64f229300efd8ebc70817c54..5957ce9280cadf292ddecff177fae89587605191 100644
|
| --- a/content/browser/renderer_host/media/video_capture_controller.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_controller.cc
|
| @@ -15,7 +15,6 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/metrics/sparse_histogram.h"
|
| -#include "base/stl_util.h"
|
| #include "build/build_config.h"
|
| #include "components/display_compositor/gl_helper.h"
|
| #include "content/browser/renderer_host/media/media_stream_manager.h"
|
| @@ -192,12 +191,12 @@ void VideoCaptureController::AddClient(
|
| if (FindClient(id, event_handler, controller_clients_))
|
| return;
|
|
|
| - ControllerClient* client = new ControllerClient(
|
| + std::unique_ptr<ControllerClient> client = base::MakeUnique<ControllerClient>(
|
| id, event_handler, render_process, session_id, params);
|
| // If we already have gotten frame_info from the device, repeat it to the new
|
| // client.
|
| if (state_ == VIDEO_CAPTURE_STATE_STARTED) {
|
| - controller_clients_.push_back(client);
|
| + controller_clients_.push_back(std::move(client));
|
| return;
|
| }
|
| }
|
| @@ -218,8 +217,10 @@ int VideoCaptureController::RemoveClient(
|
| client->active_buffers.clear();
|
|
|
| int session_id = client->session_id;
|
| - controller_clients_.remove(client);
|
| - delete client;
|
| + controller_clients_.remove_if(
|
| + [client](const std::unique_ptr<ControllerClient>& ptr) {
|
| + return ptr.get() == client;
|
| + });
|
|
|
| return session_id;
|
| }
|
| @@ -265,7 +266,7 @@ int VideoCaptureController::GetClientCount() const {
|
|
|
| bool VideoCaptureController::HasActiveClient() const {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| - for (ControllerClient* client : controller_clients_) {
|
| + for (const auto& client : controller_clients_) {
|
| if (!client->paused)
|
| return true;
|
| }
|
| @@ -274,7 +275,7 @@ bool VideoCaptureController::HasActiveClient() const {
|
|
|
| bool VideoCaptureController::HasPausedClient() const {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| - for (ControllerClient* client : controller_clients_) {
|
| + for (const auto& client : controller_clients_) {
|
| if (client->paused)
|
| return true;
|
| }
|
| @@ -350,8 +351,6 @@ VideoCaptureController::GetVideoCaptureFormat() const {
|
| }
|
|
|
| VideoCaptureController::~VideoCaptureController() {
|
| - base::STLDeleteContainerPointers(controller_clients_.begin(),
|
| - controller_clients_.end());
|
| }
|
|
|
| void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread(
|
| @@ -386,14 +385,14 @@ void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread(
|
| buffer->mapped_size())))
|
| << "VideoFrame does not appear to be backed by Buffer";
|
|
|
| - for (auto* client : controller_clients_) {
|
| + for (const auto& client : controller_clients_) {
|
| if (client->session_closed || client->paused)
|
| continue;
|
|
|
| // On the first use of a buffer on a client, share the memory handles.
|
| const bool is_new_buffer = client->known_buffers.insert(buffer_id).second;
|
| if (is_new_buffer)
|
| - DoNewBufferOnIOThread(client, buffer.get(), frame);
|
| + DoNewBufferOnIOThread(client.get(), buffer.get(), frame);
|
|
|
| client->event_handler->OnBufferReady(client->controller_id, buffer_id,
|
| frame);
|
| @@ -429,7 +428,7 @@ void VideoCaptureController::DoErrorOnIOThread() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| state_ = VIDEO_CAPTURE_STATE_ERROR;
|
|
|
| - for (const auto* client : controller_clients_) {
|
| + for (const auto& client : controller_clients_) {
|
| if (client->session_closed)
|
| continue;
|
| client->event_handler->OnError(client->controller_id);
|
| @@ -445,7 +444,7 @@ void VideoCaptureController::DoBufferDestroyedOnIOThread(
|
| int buffer_id_to_drop) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| - for (auto* client : controller_clients_) {
|
| + for (const auto& client : controller_clients_) {
|
| if (client->session_closed)
|
| continue;
|
|
|
| @@ -496,21 +495,21 @@ VideoCaptureController::ControllerClient* VideoCaptureController::FindClient(
|
| VideoCaptureControllerID id,
|
| VideoCaptureControllerEventHandler* handler,
|
| const ControllerClients& clients) {
|
| - for (auto* client : clients) {
|
| + for (const auto& client : clients) {
|
| if (client->controller_id == id && client->event_handler == handler)
|
| - return client;
|
| + return client.get();
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| VideoCaptureController::ControllerClient* VideoCaptureController::FindClient(
|
| int session_id,
|
| const ControllerClients& clients) {
|
| - for (auto* client : clients) {
|
| + for (const auto& client : clients) {
|
| if (client->session_id == session_id)
|
| - return client;
|
| + return client.get();
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| } // namespace content
|
|
|