Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2940)

Unified Diff: services/video_capture/video_capture_service.cc

Issue 2244763002: Video Capture Mojo (1.4a.a): Add service configurator interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MakeService
Patch Set: mcasas' comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/video_capture/video_capture_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/video_capture/video_capture_service.cc
diff --git a/services/video_capture/video_capture_service.cc b/services/video_capture/video_capture_service.cc
index e025b6b4903cf177e072c8f99e100bba4d06b9ac..f5ad5e6aa0787bf2d3aea2be6634ca4e8261db55 100644
--- a/services/video_capture/video_capture_service.cc
+++ b/services/video_capture/video_capture_service.cc
@@ -4,6 +4,14 @@
#include "services/video_capture/video_capture_service.h"
+#include "services/video_capture/video_capture_device_factory_impl.h"
+
+namespace {
+static const char kFakeDeviceDisplayName[] = "Fake Video Capture Device";
+static const char kFakeDeviceId[] = "FakeDeviceId";
+static const char kFakeModelId[] = "FakeModelId";
+}
+
namespace video_capture {
VideoCaptureService::VideoCaptureService() = default;
@@ -12,14 +20,47 @@ VideoCaptureService::~VideoCaptureService() = default;
bool VideoCaptureService::OnConnect(const shell::Identity& remote_identity,
shell::InterfaceRegistry* registry) {
- registry->AddInterface<mojom::VideoCaptureDeviceFactory>(this);
+ registry->AddInterface<mojom::VideoCaptureService>(this);
return true;
}
-void VideoCaptureService::Create(
- const shell::Identity& remote_identity,
+void VideoCaptureService::Create(const shell::Identity& remote_identity,
+ mojom::VideoCaptureServiceRequest request) {
+ bindings_.AddBinding(this, std::move(request));
+}
+
+void VideoCaptureService::ConnectToDeviceFactory(
+ mojom::VideoCaptureDeviceFactoryRequest request) {
+ LazyInitializeDeviceFactory();
+ factory_bindings_.AddBinding(device_factory_.get(), std::move(request));
+}
+
+void VideoCaptureService::ConnectToFakeDeviceFactory(
mojom::VideoCaptureDeviceFactoryRequest request) {
- bindings_.AddBinding(&device_factory_, std::move(request));
+ LazyInitializeFakeDeviceFactory();
+ fake_factory_bindings_.AddBinding(fake_device_factory_.get(),
+ std::move(request));
+}
+
+void VideoCaptureService::LazyInitializeDeviceFactory() {
+ if (device_factory_)
+ return;
+ device_factory_ = base::MakeUnique<VideoCaptureDeviceFactoryImpl>();
+}
+
+void VideoCaptureService::LazyInitializeFakeDeviceFactory() {
+ if (fake_device_factory_)
+ return;
+ fake_device_factory_ = base::MakeUnique<VideoCaptureDeviceFactoryImpl>();
+ auto fake_device_descriptor = mojom::VideoCaptureDeviceDescriptor::New();
+ fake_device_descriptor->display_name = kFakeDeviceDisplayName;
+ fake_device_descriptor->device_id = kFakeDeviceId;
+ fake_device_descriptor->model_id = kFakeModelId;
+ fake_device_descriptor->capture_api = mojom::VideoCaptureApi::UNKNOWN;
+ fake_device_descriptor->transport_type =
+ mojom::VideoCaptureTransportType::OTHER_TRANSPORT;
+ fake_device_factory_->AddDevice(std::move(fake_device_descriptor),
+ base::MakeUnique<VideoCaptureDeviceImpl>());
}
} // namespace video_capture
« no previous file with comments | « services/video_capture/video_capture_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698