Commit babed2b5 authored by Mohsen Izadi's avatar Mohsen Izadi Committed by Commit Bot

Add connection error handlers to viz::GpuHostImpl

Before this CL, they were in content::GpuProcessHost.

BUG=709332

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I9183ed0fc7c5baec2ea98fd3e68d8a8910fc41d4
Reviewed-on: https://chromium-review.googlesource.com/1195679
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587903}
parent 63affad9
......@@ -145,6 +145,10 @@ void GpuHostImpl::OnProcessCrashed() {
}
}
void GpuHostImpl::AddConnectionErrorHandler(base::OnceClosure handler) {
connection_error_handlers_.push_back(std::move(handler));
}
void GpuHostImpl::BlockLiveOffscreenContexts() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......@@ -224,6 +228,10 @@ void GpuHostImpl::EstablishGpuChannel(int client_id,
void GpuHostImpl::SendOutstandingReplies() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
for (auto& handler : connection_error_handlers_)
std::move(handler).Run();
connection_error_handlers_.clear();
// Send empty channel handles for all EstablishChannel requests.
while (!channel_requests_.empty()) {
auto callback = std::move(channel_requests_.front());
......
......@@ -9,7 +9,9 @@
#include <queue>
#include <set>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
......@@ -125,6 +127,9 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost {
void OnProcessLaunched(base::ProcessId pid);
void OnProcessCrashed();
// Adds a connection error handler for the GpuService.
void AddConnectionErrorHandler(base::OnceClosure handler);
void BlockLiveOffscreenContexts();
// Connects to FrameSinkManager running in the Viz service.
......@@ -197,6 +202,9 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost {
base::ProcessId pid_ = base::kNullProcessId;
// List of connection error handlers for the GpuService.
std::vector<base::OnceClosure> connection_error_handlers_;
// Whether the GPU service has started successfully or not.
bool initialized_ = false;
......
......@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "components/viz/host/gpu_host_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
......@@ -18,7 +19,8 @@ GpuMemoryBufferManagerSingleton* g_gpu_memory_buffer_manager;
viz::mojom::GpuService* GetGpuService(
base::OnceClosure connection_error_handler) {
if (auto* host = GpuProcessHost::Get()) {
host->AddConnectionErrorHandler(std::move(connection_error_handler));
host->gpu_host()->AddConnectionErrorHandler(
std::move(connection_error_handler));
return host->gpu_service();
}
return nullptr;
......
......@@ -959,10 +959,6 @@ void GpuProcessHost::OnChannelConnected(int32_t peer_pid) {
}
}
void GpuProcessHost::AddConnectionErrorHandler(base::OnceClosure handler) {
connection_error_handlers_.push_back(std::move(handler));
}
#if defined(OS_ANDROID)
void GpuProcessHost::OnDestroyingVideoSurfaceAck() {
TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck");
......@@ -1217,10 +1213,6 @@ bool GpuProcessHost::LaunchGpuProcess() {
void GpuProcessHost::SendOutstandingReplies() {
valid_ = false;
for (auto& handler : connection_error_handlers_)
std::move(handler).Run();
connection_error_handlers_.clear();
if (gpu_host_)
gpu_host_->SendOutstandingReplies();
......
......@@ -11,7 +11,6 @@
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/atomicops.h"
#include "base/callback.h"
......@@ -98,9 +97,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// IPC::Sender implementation.
bool Send(IPC::Message* msg) override;
// Adds a connection error handler for the GpuService.
void AddConnectionErrorHandler(base::OnceClosure handler);
// What kind of GPU process, e.g. sandboxed or unsandboxed.
GpuProcessKind kind();
......@@ -189,9 +185,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// GPU process id in case GPU is not in-process.
base::ProcessId process_id_ = base::kNullProcessId;
// List of connection error handlers for the GpuService.
std::vector<base::OnceClosure> connection_error_handlers_;
// A callback to signal the completion of a SendDestroyingVideoSurface call.
base::Closure send_destroying_video_surface_done_cb_;
......
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