Commit ef648a2e authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Migrate CompositingModeReporter to the new Mojo types

This CL applies pending_remote to the first argument of
AddCompositionModeWatcher in CompositingModeReport interface.

Bug: 955171
Change-Id: I331573a1245d2ea1348aa4109bdfbc23cd402c58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804698Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#697155}
parent 118dd603
......@@ -17,16 +17,18 @@ void CompositingModeReporterImpl::BindRequest(
void CompositingModeReporterImpl::SetUsingSoftwareCompositing() {
gpu_ = false;
watchers_.ForAllPtrs([](mojom::CompositingModeWatcher* watcher) {
watcher->CompositingModeFallbackToSoftware();
});
for (auto& it : watchers_)
it->CompositingModeFallbackToSoftware();
}
void CompositingModeReporterImpl::AddCompositingModeWatcher(
mojom::CompositingModeWatcherPtr watcher) {
mojo::PendingRemote<mojom::CompositingModeWatcher> watcher) {
mojo::Remote<mojom::CompositingModeWatcher> watcher_remote(
std::move(watcher));
if (!gpu_)
watcher->CompositingModeFallbackToSoftware();
watchers_.AddPtr(std::move(watcher));
watcher_remote->CompositingModeFallbackToSoftware();
watchers_.Add(std::move(watcher_remote));
}
} // namespace viz
......@@ -8,7 +8,8 @@
#include "base/macros.h"
#include "components/viz/service/viz_service_export.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h"
namespace viz {
......@@ -32,12 +33,12 @@ class VIZ_SERVICE_EXPORT CompositingModeReporterImpl
// mojom::CompositingModeReporter implementation.
void AddCompositingModeWatcher(
mojom::CompositingModeWatcherPtr watcher) override;
mojo::PendingRemote<mojom::CompositingModeWatcher> watcher) override;
private:
bool gpu_ = true;
mojo::BindingSet<mojom::CompositingModeReporter> bindings_;
mojo::InterfacePtrSet<mojom::CompositingModeWatcher> watchers_;
mojo::RemoteSet<mojom::CompositingModeWatcher> watchers_;
};
} // namespace viz
......
......@@ -678,8 +678,7 @@ RenderThreadImpl::RenderThreadImpl(
.Build()),
main_thread_scheduler_(std::move(scheduler)),
categorized_worker_pool_(new CategorizedWorkerPool()),
client_id_(1),
compositing_mode_watcher_binding_(this) {
client_id_(1) {
TRACE_EVENT0("startup", "RenderThreadImpl::Create");
Init();
}
......@@ -696,8 +695,7 @@ RenderThreadImpl::RenderThreadImpl(
.Build()),
main_thread_scheduler_(std::move(scheduler)),
categorized_worker_pool_(new CategorizedWorkerPool()),
is_scroll_animator_enabled_(false),
compositing_mode_watcher_binding_(this) {
is_scroll_animator_enabled_(false) {
TRACE_EVENT0("startup", "RenderThreadImpl::Create");
DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kRendererClientId));
......@@ -961,12 +959,8 @@ void RenderThreadImpl::Init() {
if (!is_gpu_compositing_disabled_) {
BindHostReceiver(mojo::MakeRequest(&compositing_mode_reporter_));
// Make |this| a CompositingModeWatcher for the
// |compositing_mode_reporter_|.
viz::mojom::CompositingModeWatcherPtr watcher_ptr;
compositing_mode_watcher_binding_.Bind(mojo::MakeRequest(&watcher_ptr));
compositing_mode_reporter_->AddCompositingModeWatcher(
std::move(watcher_ptr));
compositing_mode_watcher_receiver_.BindNewPipeAndPassRemote());
}
}
......
......@@ -45,10 +45,10 @@
#include "ipc/ipc_sync_channel.h"
#include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.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 "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
#include "net/base/network_change_notifier.h"
......@@ -725,8 +725,8 @@ class CONTENT_EXPORT RenderThreadImpl
viz::mojom::CompositingModeReporterPtr compositing_mode_reporter_;
// The class is a CompositingModeWatcher, which is bound to mojo through
// this member.
mojo::Binding<viz::mojom::CompositingModeWatcher>
compositing_mode_watcher_binding_;
mojo::Receiver<viz::mojom::CompositingModeWatcher>
compositing_mode_watcher_receiver_{this};
base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this};
......
......@@ -12,5 +12,5 @@ interface CompositingModeReporter {
// Adds a watcher to hear when the compositing mode will use software instead of
// gpu. If the compositing mode is software already when the watcher is added, it
// will still be notified.
AddCompositingModeWatcher(CompositingModeWatcher watcher);
AddCompositingModeWatcher(pending_remote<CompositingModeWatcher> watcher);
};
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