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( ...@@ -17,16 +17,18 @@ void CompositingModeReporterImpl::BindRequest(
void CompositingModeReporterImpl::SetUsingSoftwareCompositing() { void CompositingModeReporterImpl::SetUsingSoftwareCompositing() {
gpu_ = false; gpu_ = false;
watchers_.ForAllPtrs([](mojom::CompositingModeWatcher* watcher) { for (auto& it : watchers_)
watcher->CompositingModeFallbackToSoftware(); it->CompositingModeFallbackToSoftware();
});
} }
void CompositingModeReporterImpl::AddCompositingModeWatcher( void CompositingModeReporterImpl::AddCompositingModeWatcher(
mojom::CompositingModeWatcherPtr watcher) { mojo::PendingRemote<mojom::CompositingModeWatcher> watcher) {
mojo::Remote<mojom::CompositingModeWatcher> watcher_remote(
std::move(watcher));
if (!gpu_) if (!gpu_)
watcher->CompositingModeFallbackToSoftware(); watcher_remote->CompositingModeFallbackToSoftware();
watchers_.AddPtr(std::move(watcher));
watchers_.Add(std::move(watcher_remote));
} }
} // namespace viz } // namespace viz
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "components/viz/service/viz_service_export.h" #include "components/viz/service/viz_service_export.h"
#include "mojo/public/cpp/bindings/binding_set.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" #include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h"
namespace viz { namespace viz {
...@@ -32,12 +33,12 @@ class VIZ_SERVICE_EXPORT CompositingModeReporterImpl ...@@ -32,12 +33,12 @@ class VIZ_SERVICE_EXPORT CompositingModeReporterImpl
// mojom::CompositingModeReporter implementation. // mojom::CompositingModeReporter implementation.
void AddCompositingModeWatcher( void AddCompositingModeWatcher(
mojom::CompositingModeWatcherPtr watcher) override; mojo::PendingRemote<mojom::CompositingModeWatcher> watcher) override;
private: private:
bool gpu_ = true; bool gpu_ = true;
mojo::BindingSet<mojom::CompositingModeReporter> bindings_; mojo::BindingSet<mojom::CompositingModeReporter> bindings_;
mojo::InterfacePtrSet<mojom::CompositingModeWatcher> watchers_; mojo::RemoteSet<mojom::CompositingModeWatcher> watchers_;
}; };
} // namespace viz } // namespace viz
......
...@@ -678,8 +678,7 @@ RenderThreadImpl::RenderThreadImpl( ...@@ -678,8 +678,7 @@ RenderThreadImpl::RenderThreadImpl(
.Build()), .Build()),
main_thread_scheduler_(std::move(scheduler)), main_thread_scheduler_(std::move(scheduler)),
categorized_worker_pool_(new CategorizedWorkerPool()), categorized_worker_pool_(new CategorizedWorkerPool()),
client_id_(1), client_id_(1) {
compositing_mode_watcher_binding_(this) {
TRACE_EVENT0("startup", "RenderThreadImpl::Create"); TRACE_EVENT0("startup", "RenderThreadImpl::Create");
Init(); Init();
} }
...@@ -696,8 +695,7 @@ RenderThreadImpl::RenderThreadImpl( ...@@ -696,8 +695,7 @@ RenderThreadImpl::RenderThreadImpl(
.Build()), .Build()),
main_thread_scheduler_(std::move(scheduler)), main_thread_scheduler_(std::move(scheduler)),
categorized_worker_pool_(new CategorizedWorkerPool()), categorized_worker_pool_(new CategorizedWorkerPool()),
is_scroll_animator_enabled_(false), is_scroll_animator_enabled_(false) {
compositing_mode_watcher_binding_(this) {
TRACE_EVENT0("startup", "RenderThreadImpl::Create"); TRACE_EVENT0("startup", "RenderThreadImpl::Create");
DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kRendererClientId)); switches::kRendererClientId));
...@@ -961,12 +959,8 @@ void RenderThreadImpl::Init() { ...@@ -961,12 +959,8 @@ void RenderThreadImpl::Init() {
if (!is_gpu_compositing_disabled_) { if (!is_gpu_compositing_disabled_) {
BindHostReceiver(mojo::MakeRequest(&compositing_mode_reporter_)); 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( compositing_mode_reporter_->AddCompositingModeWatcher(
std::move(watcher_ptr)); compositing_mode_watcher_receiver_.BindNewPipeAndPassRemote());
} }
} }
......
...@@ -45,10 +45,10 @@ ...@@ -45,10 +45,10 @@
#include "ipc/ipc_sync_channel.h" #include "ipc/ipc_sync_channel.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/associated_receiver.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_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.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/remote.h"
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
...@@ -725,8 +725,8 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -725,8 +725,8 @@ class CONTENT_EXPORT RenderThreadImpl
viz::mojom::CompositingModeReporterPtr compositing_mode_reporter_; viz::mojom::CompositingModeReporterPtr compositing_mode_reporter_;
// The class is a CompositingModeWatcher, which is bound to mojo through // The class is a CompositingModeWatcher, which is bound to mojo through
// this member. // this member.
mojo::Binding<viz::mojom::CompositingModeWatcher> mojo::Receiver<viz::mojom::CompositingModeWatcher>
compositing_mode_watcher_binding_; compositing_mode_watcher_receiver_{this};
base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this}; base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this};
......
...@@ -12,5 +12,5 @@ interface CompositingModeReporter { ...@@ -12,5 +12,5 @@ interface CompositingModeReporter {
// Adds a watcher to hear when the compositing mode will use software instead of // 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 // gpu. If the compositing mode is software already when the watcher is added, it
// will still be notified. // 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