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

Unified Diff: content/browser/gpu/gpu_process_host.cc

Issue 11434072: Send notification from GPU process to browser process of offscreen context creation and destruction… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed apatrick's review feedback. Renamed containing_document_url. Created 8 years 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
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/gpu_process_host.cc
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 8de01641562c05bfe762f3aa058139fc03540287..e111fddffbae080de2292c9002dcce4974962446 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -429,6 +429,11 @@ GpuProcessHost::~GpuProcessHost() {
if (g_gpu_process_hosts[kind_] == this)
g_gpu_process_hosts[kind_] = NULL;
+ // If there are any remaining offscreen contexts at the point the
+ // GPU process exits, assume something went wrong, and block their
+ // URLs from accessing client 3D APIs without prompting.
+ BlockLiveOffscreenContexts();
Ken Russell (switch to Gerrit) 2012/12/04 21:16:10 This is the change to the GpuProcessHost destructo
apatrick_chromium 2012/12/04 21:24:23 Okay I'm blind then.
+
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(&GpuProcessHostUIShim::Destroy, host_id_));
@@ -507,6 +512,11 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated)
IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer)
IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext,
+ OnDidCreateOffscreenContext)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext,
+ OnDidDestroyOffscreenContext)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
@@ -686,6 +696,52 @@ void GpuProcessHost::OnImageCreated(const gfx::Size size) {
}
}
+void GpuProcessHost::OnDidCreateOffscreenContext(
+ const GURL& url) {
+ urls_with_live_offscreen_contexts_.insert(url);
+}
+
+void GpuProcessHost::OnDidLoseContext(bool offscreen,
+ gpu::error::ContextLostReason reason,
+ const GURL& url) {
+ // TODO(kbr): would be nice to see the "offscreen" flag too.
+ TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext",
+ "reason", reason,
+ "url",
+ url.possibly_invalid_spec());
+
+ if (!offscreen || url.is_empty()) {
+ // Assume that the loss of the compositor's or accelerated canvas'
+ // context is a serious event and blame the loss on all live
+ // offscreen contexts. This more robustly handles situations where
+ // the GPU process may not actually detect the context loss in the
+ // offscreen context.
+ BlockLiveOffscreenContexts();
+ return;
+ }
+
+ GpuDataManagerImpl::DomainGuilt guilt;
+
+ switch (reason) {
+ case gpu::error::kGuilty:
+ guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
+ break;
+ case gpu::error::kUnknown:
+ guilt = GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
+ break;
+ case gpu::error::kInnocent:
+ return;
+ }
+
+ GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
+ url, guilt);
+}
+
+void GpuProcessHost::OnDidDestroyOffscreenContext(
+ const GURL& url) {
+ urls_with_live_offscreen_contexts_.erase(url);
+}
+
#if defined(OS_MACOSX)
void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
@@ -988,4 +1044,13 @@ void GpuProcessHost::CreateImageError(
callback.Run(size);
}
+void GpuProcessHost::BlockLiveOffscreenContexts() {
+ for (std::multiset<GURL>::iterator iter =
+ urls_with_live_offscreen_contexts_.begin();
+ iter != urls_with_live_offscreen_contexts_.end(); ++iter) {
+ GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
+ *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN);
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698