Commit d65cb07e authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate references to the viz::mojom::FrameSinkVideoCapturer mojo interface

Convert the remaining bits in both the implementation and clients from
the browser and renderer processes for the FrameSinkVideoCapturer interface,
and adapt unit tests.

Bug: 955171, 978694
Change-Id: I87d6d2758d45f44554a1bd6c88fa0358d0709a0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863091
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708120}
parent 8d7e6d70
......@@ -34,7 +34,7 @@ void ClientFrameSinkVideoCapturer::SetFormat(media::VideoPixelFormat format,
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
format_.emplace(format, color_space);
capturer_->SetFormat(format, color_space);
capturer_remote_->SetFormat(format, color_space);
}
void ClientFrameSinkVideoCapturer::SetMinCapturePeriod(
......@@ -42,7 +42,7 @@ void ClientFrameSinkVideoCapturer::SetMinCapturePeriod(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
min_capture_period_ = min_capture_period;
capturer_->SetMinCapturePeriod(min_capture_period);
capturer_remote_->SetMinCapturePeriod(min_capture_period);
}
void ClientFrameSinkVideoCapturer::SetMinSizeChangePeriod(
......@@ -50,7 +50,7 @@ void ClientFrameSinkVideoCapturer::SetMinSizeChangePeriod(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
min_size_change_period_ = min_period;
capturer_->SetMinSizeChangePeriod(min_period);
capturer_remote_->SetMinSizeChangePeriod(min_period);
}
void ClientFrameSinkVideoCapturer::SetResolutionConstraints(
......@@ -60,15 +60,15 @@ void ClientFrameSinkVideoCapturer::SetResolutionConstraints(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
resolution_constraints_.emplace(min_size, max_size, use_fixed_aspect_ratio);
capturer_->SetResolutionConstraints(min_size, max_size,
use_fixed_aspect_ratio);
capturer_remote_->SetResolutionConstraints(min_size, max_size,
use_fixed_aspect_ratio);
}
void ClientFrameSinkVideoCapturer::SetAutoThrottlingEnabled(bool enabled) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto_throttling_enabled_ = enabled;
capturer_->SetAutoThrottlingEnabled(enabled);
capturer_remote_->SetAutoThrottlingEnabled(enabled);
}
void ClientFrameSinkVideoCapturer::ChangeTarget(
......@@ -76,7 +76,7 @@ void ClientFrameSinkVideoCapturer::ChangeTarget(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
target_ = frame_sink_id;
capturer_->ChangeTarget(frame_sink_id);
capturer_remote_->ChangeTarget(frame_sink_id);
}
void ClientFrameSinkVideoCapturer::Start(
......@@ -93,7 +93,7 @@ void ClientFrameSinkVideoCapturer::Stop() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
is_started_ = false;
capturer_->Stop();
capturer_remote_->Stop();
}
void ClientFrameSinkVideoCapturer::StopAndResetConsumer() {
......@@ -107,7 +107,7 @@ void ClientFrameSinkVideoCapturer::StopAndResetConsumer() {
void ClientFrameSinkVideoCapturer::RequestRefreshFrame() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
capturer_->RequestRefreshFrame();
capturer_remote_->RequestRefreshFrame();
}
std::unique_ptr<ClientFrameSinkVideoCapturer::Overlay>
......@@ -127,8 +127,8 @@ ClientFrameSinkVideoCapturer::CreateOverlay(int32_t stacking_index) {
auto overlay =
std::make_unique<Overlay>(weak_factory_.GetWeakPtr(), stacking_index);
overlays_.push_back(overlay.get());
if (capturer_)
overlays_.back()->EstablishConnection(capturer_.get());
if (capturer_remote_)
overlays_.back()->EstablishConnection(capturer_remote_.get());
return overlay;
}
......@@ -166,27 +166,29 @@ void ClientFrameSinkVideoCapturer::OnStopped() {
void ClientFrameSinkVideoCapturer::EstablishConnection() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
establish_connection_callback_.Run(mojo::MakeRequest(&capturer_));
capturer_.set_connection_error_handler(
capturer_remote_.reset();
establish_connection_callback_.Run(
capturer_remote_.BindNewPipeAndPassReceiver());
capturer_remote_.set_disconnect_handler(
base::BindOnce(&ClientFrameSinkVideoCapturer::OnConnectionError,
base::Unretained(this)));
if (format_)
capturer_->SetFormat(format_->pixel_format, format_->color_space);
capturer_remote_->SetFormat(format_->pixel_format, format_->color_space);
if (min_capture_period_)
capturer_->SetMinCapturePeriod(*min_capture_period_);
capturer_remote_->SetMinCapturePeriod(*min_capture_period_);
if (min_size_change_period_)
capturer_->SetMinSizeChangePeriod(*min_size_change_period_);
capturer_remote_->SetMinSizeChangePeriod(*min_size_change_period_);
if (resolution_constraints_) {
capturer_->SetResolutionConstraints(
capturer_remote_->SetResolutionConstraints(
resolution_constraints_->min_size, resolution_constraints_->max_size,
resolution_constraints_->use_fixed_aspect_ratio);
}
if (auto_throttling_enabled_)
capturer_->SetAutoThrottlingEnabled(*auto_throttling_enabled_);
capturer_remote_->SetAutoThrottlingEnabled(*auto_throttling_enabled_);
if (target_)
capturer_->ChangeTarget(target_);
capturer_remote_->ChangeTarget(target_);
for (Overlay* overlay : overlays_)
overlay->EstablishConnection(capturer_.get());
overlay->EstablishConnection(capturer_remote_.get());
if (is_started_)
StartInternal();
}
......@@ -204,7 +206,7 @@ void ClientFrameSinkVideoCapturer::OnConnectionError() {
void ClientFrameSinkVideoCapturer::StartInternal() {
if (consumer_receiver_.is_bound())
consumer_receiver_.reset();
capturer_->Start(consumer_receiver_.BindNewPipeAndPassRemote());
capturer_remote_->Start(consumer_receiver_.BindNewPipeAndPassRemote());
}
void ClientFrameSinkVideoCapturer::OnOverlayDestroyed(Overlay* overlay) {
......
......@@ -13,7 +13,9 @@
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/host/viz_host_export.h"
#include "media/base/video_types.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/viz/privileged/mojom/compositing/frame_sink_video_capture.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/rect_f.h"
......@@ -64,8 +66,8 @@ class VIZ_HOST_EXPORT ClientFrameSinkVideoCapturer
DISALLOW_COPY_AND_ASSIGN(Overlay);
};
using EstablishConnectionCallback =
base::RepeatingCallback<void(mojom::FrameSinkVideoCapturerRequest)>;
using EstablishConnectionCallback = base::RepeatingCallback<void(
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer>)>;
explicit ClientFrameSinkVideoCapturer(EstablishConnectionCallback callback);
~ClientFrameSinkVideoCapturer() override;
......@@ -152,7 +154,7 @@ class VIZ_HOST_EXPORT ClientFrameSinkVideoCapturer
mojom::FrameSinkVideoConsumer* consumer_ = nullptr;
EstablishConnectionCallback establish_connection_callback_;
mojom::FrameSinkVideoCapturerPtr capturer_;
mojo::Remote<mojom::FrameSinkVideoCapturer> capturer_remote_;
mojo::Receiver<mojom::FrameSinkVideoConsumer> consumer_receiver_{this};
base::WeakPtrFactory<ClientFrameSinkVideoCapturer> weak_factory_{this};
......
......@@ -282,16 +282,16 @@ void HostFrameSinkManager::AddVideoDetectorObserver(
}
void HostFrameSinkManager::CreateVideoCapturer(
mojom::FrameSinkVideoCapturerRequest request) {
frame_sink_manager_->CreateVideoCapturer(std::move(request));
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver) {
frame_sink_manager_->CreateVideoCapturer(std::move(receiver));
}
std::unique_ptr<ClientFrameSinkVideoCapturer>
HostFrameSinkManager::CreateVideoCapturer() {
return std::make_unique<ClientFrameSinkVideoCapturer>(base::BindRepeating(
[](base::WeakPtr<HostFrameSinkManager> self,
mojom::FrameSinkVideoCapturerRequest request) {
self->CreateVideoCapturer(std::move(request));
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver) {
self->CreateVideoCapturer(std::move(receiver));
},
weak_ptr_factory_.GetWeakPtr()));
}
......
......@@ -164,7 +164,8 @@ class VIZ_HOST_EXPORT HostFrameSinkManager
void AddVideoDetectorObserver(mojom::VideoDetectorObserverPtr observer);
// Creates a FrameSinkVideoCapturer instance in viz.
void CreateVideoCapturer(mojom::FrameSinkVideoCapturerRequest request);
void CreateVideoCapturer(
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver);
// Creates a FrameSinkVideoCapturer instance in viz and returns a
// ClientFrameSinkVideoCapturer that's connected to it. Clients should prefer
......
......@@ -278,9 +278,9 @@ void FrameSinkManagerImpl::AddVideoDetectorObserver(
}
void FrameSinkManagerImpl::CreateVideoCapturer(
mojom::FrameSinkVideoCapturerRequest request) {
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver) {
video_capturers_.emplace(std::make_unique<FrameSinkVideoCapturerImpl>(
this, std::move(request),
this, std::move(receiver),
std::make_unique<media::VideoCaptureOracle>(
true /* enable_auto_throttling */)));
}
......
......@@ -124,7 +124,7 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
void AddVideoDetectorObserver(
mojom::VideoDetectorObserverPtr observer) override;
void CreateVideoCapturer(
mojom::FrameSinkVideoCapturerRequest request) override;
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver) override;
void EvictSurfaces(const std::vector<SurfaceId>& surface_ids) override;
void RequestCopyOfOutput(const SurfaceId& surface_id,
std::unique_ptr<CopyOutputRequest> request) override;
......
......@@ -62,10 +62,9 @@ constexpr gfx::ColorSpace FrameSinkVideoCapturerImpl::kDefaultColorSpace;
FrameSinkVideoCapturerImpl::FrameSinkVideoCapturerImpl(
FrameSinkVideoCapturerManager* frame_sink_manager,
mojom::FrameSinkVideoCapturerRequest request,
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver,
std::unique_ptr<media::VideoCaptureOracle> oracle)
: frame_sink_manager_(frame_sink_manager),
binding_(this),
copy_request_source_(base::UnguessableToken::Create()),
clock_(base::DefaultTickClock::GetInstance()),
oracle_(std::move(oracle)),
......@@ -77,9 +76,9 @@ FrameSinkVideoCapturerImpl::FrameSinkVideoCapturerImpl(
// Instantiate a default base::OneShotTimer instance.
refresh_frame_retry_timer_.emplace();
if (request.is_pending()) {
binding_.Bind(std::move(request));
binding_.set_connection_error_handler(
if (receiver.is_valid()) {
receiver_.Bind(std::move(receiver));
receiver_.set_disconnect_handler(
base::BindOnce(&FrameSinkVideoCapturerManager::OnCapturerConnectionLost,
base::Unretained(frame_sink_manager_), this));
}
......
......@@ -29,8 +29,9 @@
#include "components/viz/service/viz_service_export.h"
#include "media/base/video_frame.h"
#include "media/capture/content/video_capture_oracle.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/viz/privileged/mojom/compositing/frame_sink_video_capture.mojom.h"
#include "ui/gfx/geometry/rect.h"
......@@ -73,11 +74,12 @@ class VIZ_SERVICE_EXPORT FrameSinkVideoCapturerImpl final
public mojom::FrameSinkVideoCapturer {
public:
// |frame_sink_manager| must outlive this instance. Binds this instance to the
// Mojo message pipe endpoint in |request|, but |request| may be empty for
// Mojo message pipe endpoint in |receiver|, but |receiver| may be empty for
// unit testing.
FrameSinkVideoCapturerImpl(FrameSinkVideoCapturerManager* frame_sink_manager,
mojom::FrameSinkVideoCapturerRequest request,
std::unique_ptr<media::VideoCaptureOracle> oracle);
FrameSinkVideoCapturerImpl(
FrameSinkVideoCapturerManager* frame_sink_manager,
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver,
std::unique_ptr<media::VideoCaptureOracle> oracle);
~FrameSinkVideoCapturerImpl() final;
......@@ -228,8 +230,8 @@ class VIZ_SERVICE_EXPORT FrameSinkVideoCapturerImpl final
// Owner/Manager of this instance.
FrameSinkVideoCapturerManager* const frame_sink_manager_;
// Mojo binding for this instance.
mojo::Binding<mojom::FrameSinkVideoCapturer> binding_;
// Mojo receiver for this instance.
mojo::Receiver<mojom::FrameSinkVideoCapturer> receiver_{this};
// Represents this instance as an issuer of CopyOutputRequests. The Surface
// uses this to auto-cancel stale requests (i.e., prior requests that did not
......
......@@ -22,6 +22,7 @@
#include "media/base/limits.h"
#include "media/base/video_util.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/viz/privileged/mojom/compositing/frame_sink_video_capture.mojom.h"
......@@ -378,8 +379,7 @@ class FrameSinkVideoCapturerTest : public testing::Test {
true /* enable_auto_throttling */);
oracle_ = oracle.get();
capturer_ = std::make_unique<FrameSinkVideoCapturerImpl>(
&frame_sink_manager_, mojom::FrameSinkVideoCapturerRequest(),
std::move(oracle));
&frame_sink_manager_, mojo::NullReceiver(), std::move(oracle));
}
void SetUp() override {
......
......@@ -50,7 +50,7 @@ class TestFrameSinkManagerImpl : public mojom::FrameSinkManager {
void AddVideoDetectorObserver(
mojom::VideoDetectorObserverPtr observer) override {}
void CreateVideoCapturer(
mojom::FrameSinkVideoCapturerRequest request) override {}
mojo::PendingReceiver<mojom::FrameSinkVideoCapturer> receiver) override {}
void EvictSurfaces(const std::vector<SurfaceId>& surface_ids) override {}
void RequestCopyOfOutput(
const SurfaceId& surface_id,
......
......@@ -42,9 +42,10 @@ class MockFrameSinkVideoCapturer : public viz::mojom::FrameSinkVideoCapturer {
bool is_bound() const { return receiver_.is_bound(); }
void Bind(viz::mojom::FrameSinkVideoCapturerRequest request) {
void Bind(
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver) {
DCHECK(!receiver_.is_bound());
receiver_.Bind(std::move(request));
receiver_.Bind(std::move(receiver));
}
void Reset() {
......@@ -237,9 +238,8 @@ class DevToolsVideoConsumerTest : public testing::Test {
return std::make_unique<viz::ClientFrameSinkVideoCapturer>(
base::BindRepeating(
[](base::WeakPtr<DevToolsVideoConsumerTest> self,
viz::mojom::FrameSinkVideoCapturerRequest request) {
self->capturer_.Bind(std::move(request));
},
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer>
receiver) { self->capturer_.Bind(std::move(receiver)); },
weak_factory_.GetWeakPtr()));
}
......
......@@ -19,7 +19,8 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h"
#include "media/base/bind_to_current_loop.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_occlusion_tracker.h"
......@@ -157,12 +158,13 @@ AuraWindowVideoCaptureDevice::~AuraWindowVideoCaptureDevice() = default;
#if defined(OS_CHROMEOS)
void AuraWindowVideoCaptureDevice::CreateCapturer(
viz::mojom::FrameSinkVideoCapturerRequest request) {
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver) {
base::PostTask(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
[](base::WeakPtr<WindowTracker> tracker_ptr,
viz::mojom::FrameSinkVideoCapturerRequest request) {
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer>
receiver) {
WindowTracker* const tracker = tracker_ptr.get();
if (!tracker) {
// WindowTracker was destroyed in the meantime, due to early
......@@ -173,17 +175,17 @@ void AuraWindowVideoCaptureDevice::CreateCapturer(
if (tracker->target_type() == DesktopMediaID::TYPE_WINDOW) {
VLOG(1) << "AuraWindowVideoCaptureDevice is using the LAME "
"capturer. :(";
mojo::StrongBinding<viz::mojom::FrameSinkVideoCapturer>::Create(
mojo::MakeSelfOwnedReceiver(
std::make_unique<LameWindowCapturerChromeOS>(
tracker->target_window()),
std::move(request));
std::move(receiver));
} else {
VLOG(1) << "AuraWindowVideoCaptureDevice is using the frame "
"sink capturer. :)";
CreateCapturerViaGlobalManager(std::move(request));
CreateCapturerViaGlobalManager(std::move(receiver));
}
},
tracker_->AsWeakPtr(), std::move(request)));
tracker_->AsWeakPtr(), std::move(receiver)));
}
#endif
......
......@@ -13,6 +13,7 @@
#include "content/browser/media/capture/frame_sink_video_capture_device.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace aura {
class Window;
......@@ -37,7 +38,8 @@ class CONTENT_EXPORT AuraWindowVideoCaptureDevice
// LameWindowCapturerChromeOS for window capture where compositor frame sinks
// are not present. See class comments for LameWindowCapturerChromeOS for
// further details.
void CreateCapturer(viz::mojom::FrameSinkVideoCapturerRequest request) final;
void CreateCapturer(
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver) final;
#endif
private:
......
......@@ -297,24 +297,26 @@ void FrameSinkVideoCaptureDevice::WillStart() {}
void FrameSinkVideoCaptureDevice::DidStop() {}
void FrameSinkVideoCaptureDevice::CreateCapturer(
viz::mojom::FrameSinkVideoCapturerRequest request) {
CreateCapturerViaGlobalManager(std::move(request));
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver) {
CreateCapturerViaGlobalManager(std::move(receiver));
}
// static
void FrameSinkVideoCaptureDevice::CreateCapturerViaGlobalManager(
viz::mojom::FrameSinkVideoCapturerRequest request) {
// Send the request to UI thread because that's where HostFrameSinkManager
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver) {
// Send the receiver to UI thread because that's where HostFrameSinkManager
// lives.
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(
[](viz::mojom::FrameSinkVideoCapturerRequest request) {
viz::HostFrameSinkManager* const manager =
GetHostFrameSinkManager();
DCHECK(manager);
manager->CreateVideoCapturer(std::move(request));
},
std::move(request)));
base::PostTask(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
[](mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer>
receiver) {
viz::HostFrameSinkManager* const manager =
GetHostFrameSinkManager();
DCHECK(manager);
manager->CreateVideoCapturer(std::move(receiver));
},
std::move(receiver)));
}
void FrameSinkVideoCaptureDevice::MaybeStartConsuming() {
......
......@@ -22,6 +22,7 @@
#include "media/capture/video/video_capture_device.h"
#include "media/capture/video/video_frame_receiver.h"
#include "media/capture/video_capture_types.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
......@@ -101,12 +102,12 @@ class CONTENT_EXPORT FrameSinkVideoCaptureDevice
// implementation calls CreateCapturerViaGlobalManager(), but subclasses
// and/or tests may provide alternatives.
virtual void CreateCapturer(
viz::mojom::FrameSinkVideoCapturerRequest request);
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver);
// Establishes connection to FrameSinkVideoCapturer using the global
// viz::HostFrameSinkManager.
static void CreateCapturerViaGlobalManager(
viz::mojom::FrameSinkVideoCapturerRequest request);
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver);
private:
using BufferId = decltype(media::VideoCaptureDevice::Client::Buffer::id);
......
......@@ -19,7 +19,6 @@
#include "media/capture/video/video_frame_receiver.h"
#include "media/capture/video_capture_types.h"
#include "mojo/public/cpp/base/shared_memory_utils.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
......@@ -83,13 +82,14 @@ media::VideoCaptureParams GetCaptureParams() {
// Mock for the FrameSinkVideoCapturer running in the VIZ process.
class MockFrameSinkVideoCapturer : public viz::mojom::FrameSinkVideoCapturer {
public:
MockFrameSinkVideoCapturer() : binding_(this) {}
MockFrameSinkVideoCapturer() = default;
bool is_bound() const { return binding_.is_bound(); }
bool is_bound() const { return receiver_.is_bound(); }
void Bind(viz::mojom::FrameSinkVideoCapturerRequest request) {
void Bind(
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> receiver) {
DCHECK_NOT_ON_DEVICE_THREAD();
binding_.Bind(std::move(request));
receiver_.Bind(std::move(receiver));
}
MOCK_METHOD2(SetFormat,
......@@ -129,7 +129,7 @@ class MockFrameSinkVideoCapturer : public viz::mojom::FrameSinkVideoCapturer {
receiver));
private:
mojo::Binding<viz::mojom::FrameSinkVideoCapturer> binding_;
mojo::Receiver<viz::mojom::FrameSinkVideoCapturer> receiver_{this};
mojo::Remote<viz::mojom::FrameSinkVideoConsumer> consumer_;
};
......@@ -272,14 +272,15 @@ class FrameSinkVideoCaptureDeviceForTest : public FrameSinkVideoCaptureDevice {
: capturer_(capturer) {}
protected:
void CreateCapturer(viz::mojom::FrameSinkVideoCapturerRequest request) final {
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(
[](MockFrameSinkVideoCapturer* capturer,
viz::mojom::FrameSinkVideoCapturerRequest request) {
capturer->Bind(std::move(request));
},
capturer_, std::move(request)));
void CreateCapturer(mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer>
receiver) final {
base::PostTask(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(
[](MockFrameSinkVideoCapturer* capturer,
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer>
receiver) { capturer->Bind(std::move(receiver)); },
capturer_, std::move(receiver)));
}
MockFrameSinkVideoCapturer* const capturer_;
......
......@@ -122,7 +122,7 @@ interface FrameSinkManager {
AddVideoDetectorObserver(VideoDetectorObserver observer);
// Creates a FrameSinkVideoCapturer instance.
CreateVideoCapturer(FrameSinkVideoCapturer& request);
CreateVideoCapturer(pending_receiver<FrameSinkVideoCapturer> receiver);
// Marks the given SurfaceIds for destruction.
EvictSurfaces(array<SurfaceId> surface_ids);
......
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