#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include <utility>
#include "base/android/orderfile/orderfile_buildflags.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/process/process_handle.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "base/timer/timer.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/viz/host/gpu_host_impl.h"
#include "content/browser/child_process_host_impl.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_disk_cache_factory.h"
#include "content/browser/gpu/gpu_memory_buffer_manager_singleton.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "gpu/ipc/common/gpu_client_ids.h"
#include "gpu/ipc/common/gpu_watchdog_timeout.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/constants.mojom.h"
#if BUILDFLAG(IS_MAC)
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
#endif
namespace content {
namespace {
#if BUILDFLAG(IS_ANDROID)
NOINLINE void TimedOut() {
LOG(FATAL) << "Timed out waiting for GPU channel.";
}
void DumpGpuStackOnProcessThread() {
GpuProcessHost* host =
GpuProcessHost::Get(GPU_PROCESS_KIND_SANDBOXED, false);
if (host) {
host->DumpProcessStack();
}
TimedOut();
}
#endif
}
BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = …;
class BrowserGpuChannelHostFactory::EstablishRequest
: public base::RefCountedThreadSafe<EstablishRequest> { … };
scoped_refptr<BrowserGpuChannelHostFactory::EstablishRequest>
BrowserGpuChannelHostFactory::EstablishRequest::Create(
int gpu_client_id,
uint64_t gpu_client_tracing_id,
bool sync,
std::vector<gpu::GpuChannelEstablishedCallback> established_callbacks) { … }
BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest(
int gpu_client_id,
uint64_t gpu_client_tracing_id,
std::vector<gpu::GpuChannelEstablishedCallback> established_callbacks)
: … { … }
void BrowserGpuChannelHostFactory::EstablishRequest::RestartTimeout() { … }
void BrowserGpuChannelHostFactory::EstablishRequest::Establish(bool sync) { … }
void BrowserGpuChannelHostFactory::EstablishRequest::OnEstablished(
mojo::ScopedMessagePipeHandle channel_handle,
const gpu::GPUInfo& gpu_info,
const gpu::GpuFeatureInfo& gpu_feature_info,
const gpu::SharedImageCapabilities& shared_image_capabilities,
viz::GpuHostImpl::EstablishChannelStatus status) { … }
void BrowserGpuChannelHostFactory::EstablishRequest::Finish() { … }
void BrowserGpuChannelHostFactory::EstablishRequest::
FinishAndRunCallbacksOnMain() { … }
void BrowserGpuChannelHostFactory::EstablishRequest::FinishOnMain() { … }
void BrowserGpuChannelHostFactory::EstablishRequest::RunCallbacksOnMain() { … }
void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { … }
void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { … }
void BrowserGpuChannelHostFactory::Initialize(bool establish_gpu_channel) { … }
void BrowserGpuChannelHostFactory::Terminate() { … }
void BrowserGpuChannelHostFactory::MaybeCloseChannel() { … }
void BrowserGpuChannelHostFactory::CloseChannel() { … }
BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory()
: … { … }
BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { … }
void BrowserGpuChannelHostFactory::EstablishGpuChannel(
gpu::GpuChannelEstablishedCallback callback) { … }
scoped_refptr<gpu::GpuChannelHost>
BrowserGpuChannelHostFactory::EstablishGpuChannelSync() { … }
void BrowserGpuChannelHostFactory::EstablishGpuChannel(
gpu::GpuChannelEstablishedCallback callback,
bool sync) { … }
gpu::GpuMemoryBufferManager*
BrowserGpuChannelHostFactory::GetGpuMemoryBufferManager() { … }
void BrowserGpuChannelHostFactory::SetApplicationVisible(bool is_visible) { … }
gpu::GpuChannelHost* BrowserGpuChannelHostFactory::GetGpuChannel() { … }
void BrowserGpuChannelHostFactory::GpuChannelEstablished(
EstablishRequest* request) { … }
void BrowserGpuChannelHostFactory::RestartTimeout() { … }
}