#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif
#include "services/viz/privileged/mojom/gl/gpu_service.mojom.h"
#include <math.h>
#include <stdint.h>
#include <utility>
#include "base/debug/alias.h"
#include "base/hash/md5_constexpr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/cpp/bindings/features.h"
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/proxy_to_responder.h"
#include "mojo/public/cpp/bindings/lib/send_message_helper.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "mojo/public/cpp/bindings/urgent_message_scope.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "services/viz/privileged/mojom/gl/gpu_service.mojom-params-data.h"
#include "services/viz/privileged/mojom/gl/gpu_service.mojom-shared-message-ids.h"
#include "services/viz/privileged/mojom/gl/gpu_service.mojom-import-headers.h"
#include "services/viz/privileged/mojom/gl/gpu_service.mojom-test-utils.h"
namespace viz::mojom {
const char GpuService::Name_[] = …;
GpuService::IPCStableHashFunction GpuService::MessageToMethodInfo_(mojo::Message& message) { … }
const char* GpuService::MessageToMethodName_(mojo::Message& message) { … }
#if !BUILDFLAG(IS_FUCHSIA)
uint32_t GpuService::EstablishGpuChannel_Sym::IPCStableHash() { … }
uint32_t GpuService::SetChannelClientPid_Sym::IPCStableHash() { … }
uint32_t GpuService::SetChannelDiskCacheHandle_Sym::IPCStableHash() { … }
uint32_t GpuService::OnDiskCacheHandleDestoyed_Sym::IPCStableHash() { … }
uint32_t GpuService::CloseChannel_Sym::IPCStableHash() { … }
uint32_t GpuService::BindClientGmbInterface_Sym::IPCStableHash() { … }
uint32_t GpuService::CreateVideoEncodeAcceleratorProvider_Sym::IPCStableHash() { … }
uint32_t GpuService::BindWebNNContextProvider_Sym::IPCStableHash() { … }
uint32_t GpuService::CreateGpuMemoryBuffer_Sym::IPCStableHash() { … }
uint32_t GpuService::DestroyGpuMemoryBuffer_Sym::IPCStableHash() { … }
uint32_t GpuService::CopyGpuMemoryBuffer_Sym::IPCStableHash() { … }
uint32_t GpuService::GetVideoMemoryUsageStats_Sym::IPCStableHash() { … }
uint32_t GpuService::StartPeakMemoryMonitor_Sym::IPCStableHash() { … }
uint32_t GpuService::GetPeakMemoryUsage_Sym::IPCStableHash() { … }
uint32_t GpuService::LoadedBlob_Sym::IPCStableHash() { … }
uint32_t GpuService::WakeUpGpu_Sym::IPCStableHash() { … }
uint32_t GpuService::GpuSwitched_Sym::IPCStableHash() { … }
uint32_t GpuService::DisplayAdded_Sym::IPCStableHash() { … }
uint32_t GpuService::DisplayRemoved_Sym::IPCStableHash() { … }
uint32_t GpuService::DisplayMetricsChanged_Sym::IPCStableHash() { … }
uint32_t GpuService::DestroyAllChannels_Sym::IPCStableHash() { … }
uint32_t GpuService::OnBackgroundCleanup_Sym::IPCStableHash() { … }
uint32_t GpuService::OnBackgrounded_Sym::IPCStableHash() { … }
uint32_t GpuService::OnForegrounded_Sym::IPCStableHash() { … }
uint32_t GpuService::OnMemoryPressure_Sym::IPCStableHash() { … }
uint32_t GpuService::GetDawnInfo_Sym::IPCStableHash() { … }
uint32_t GpuService::Crash_Sym::IPCStableHash() { … }
uint32_t GpuService::Hang_Sym::IPCStableHash() { … }
uint32_t GpuService::ThrowJavaException_Sym::IPCStableHash() { … }
# endif
bool GpuService::EstablishGpuChannel(int32_t client_id, uint64_t client_tracing_id, bool is_gpu_host, ::mojo::ScopedMessagePipeHandle* out_channel_handle, ::gpu::GPUInfo* out_gpu_info, ::gpu::GpuFeatureInfo* out_gpu_feature_info, ::gpu::SharedImageCapabilities* out_shared_image_capabilities) { … }
bool GpuService::CreateGpuMemoryBuffer(::gfx::GpuMemoryBufferId id, const ::gfx::Size& size, ::gfx::BufferFormat format, ::gfx::BufferUsage usage, int32_t client_id, ::gpu::SurfaceHandle surface_handle, ::gfx::GpuMemoryBufferHandle* out_buffer_handle) { … }
class GpuService_EstablishGpuChannel_HandleSyncResponse
: public mojo::MessageReceiver { … };
class GpuService_EstablishGpuChannel_ForwardToCallback
: public mojo::MessageReceiver { … };
class GpuService_CreateGpuMemoryBuffer_HandleSyncResponse
: public mojo::MessageReceiver { … };
class GpuService_CreateGpuMemoryBuffer_ForwardToCallback
: public mojo::MessageReceiver { … };
class GpuService_CopyGpuMemoryBuffer_ForwardToCallback
: public mojo::MessageReceiver { … };
class GpuService_GetVideoMemoryUsageStats_ForwardToCallback
: public mojo::MessageReceiver { … };
class GpuService_GetPeakMemoryUsage_ForwardToCallback
: public mojo::MessageReceiver { … };
class GpuService_GetDawnInfo_ForwardToCallback
: public mojo::MessageReceiver { … };
GpuServiceProxy::GpuServiceProxy(mojo::MessageReceiverWithResponder* receiver)
: … { … }
bool GpuServiceProxy::EstablishGpuChannel(
int32_t param_client_id, uint64_t param_client_tracing_id, bool param_is_gpu_host, ::mojo::ScopedMessagePipeHandle* out_param_channel_handle, ::gpu::GPUInfo* out_param_gpu_info, ::gpu::GpuFeatureInfo* out_param_gpu_feature_info, ::gpu::SharedImageCapabilities* out_param_shared_image_capabilities) { … }
void GpuServiceProxy::EstablishGpuChannel(
int32_t in_client_id, uint64_t in_client_tracing_id, bool in_is_gpu_host, EstablishGpuChannelCallback callback) { … }
void GpuServiceProxy::SetChannelClientPid(
int32_t in_client_id, ::base::ProcessId in_client_pid) { … }
void GpuServiceProxy::SetChannelDiskCacheHandle(
int32_t in_client_id, const ::gpu::GpuDiskCacheHandle& in_cache_handle) { … }
void GpuServiceProxy::OnDiskCacheHandleDestoyed(
const ::gpu::GpuDiskCacheHandle& in_cache_handle) { … }
void GpuServiceProxy::CloseChannel(
int32_t in_client_id) { … }
void GpuServiceProxy::BindClientGmbInterface(
::mojo::PendingReceiver<::gpu::mojom::ClientGmbInterface> in_receiver, int32_t in_client_id) { … }
void GpuServiceProxy::CreateVideoEncodeAcceleratorProvider(
::mojo::PendingReceiver<::media::mojom::VideoEncodeAcceleratorProvider> in_vea_provider) { … }
void GpuServiceProxy::BindWebNNContextProvider(
::mojo::PendingReceiver<::webnn::mojom::WebNNContextProvider> in_receiver, int32_t in_client_id) { … }
bool GpuServiceProxy::CreateGpuMemoryBuffer(
::gfx::GpuMemoryBufferId param_id, const ::gfx::Size& param_size, ::gfx::BufferFormat param_format, ::gfx::BufferUsage param_usage, int32_t param_client_id, ::gpu::SurfaceHandle param_surface_handle, ::gfx::GpuMemoryBufferHandle* out_param_buffer_handle) { … }
void GpuServiceProxy::CreateGpuMemoryBuffer(
::gfx::GpuMemoryBufferId in_id, const ::gfx::Size& in_size, ::gfx::BufferFormat in_format, ::gfx::BufferUsage in_usage, int32_t in_client_id, ::gpu::SurfaceHandle in_surface_handle, CreateGpuMemoryBufferCallback callback) { … }
void GpuServiceProxy::DestroyGpuMemoryBuffer(
::gfx::GpuMemoryBufferId in_id, int32_t in_client_id) { … }
void GpuServiceProxy::CopyGpuMemoryBuffer(
::gfx::GpuMemoryBufferHandle in_buffer_handle, ::base::UnsafeSharedMemoryRegion in_shared_memory, CopyGpuMemoryBufferCallback callback) { … }
void GpuServiceProxy::GetVideoMemoryUsageStats(
GetVideoMemoryUsageStatsCallback callback) { … }
void GpuServiceProxy::StartPeakMemoryMonitor(
uint32_t in_sequence_num) { … }
void GpuServiceProxy::GetPeakMemoryUsage(
uint32_t in_sequence_num, GetPeakMemoryUsageCallback callback) { … }
void GpuServiceProxy::LoadedBlob(
const ::gpu::GpuDiskCacheHandle& in_cache_handle, const std::string& in_key, const std::string& in_data) { … }
void GpuServiceProxy::WakeUpGpu(
) { … }
void GpuServiceProxy::GpuSwitched(
::gl::GpuPreference in_active_gpu_heuristic) { … }
void GpuServiceProxy::DisplayAdded(
) { … }
void GpuServiceProxy::DisplayRemoved(
) { … }
void GpuServiceProxy::DisplayMetricsChanged(
) { … }
void GpuServiceProxy::DestroyAllChannels(
) { … }
void GpuServiceProxy::OnBackgroundCleanup(
) { … }
void GpuServiceProxy::OnBackgrounded(
) { … }
void GpuServiceProxy::OnForegrounded(
) { … }
void GpuServiceProxy::OnMemoryPressure(
::base::MemoryPressureListener::MemoryPressureLevel in_level) { … }
void GpuServiceProxy::GetDawnInfo(
bool in_collect_metrics, GetDawnInfoCallback callback) { … }
void GpuServiceProxy::Crash(
) { … }
void GpuServiceProxy::Hang(
) { … }
void GpuServiceProxy::ThrowJavaException(
) { … }
class GpuService_EstablishGpuChannel_ProxyToResponder : public ::mojo::internal::ProxyToResponder { … };
bool GpuService_EstablishGpuChannel_ForwardToCallback::Accept(
mojo::Message* message) { … }
void GpuService_EstablishGpuChannel_ProxyToResponder::Run(
::mojo::ScopedMessagePipeHandle in_channel_handle, const ::gpu::GPUInfo& in_gpu_info, const ::gpu::GpuFeatureInfo& in_gpu_feature_info, const ::gpu::SharedImageCapabilities& in_shared_image_capabilities) { … }
bool GpuService_EstablishGpuChannel_HandleSyncResponse::Accept(
mojo::Message* message) { … }
class GpuService_CreateGpuMemoryBuffer_ProxyToResponder : public ::mojo::internal::ProxyToResponder { … };
bool GpuService_CreateGpuMemoryBuffer_ForwardToCallback::Accept(
mojo::Message* message) { … }
void GpuService_CreateGpuMemoryBuffer_ProxyToResponder::Run(
::gfx::GpuMemoryBufferHandle in_buffer_handle) { … }
bool GpuService_CreateGpuMemoryBuffer_HandleSyncResponse::Accept(
mojo::Message* message) { … }
class GpuService_CopyGpuMemoryBuffer_ProxyToResponder : public ::mojo::internal::ProxyToResponder { … };
bool GpuService_CopyGpuMemoryBuffer_ForwardToCallback::Accept(
mojo::Message* message) { … }
void GpuService_CopyGpuMemoryBuffer_ProxyToResponder::Run(
bool in_success) { … }
class GpuService_GetVideoMemoryUsageStats_ProxyToResponder : public ::mojo::internal::ProxyToResponder { … };
bool GpuService_GetVideoMemoryUsageStats_ForwardToCallback::Accept(
mojo::Message* message) { … }
void GpuService_GetVideoMemoryUsageStats_ProxyToResponder::Run(
const ::gpu::VideoMemoryUsageStats& in_stats) { … }
class GpuService_GetPeakMemoryUsage_ProxyToResponder : public ::mojo::internal::ProxyToResponder { … };
bool GpuService_GetPeakMemoryUsage_ForwardToCallback::Accept(
mojo::Message* message) { … }
void GpuService_GetPeakMemoryUsage_ProxyToResponder::Run(
uint64_t in_memory_usage, const base::flat_map<::gpu::GpuPeakMemoryAllocationSource, uint64_t>& in_memory_per_allocation_source) { … }
class GpuService_GetDawnInfo_ProxyToResponder : public ::mojo::internal::ProxyToResponder { … };
bool GpuService_GetDawnInfo_ForwardToCallback::Accept(
mojo::Message* message) { … }
void GpuService_GetDawnInfo_ProxyToResponder::Run(
const std::vector<std::string>& in_dawn_info_list) { … }
bool GpuServiceStubDispatch::Accept(
GpuService* impl,
mojo::Message* message) { … }
bool GpuServiceStubDispatch::AcceptWithResponder(
GpuService* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { … }
namespace {
bool ValidateWithRuntimeFeature_GpuService_BindWebNNContextProvider(
const void* data, mojo::internal::ValidationContext* validation_context) { … }
}
static const mojo::internal::GenericValidationInfo kGpuServiceValidationInfo[] = …;
bool GpuServiceRequestValidator::Accept(mojo::Message* message) { … }
bool GpuServiceResponseValidator::Accept(mojo::Message* message) { … }
}
namespace mojo {
}
namespace viz::mojom {
void GpuServiceInterceptorForTesting::EstablishGpuChannel(int32_t client_id, uint64_t client_tracing_id, bool is_gpu_host, EstablishGpuChannelCallback callback) { … }
void GpuServiceInterceptorForTesting::SetChannelClientPid(int32_t client_id, ::base::ProcessId client_pid) { … }
void GpuServiceInterceptorForTesting::SetChannelDiskCacheHandle(int32_t client_id, const ::gpu::GpuDiskCacheHandle& cache_handle) { … }
void GpuServiceInterceptorForTesting::OnDiskCacheHandleDestoyed(const ::gpu::GpuDiskCacheHandle& cache_handle) { … }
void GpuServiceInterceptorForTesting::CloseChannel(int32_t client_id) { … }
void GpuServiceInterceptorForTesting::BindClientGmbInterface(::mojo::PendingReceiver<::gpu::mojom::ClientGmbInterface> receiver, int32_t client_id) { … }
void GpuServiceInterceptorForTesting::CreateVideoEncodeAcceleratorProvider(::mojo::PendingReceiver<::media::mojom::VideoEncodeAcceleratorProvider> vea_provider) { … }
void GpuServiceInterceptorForTesting::BindWebNNContextProvider(::mojo::PendingReceiver<::webnn::mojom::WebNNContextProvider> receiver, int32_t client_id) { … }
void GpuServiceInterceptorForTesting::CreateGpuMemoryBuffer(::gfx::GpuMemoryBufferId id, const ::gfx::Size& size, ::gfx::BufferFormat format, ::gfx::BufferUsage usage, int32_t client_id, ::gpu::SurfaceHandle surface_handle, CreateGpuMemoryBufferCallback callback) { … }
void GpuServiceInterceptorForTesting::DestroyGpuMemoryBuffer(::gfx::GpuMemoryBufferId id, int32_t client_id) { … }
void GpuServiceInterceptorForTesting::CopyGpuMemoryBuffer(::gfx::GpuMemoryBufferHandle buffer_handle, ::base::UnsafeSharedMemoryRegion shared_memory, CopyGpuMemoryBufferCallback callback) { … }
void GpuServiceInterceptorForTesting::GetVideoMemoryUsageStats(GetVideoMemoryUsageStatsCallback callback) { … }
void GpuServiceInterceptorForTesting::StartPeakMemoryMonitor(uint32_t sequence_num) { … }
void GpuServiceInterceptorForTesting::GetPeakMemoryUsage(uint32_t sequence_num, GetPeakMemoryUsageCallback callback) { … }
void GpuServiceInterceptorForTesting::LoadedBlob(const ::gpu::GpuDiskCacheHandle& cache_handle, const std::string& key, const std::string& data) { … }
void GpuServiceInterceptorForTesting::WakeUpGpu() { … }
void GpuServiceInterceptorForTesting::GpuSwitched(::gl::GpuPreference active_gpu_heuristic) { … }
void GpuServiceInterceptorForTesting::DisplayAdded() { … }
void GpuServiceInterceptorForTesting::DisplayRemoved() { … }
void GpuServiceInterceptorForTesting::DisplayMetricsChanged() { … }
void GpuServiceInterceptorForTesting::DestroyAllChannels() { … }
void GpuServiceInterceptorForTesting::OnBackgroundCleanup() { … }
void GpuServiceInterceptorForTesting::OnBackgrounded() { … }
void GpuServiceInterceptorForTesting::OnForegrounded() { … }
void GpuServiceInterceptorForTesting::OnMemoryPressure(::base::MemoryPressureListener::MemoryPressureLevel level) { … }
void GpuServiceInterceptorForTesting::GetDawnInfo(bool collect_metrics, GetDawnInfoCallback callback) { … }
void GpuServiceInterceptorForTesting::Crash() { … }
void GpuServiceInterceptorForTesting::Hang() { … }
void GpuServiceInterceptorForTesting::ThrowJavaException() { … }
GpuServiceAsyncWaiter::GpuServiceAsyncWaiter(
GpuService* proxy) : … { … }
GpuServiceAsyncWaiter::~GpuServiceAsyncWaiter() = default;
void GpuServiceAsyncWaiter::EstablishGpuChannel(
int32_t client_id, uint64_t client_tracing_id, bool is_gpu_host, ::mojo::ScopedMessagePipeHandle* out_channel_handle, ::gpu::GPUInfo* out_gpu_info, ::gpu::GpuFeatureInfo* out_gpu_feature_info, ::gpu::SharedImageCapabilities* out_shared_image_capabilities) { … }
void GpuServiceAsyncWaiter::CreateGpuMemoryBuffer(
::gfx::GpuMemoryBufferId id, const ::gfx::Size& size, ::gfx::BufferFormat format, ::gfx::BufferUsage usage, int32_t client_id, ::gpu::SurfaceHandle surface_handle, ::gfx::GpuMemoryBufferHandle* out_buffer_handle) { … }
::gfx::GpuMemoryBufferHandle GpuServiceAsyncWaiter::CreateGpuMemoryBuffer(
::gfx::GpuMemoryBufferId id, const ::gfx::Size& size, ::gfx::BufferFormat format, ::gfx::BufferUsage usage, int32_t client_id, ::gpu::SurfaceHandle surface_handle) { … }
void GpuServiceAsyncWaiter::CopyGpuMemoryBuffer(
::gfx::GpuMemoryBufferHandle buffer_handle, ::base::UnsafeSharedMemoryRegion shared_memory, bool* out_success) { … }
bool GpuServiceAsyncWaiter::CopyGpuMemoryBuffer(
::gfx::GpuMemoryBufferHandle buffer_handle, ::base::UnsafeSharedMemoryRegion shared_memory) { … }
void GpuServiceAsyncWaiter::GetVideoMemoryUsageStats(
::gpu::VideoMemoryUsageStats* out_stats) { … }
::gpu::VideoMemoryUsageStats GpuServiceAsyncWaiter::GetVideoMemoryUsageStats(
) { … }
void GpuServiceAsyncWaiter::GetPeakMemoryUsage(
uint32_t sequence_num, uint64_t* out_memory_usage, base::flat_map<::gpu::GpuPeakMemoryAllocationSource, uint64_t>* out_memory_per_allocation_source) { … }
void GpuServiceAsyncWaiter::GetDawnInfo(
bool collect_metrics, std::vector<std::string>* out_dawn_info_list) { … }
std::vector<std::string> GpuServiceAsyncWaiter::GetDawnInfo(
bool collect_metrics) { … }
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif