Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Unified Diff: content/gpu/gpu_child_thread.cc

Issue 1711533002: Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Mark's nit Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/gpu/gpu_child_thread.cc
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index 6ea7e2ec22010e863e109012fbb8aa56e641af59..9f91dac691deaa169414eb27fb16449df7d7978b 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -13,8 +13,9 @@
#include "build/build_config.h"
#include "content/child/child_process.h"
#include "content/child/thread_safe_sender.h"
+#include "content/common/gpu/establish_channel_params.h"
+#include "content/common/gpu/gpu_browser_messages.h"
#include "content/common/gpu/gpu_memory_buffer_factory.h"
-#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/media/gpu_video_decode_accelerator.h"
#include "content/gpu/gpu_process_control_impl.h"
#include "content/gpu/gpu_watchdog_thread.h"
@@ -45,13 +46,14 @@ bool GpuProcessLogMessageHandler(int severity,
std::string header = str.substr(0, message_start);
std::string message = str.substr(message_start);
- g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage(
- severity, header, message));
+ g_thread_safe_sender.Get()->Send(
+ new GpuHostMsg_OnLogMessage(severity, header, message));
return false;
}
-// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages on
+// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages
+// on
no sievers 2016/02/19 19:46:23 nit: formatting
Fady Samuel 2016/02/19 20:33:30 Done.
// the IO thread. This allows the UI thread in the browser process to remain
// fast at all times.
class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
@@ -74,10 +76,10 @@ class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
DCHECK(sender_);
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GpuMemoryBufferMessageFilter, message)
- IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer)
- IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle,
- OnCreateGpuMemoryBufferFromHandle)
- IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle,
+ OnCreateGpuMemoryBufferFromHandle)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
@@ -252,10 +254,67 @@ bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) {
if (ChildThreadImpl::OnMessageReceived(msg))
return true;
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
+ IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
+ IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
+ IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
+ IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState)
+#if defined(OS_ANDROID)
+ IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu);
+#endif
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ if (handled)
+ return true;
+
return gpu_channel_manager_.get() &&
gpu_channel_manager_->OnMessageReceived(msg);
}
+void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) {
+ Send(new GpuHostMsg_AddSubscription(client_id, target));
+}
+
+void GpuChildThread::ChannelEstablished(
+ const IPC::ChannelHandle& channel_handle) {
+ Send(new GpuHostMsg_ChannelEstablished(channel_handle));
+}
+
+void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
+ Send(new GpuHostMsg_DidCreateOffscreenContext(active_url));
+}
+
+void GpuChildThread::DidDestroyChannel(int client_id) {
+ Send(new GpuHostMsg_DestroyChannel(client_id));
+}
+
+void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) {
+ Send(new GpuHostMsg_DidDestroyOffscreenContext(active_url));
+}
+
+void GpuChildThread::DidLoseContext(bool offscreen,
+ gpu::error::ContextLostReason reason,
+ const GURL& active_url) {
+ Send(new GpuHostMsg_DidLoseContext(offscreen, reason, active_url));
+}
+
+void GpuChildThread::GpuMemoryUmaStats(const GPUMemoryUmaStats& params) {
+ Send(new GpuHostMsg_GpuMemoryUmaStats(params));
+}
+
+void GpuChildThread::RemoveSubscription(int32_t client_id,
+ unsigned int target) {
+ Send(new GpuHostMsg_RemoveSubscription(client_id, target));
+}
+
+void GpuChildThread::StoreShaderToDisk(int32_t client_id,
+ const std::string& key,
+ const std::string& shader) {
+ Send(new GpuHostMsg_CacheShader(client_id, key, shader));
+}
+
void GpuChildThread::OnInitialize() {
// Record initialization only after collecting the GPU info because that can
// take a significant amount of time.
@@ -281,7 +340,7 @@ void GpuChildThread::OnInitialize() {
// IPC messages before the sandbox has been enabled and all other necessary
// initialization has succeeded.
gpu_channel_manager_.reset(
- new GpuChannelManager(channel(), watchdog_thread_.get(),
+ new GpuChannelManager(this, channel(), watchdog_thread_.get(),
no sievers 2016/02/19 19:46:23 no need to pass channel() anymore
Fady Samuel 2016/02/19 20:33:30 Done.
base::ThreadTaskRunnerHandle::Get().get(),
ChildProcess::current()->io_task_runner(),
ChildProcess::current()->GetShutDownEvent(),
@@ -361,7 +420,7 @@ void GpuChildThread::OnGetVideoMemoryUsageStats() {
void GpuChildThread::OnClean() {
DVLOG(1) << "GPU: Removing all contexts";
if (gpu_channel_manager_)
- gpu_channel_manager_->LoseAllContexts();
+ gpu_channel_manager_->DestroyAllChannels();
}
void GpuChildThread::OnCrash() {
@@ -397,6 +456,48 @@ void GpuChildThread::OnGpuSwitched() {
ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
}
+void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->EstablishChannel(params);
+}
+
+void GpuChildThread::OnCloseChannel(const IPC::ChannelHandle& channel_handle) {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->CloseChannel(channel_handle);
+}
+
+void GpuChildThread::OnLoadedShader(const std::string& shader) {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->PopulateShaderCache(shader);
+}
+
+void GpuChildThread::OnDestroyGpuMemoryBuffer(
+ gfx::GpuMemoryBufferId id,
+ int client_id,
+ const gpu::SyncToken& sync_token) {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
+}
+
+void GpuChildThread::OnUpdateValueState(int client_id,
+ unsigned int target,
+ const gpu::ValueState& state) {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->UpdateValueState(client_id, target, state);
+}
+
+#if defined(OS_ANDROID)
+void GpuChildThread::OnWakeUpGpu() {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->WakeUpGpu();
+}
+#endif
+
+void GpuChildThread::OnLoseAllContexts() {
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->DestroyAllChannels();
+}
+
void GpuChildThread::BindProcessControlRequest(
mojo::InterfaceRequest<ProcessControl> request) {
DVLOG(1) << "GPU: Binding ProcessControl request";

Powered by Google App Engine
This is Rietveld 408576698