Commit 23ae5a29 authored by Palak Agarwal's avatar Palak Agarwal Committed by Commit Bot

Refactor code duplication by introducing make_unique at the constructor

stage of media::VideoCaptureBufferPoolImpl

Change-Id: I993f1527729b11a12909bf07a3a1d929289fbf3a
Bug: 781987
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2384035Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Palak Agarwal <agpalak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804162}
parent 7bf06a8e
...@@ -78,7 +78,6 @@ void FakeVideoCaptureDeviceLauncher::LaunchDeviceAsync( ...@@ -78,7 +78,6 @@ void FakeVideoCaptureDeviceLauncher::LaunchDeviceAsync(
auto device = system_->CreateDevice(device_id); auto device = system_->CreateDevice(device_id);
scoped_refptr<media::VideoCaptureBufferPool> buffer_pool( scoped_refptr<media::VideoCaptureBufferPool> buffer_pool(
new media::VideoCaptureBufferPoolImpl( new media::VideoCaptureBufferPoolImpl(
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>(),
media::VideoCaptureBufferType::kSharedMemory, kMaxBufferCount)); media::VideoCaptureBufferType::kSharedMemory, kMaxBufferCount));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
auto device_client = std::make_unique<media::VideoCaptureDeviceClient>( auto device_client = std::make_unique<media::VideoCaptureDeviceClient>(
......
...@@ -248,7 +248,6 @@ InProcessVideoCaptureDeviceLauncher::CreateDeviceClient( ...@@ -248,7 +248,6 @@ InProcessVideoCaptureDeviceLauncher::CreateDeviceClient(
scoped_refptr<media::VideoCaptureBufferPool> buffer_pool = scoped_refptr<media::VideoCaptureBufferPool> buffer_pool =
new media::VideoCaptureBufferPoolImpl( new media::VideoCaptureBufferPoolImpl(
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>(),
requested_buffer_type, buffer_pool_max_buffer_count); requested_buffer_type, buffer_pool_max_buffer_count);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -62,7 +62,6 @@ class VideoCaptureBufferPoolTest ...@@ -62,7 +62,6 @@ class VideoCaptureBufferPoolTest
VideoCaptureBufferPoolTest() VideoCaptureBufferPoolTest()
: expected_dropped_id_(0), : expected_dropped_id_(0),
pool_(new media::VideoCaptureBufferPoolImpl( pool_(new media::VideoCaptureBufferPoolImpl(
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>(),
media::VideoCaptureBufferType::kSharedMemory, media::VideoCaptureBufferType::kSharedMemory,
kTestBufferPoolSize)) {} kTestBufferPoolSize)) {}
......
...@@ -177,7 +177,6 @@ class VideoCaptureControllerTest ...@@ -177,7 +177,6 @@ class VideoCaptureControllerTest
void InitializeNewDeviceClientAndBufferPoolInstances() { void InitializeNewDeviceClientAndBufferPoolInstances() {
buffer_pool_ = new media::VideoCaptureBufferPoolImpl( buffer_pool_ = new media::VideoCaptureBufferPoolImpl(
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>(),
media::VideoCaptureBufferType::kSharedMemory, kPoolSize); media::VideoCaptureBufferType::kSharedMemory, kPoolSize);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
device_client_.reset(new media::VideoCaptureDeviceClient( device_client_.reset(new media::VideoCaptureDeviceClient(
......
...@@ -12,18 +12,19 @@ ...@@ -12,18 +12,19 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "media/capture/video/video_capture_buffer_handle.h" #include "media/capture/video/video_capture_buffer_handle.h"
#include "media/capture/video/video_capture_buffer_tracker.h" #include "media/capture/video/video_capture_buffer_tracker.h"
#include "media/capture/video/video_capture_buffer_tracker_factory_impl.h"
#include "ui/gfx/buffer_format_util.h" #include "ui/gfx/buffer_format_util.h"
namespace media { namespace media {
VideoCaptureBufferPoolImpl::VideoCaptureBufferPoolImpl( VideoCaptureBufferPoolImpl::VideoCaptureBufferPoolImpl(
std::unique_ptr<VideoCaptureBufferTrackerFactory> buffer_tracker_factory,
VideoCaptureBufferType buffer_type, VideoCaptureBufferType buffer_type,
int count) int count)
: buffer_type_(buffer_type), : buffer_type_(buffer_type),
count_(count), count_(count),
next_buffer_id_(0), next_buffer_id_(0),
buffer_tracker_factory_(std::move(buffer_tracker_factory)) { buffer_tracker_factory_(
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>()) {
DCHECK_GT(count, 0); DCHECK_GT(count, 0);
} }
......
...@@ -30,7 +30,6 @@ class CAPTURE_EXPORT VideoCaptureBufferPoolImpl ...@@ -30,7 +30,6 @@ class CAPTURE_EXPORT VideoCaptureBufferPoolImpl
: public VideoCaptureBufferPool { : public VideoCaptureBufferPool {
public: public:
explicit VideoCaptureBufferPoolImpl( explicit VideoCaptureBufferPoolImpl(
std::unique_ptr<VideoCaptureBufferTrackerFactory> buffer_tracker_factory,
VideoCaptureBufferType buffer_type, VideoCaptureBufferType buffer_type,
int count); int count);
......
...@@ -55,7 +55,6 @@ class VideoCaptureDeviceClientTest : public ::testing::Test { ...@@ -55,7 +55,6 @@ class VideoCaptureDeviceClientTest : public ::testing::Test {
VideoCaptureDeviceClientTest() { VideoCaptureDeviceClientTest() {
scoped_refptr<VideoCaptureBufferPoolImpl> buffer_pool( scoped_refptr<VideoCaptureBufferPoolImpl> buffer_pool(
new VideoCaptureBufferPoolImpl( new VideoCaptureBufferPoolImpl(
std::make_unique<VideoCaptureBufferTrackerFactoryImpl>(),
VideoCaptureBufferType::kSharedMemory, 2)); VideoCaptureBufferType::kSharedMemory, 2));
auto controller = std::make_unique<NiceMock<MockVideoFrameReceiver>>(); auto controller = std::make_unique<NiceMock<MockVideoFrameReceiver>>();
receiver_ = controller.get(); receiver_ = controller.get();
......
...@@ -91,11 +91,8 @@ void DeviceMediaToMojoAdapter::Start( ...@@ -91,11 +91,8 @@ void DeviceMediaToMojoAdapter::Start(
} }
// Create a dedicated buffer pool for the device usage session. // Create a dedicated buffer pool for the device usage session.
auto buffer_tracker_factory =
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>();
scoped_refptr<media::VideoCaptureBufferPool> buffer_pool( scoped_refptr<media::VideoCaptureBufferPool> buffer_pool(
new media::VideoCaptureBufferPoolImpl(std::move(buffer_tracker_factory), new media::VideoCaptureBufferPoolImpl(requested_settings.buffer_type,
requested_settings.buffer_type,
max_buffer_pool_buffer_count())); max_buffer_pool_buffer_count()));
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
auto device_client = std::make_unique<media::VideoCaptureDeviceClient>( auto device_client = std::make_unique<media::VideoCaptureDeviceClient>(
......
...@@ -38,7 +38,6 @@ SharedMemoryVirtualDeviceMojoAdapter::SharedMemoryVirtualDeviceMojoAdapter( ...@@ -38,7 +38,6 @@ SharedMemoryVirtualDeviceMojoAdapter::SharedMemoryVirtualDeviceMojoAdapter(
send_buffer_handles_to_producer_as_raw_file_descriptors_( send_buffer_handles_to_producer_as_raw_file_descriptors_(
send_buffer_handles_to_producer_as_raw_file_descriptors), send_buffer_handles_to_producer_as_raw_file_descriptors),
buffer_pool_(new media::VideoCaptureBufferPoolImpl( buffer_pool_(new media::VideoCaptureBufferPoolImpl(
std::make_unique<media::VideoCaptureBufferTrackerFactoryImpl>(),
media::VideoCaptureBufferType::kSharedMemory, media::VideoCaptureBufferType::kSharedMemory,
max_buffer_pool_buffer_count())) {} max_buffer_pool_buffer_count())) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment