Commit ed18a48c authored by kylechar's avatar kylechar Committed by Commit Bot

gpu: Cleanup callback types (part 4).

Remove usage of deprecated base::Bind, base::Callback, base::Closure,
base::CancelableCallback and base::CancelableClosure types from
content/gpu/*, content/browser/gpu* and chrome/gpu/*. Where possible
convert to the corresponding once type. Otherwise replace with the
repeating type which is equivalent to the deprecated type.

Bug: 714018
Change-Id: I8da148c51d9eb8b5d85a4a8f76b41f8a13ff295f
Reviewed-on: https://chromium-review.googlesource.com/c/1456941Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629955}
parent 2a95c5f6
......@@ -51,21 +51,23 @@ void ChromeContentGpuClient::InitializeRegistry(
service_manager::BinderRegistry* registry) {
#if defined(OS_CHROMEOS)
registry->AddInterface(
base::Bind(&ChromeContentGpuClient::CreateArcVideoDecodeAccelerator,
base::Unretained(this)),
base::BindRepeating(
&ChromeContentGpuClient::CreateArcVideoDecodeAccelerator,
base::Unretained(this)),
base::ThreadTaskRunnerHandle::Get());
registry->AddInterface(
base::Bind(&ChromeContentGpuClient::CreateArcVideoEncodeAccelerator,
base::Unretained(this)),
base::BindRepeating(
&ChromeContentGpuClient::CreateArcVideoEncodeAccelerator,
base::Unretained(this)),
base::ThreadTaskRunnerHandle::Get());
registry->AddInterface(
base::Bind(
base::BindRepeating(
&ChromeContentGpuClient::CreateArcVideoProtectedBufferAllocator,
base::Unretained(this)),
base::ThreadTaskRunnerHandle::Get());
registry->AddInterface(
base::Bind(&ChromeContentGpuClient::CreateProtectedBufferManager,
base::Unretained(this)),
base::BindRepeating(&ChromeContentGpuClient::CreateProtectedBufferManager,
base::Unretained(this)),
base::ThreadTaskRunnerHandle::Get());
#endif
}
......@@ -76,9 +78,9 @@ void ChromeContentGpuClient::GpuServiceInitialized(
gpu_preferences_ = gpu_preferences;
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->SetGetProtectedNativePixmapDelegate(
base::Bind(&arc::ProtectedBufferManager::GetProtectedNativePixmapFor,
base::Unretained(protected_buffer_manager_.get())));
->SetGetProtectedNativePixmapDelegate(base::BindRepeating(
&arc::ProtectedBufferManager::GetProtectedNativePixmapFor,
base::Unretained(protected_buffer_manager_.get())));
#endif
// This doesn't work in single-process mode.
......
......@@ -411,7 +411,7 @@ void BrowserGpuChannelHostFactory::RestartTimeout() {
#endif
timeout_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kGpuChannelTimeoutInSeconds),
base::Bind(&TimedOut));
base::BindOnce(&TimedOut));
#endif // OS_ANDROID
}
......
......@@ -57,10 +57,9 @@ gpu::GpuFeatureStatus GpuDataManagerImpl::GetFeatureStatus(
}
void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback) const {
VideoMemoryUsageStatsCallback callback) const {
base::AutoLock auto_lock(lock_);
private_->RequestVideoMemoryUsageStatsUpdate(callback);
private_->RequestVideoMemoryUsageStatsUpdate(std::move(callback));
}
void GpuDataManagerImpl::AddObserver(
......
......@@ -33,7 +33,6 @@ class GURL;
namespace gpu {
struct GpuPreferences;
struct VideoMemoryUsageStats;
}
namespace content {
......@@ -52,8 +51,7 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager {
void RequestCompleteGpuInfoIfNeeded() override;
bool IsEssentialGpuInfoAvailable() const override;
void RequestVideoMemoryUsageStatsUpdate(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback) const override;
VideoMemoryUsageStatsCallback callback) const override;
// TODO(kbr): the threading model for the GpuDataManagerObservers is
// not well defined, and it's impossible for callers to correctly
// delete observers from anywhere except in one of the observer's
......
......@@ -234,21 +234,19 @@ enum BlockStatusHistogram {
};
void OnVideoMemoryUsageStats(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback,
GpuDataManager::VideoMemoryUsageStatsCallback callback,
const gpu::VideoMemoryUsageStats& stats) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, stats));
base::BindOnce(std::move(callback), stats));
}
void RequestVideoMemoryUsageStats(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback,
GpuDataManager::VideoMemoryUsageStatsCallback callback,
GpuProcessHost* host) {
if (!host)
return;
host->gpu_service()->GetVideoMemoryUsageStats(
base::BindOnce(&OnVideoMemoryUsageStats, callback));
base::BindOnce(&OnVideoMemoryUsageStats, std::move(callback)));
}
#if defined(OS_WIN)
......@@ -390,7 +388,7 @@ void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() {
complete_gpu_info_already_requested_ = true;
GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED_NO_GL,
true /* force_create */,
base::Bind([](GpuProcessHost* host) {
base::BindOnce([](GpuProcessHost* host) {
if (!host)
return;
host->gpu_service()->RequestCompleteGpuInfo(
......@@ -440,11 +438,10 @@ gpu::GpuFeatureStatus GpuDataManagerImplPrivate::GetFeatureStatus(
}
void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback) const {
GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
false /* force_create */,
base::Bind(&RequestVideoMemoryUsageStats, callback));
GpuDataManager::VideoMemoryUsageStatsCallback callback) const {
GpuProcessHost::CallOnIO(
GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, false /* force_create */,
base::BindOnce(&RequestVideoMemoryUsageStats, std::move(callback)));
}
void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) {
......@@ -691,7 +688,7 @@ void GpuDataManagerImplPrivate::HandleGpuSwitch() {
// Pass the notification to the GPU process to notify observers there.
GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
false /* force_create */,
base::Bind([](GpuProcessHost* host) {
base::BindOnce([](GpuProcessHost* host) {
if (host)
host->gpu_service()->GpuSwitched();
}));
......
......@@ -30,7 +30,6 @@ class CommandLine;
namespace gpu {
struct GpuPreferences;
struct VideoMemoryUsageStats;
}
namespace content {
......@@ -51,8 +50,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
bool IsGpuFeatureInfoAvailable() const;
gpu::GpuFeatureStatus GetFeatureStatus(gpu::GpuFeatureType feature) const;
void RequestVideoMemoryUsageStatsUpdate(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback) const;
GpuDataManager::VideoMemoryUsageStatsCallback callback) const;
void AddObserver(GpuDataManagerObserver* observer);
void RemoveObserver(GpuDataManagerObserver* observer);
void UnblockDomainFrom3DAPIs(const GURL& url);
......
......@@ -111,11 +111,6 @@ class BrowserGpuChannelHostFactoryTest : public ContentBrowserTest {
command_line->AppendSwitch(switches::kDisableGpuEarlyInit);
}
void OnContextLost(const base::Closure callback, int* counter) {
(*counter)++;
callback.Run();
}
void Signal(bool* event,
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) {
CHECK_EQ(*event, false);
......@@ -287,7 +282,7 @@ IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
ASSERT_EQ(provider->BindToCurrentThread(), gpu::ContextResult::kSuccess);
GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
false /* force_create */,
base::Bind([](GpuProcessHost* host) {
base::BindOnce([](GpuProcessHost* host) {
if (host)
host->gpu_service()->Crash();
}));
......
......@@ -275,9 +275,9 @@ GpuProcessHost* g_gpu_process_hosts[GpuProcessHost::GPU_PROCESS_KIND_COUNT];
void RunCallbackOnIO(GpuProcessHost::GpuProcessKind kind,
bool force_create,
const base::Callback<void(GpuProcessHost*)>& callback) {
base::OnceCallback<void(GpuProcessHost*)> callback) {
GpuProcessHost* host = GpuProcessHost::Get(kind, force_create);
callback.Run(host);
std::move(callback).Run(host);
}
void OnGpuProcessHostDestroyedOnUI(int host_id, const std::string& message) {
......@@ -484,11 +484,12 @@ class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter {
explicit ConnectionFilterImpl(int gpu_process_id) {
auto task_runner =
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI});
registry_.AddInterface(base::Bind(&FieldTrialRecorder::Create),
registry_.AddInterface(base::BindRepeating(&FieldTrialRecorder::Create),
task_runner);
#if defined(OS_ANDROID)
registry_.AddInterface(
base::Bind(&BindJavaInterface<media::mojom::AndroidOverlayProvider>),
base::BindRepeating(
&BindJavaInterface<media::mojom::AndroidOverlayProvider>),
task_runner);
#endif
}
......@@ -599,13 +600,13 @@ void GpuProcessHost::GetHasGpuProcess(base::OnceCallback<void(bool)> callback) {
void GpuProcessHost::CallOnIO(
GpuProcessKind kind,
bool force_create,
const base::Callback<void(GpuProcessHost*)>& callback) {
base::OnceCallback<void(GpuProcessHost*)> callback) {
#if !defined(OS_WIN)
DCHECK_NE(kind, GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED_NO_GL);
#endif
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&RunCallbackOnIO, kind, force_create, callback));
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(&RunCallbackOnIO, kind, force_create,
std::move(callback)));
}
void GpuProcessHost::BindInterface(
......
......@@ -85,7 +85,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
CONTENT_EXPORT static void CallOnIO(
GpuProcessKind kind,
bool force_create,
const base::Callback<void(GpuProcessHost*)>& callback);
base::OnceCallback<void(GpuProcessHost*)> callback);
// Get the GPU process host for the GPU process with the given ID. Returns
// null if the process no longer exists.
......
......@@ -82,11 +82,11 @@ class QueueingConnectionFilter : public ConnectionFilter {
DCHECK(io_thread_checker_.CalledOnValidThread());
}
base::Closure GetReleaseCallback() {
return base::Bind(base::IgnoreResult(&base::TaskRunner::PostTask),
io_task_runner_, FROM_HERE,
base::Bind(&QueueingConnectionFilter::Release,
weak_factory_.GetWeakPtr()));
base::OnceClosure GetReleaseCallback() {
return base::BindOnce(base::IgnoreResult(&base::TaskRunner::PostTask),
io_task_runner_, FROM_HERE,
base::BindOnce(&QueueingConnectionFilter::Release,
weak_factory_.GetWeakPtr()));
}
#if defined(USE_OZONE)
......@@ -233,13 +233,14 @@ void GpuChildThread::Init(const base::Time& process_start_time) {
blink::AssociatedInterfaceRegistry* associated_registry =
&associated_interfaces_;
associated_registry->AddInterface(base::Bind(
associated_registry->AddInterface(base::BindRepeating(
&GpuChildThread::CreateVizMainService, base::Unretained(this)));
auto registry = std::make_unique<service_manager::BinderRegistry>();
registry->AddInterface(base::Bind(&GpuChildThread::BindServiceFactoryRequest,
weak_factory_.GetWeakPtr()),
base::ThreadTaskRunnerHandle::Get());
registry->AddInterface(
base::BindRepeating(&GpuChildThread::BindServiceFactoryRequest,
weak_factory_.GetWeakPtr()),
base::ThreadTaskRunnerHandle::Get());
if (GetContentClient()->gpu()) // nullptr in tests.
GetContentClient()->gpu()->InitializeRegistry(registry.get());
......@@ -292,8 +293,9 @@ void GpuChildThread::OnInitializationFailed() {
void GpuChildThread::OnGpuServiceConnection(viz::GpuServiceImpl* gpu_service) {
media::AndroidOverlayMojoFactoryCB overlay_factory_cb;
#if defined(OS_ANDROID)
overlay_factory_cb = base::Bind(&GpuChildThread::CreateAndroidOverlay,
base::ThreadTaskRunnerHandle::Get());
overlay_factory_cb =
base::BindRepeating(&GpuChildThread::CreateAndroidOverlay,
base::ThreadTaskRunnerHandle::Get());
gpu_service->media_gpu_channel_manager()->SetOverlayFactory(
overlay_factory_cb);
#endif
......@@ -311,7 +313,8 @@ void GpuChildThread::OnGpuServiceConnection(viz::GpuServiceImpl* gpu_service) {
gpu_service->gpu_preferences());
}
release_pending_requests_closure_.Run();
DCHECK(release_pending_requests_closure_);
std::move(release_pending_requests_closure_).Run();
}
void GpuChildThread::PostCompositorThreadCreated(
......
......@@ -114,7 +114,7 @@ class GpuChildThread : public ChildThreadImpl,
blink::AssociatedInterfaceRegistry associated_interfaces_;
// Holds a closure that releases pending interface requests on the IO thread.
base::Closure release_pending_requests_closure_;
base::OnceClosure release_pending_requests_closure_;
// A closure which quits the main message loop.
base::RepeatingClosure quit_closure_;
......
......@@ -28,6 +28,9 @@ class GpuDataManagerObserver;
// This class is fully thread-safe.
class GpuDataManager {
public:
using VideoMemoryUsageStatsCallback =
base::OnceCallback<void(const gpu::VideoMemoryUsageStats&)>;
// Getter for the singleton.
CONTENT_EXPORT static GpuDataManager* GetInstance();
......@@ -53,8 +56,7 @@ class GpuDataManager {
// Requests that the GPU process report its current video memory usage stats.
virtual void RequestVideoMemoryUsageStatsUpdate(
const base::Callback<void(const gpu::VideoMemoryUsageStats& stats)>&
callback) const = 0;
VideoMemoryUsageStatsCallback callback) const = 0;
// Registers/unregister |observer|.
virtual void AddObserver(GpuDataManagerObserver* observer) = 0;
......
......@@ -18,8 +18,9 @@ ShellContentGpuClient::~ShellContentGpuClient() = default;
void ShellContentGpuClient::InitializeRegistry(
service_manager::BinderRegistry* registry) {
registry->AddInterface<mojom::PowerMonitorTest>(
base::Bind(&PowerMonitorTestImpl::MakeStrongBinding,
base::Passed(std::make_unique<PowerMonitorTestImpl>())),
base::BindRepeating(
&PowerMonitorTestImpl::MakeStrongBinding,
base::Passed(std::make_unique<PowerMonitorTestImpl>())),
base::ThreadTaskRunnerHandle::Get());
}
......
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