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

Side by Side 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: Worked around stupid compilers. 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 while (!queued_messages_.empty()) { 422 while (!queued_messages_.empty()) {
423 delete queued_messages_.front(); 423 delete queued_messages_.front();
424 queued_messages_.pop(); 424 queued_messages_.pop();
425 } 425 }
426 426
427 // This is only called on the IO thread so no race against the constructor 427 // This is only called on the IO thread so no race against the constructor
428 // for another GpuProcessHost. 428 // for another GpuProcessHost.
429 if (g_gpu_process_hosts[kind_] == this) 429 if (g_gpu_process_hosts[kind_] == this)
430 g_gpu_process_hosts[kind_] = NULL; 430 g_gpu_process_hosts[kind_] = NULL;
431 431
432 // If there are any remaining offscreen contexts at the point the
433 // GPU process exits, assume something went wrong, and block their
434 // URLs from accessing client 3D APIs without prompting.
435 BlockLiveOffscreenContexts();
436
432 BrowserThread::PostTask(BrowserThread::UI, 437 BrowserThread::PostTask(BrowserThread::UI,
433 FROM_HERE, 438 FROM_HERE,
434 base::Bind(&GpuProcessHostUIShim::Destroy, host_id_)); 439 base::Bind(&GpuProcessHostUIShim::Destroy, host_id_));
435 } 440 }
436 441
437 bool GpuProcessHost::Init() { 442 bool GpuProcessHost::Init() {
438 init_start_time_ = base::TimeTicks::Now(); 443 init_start_time_ = base::TimeTicks::Now();
439 444
440 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess"); 445 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess");
441 446
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 505 }
501 506
502 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { 507 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
503 DCHECK(CalledOnValidThread()); 508 DCHECK(CalledOnValidThread());
504 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) 509 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
505 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) 510 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized)
506 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) 511 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished)
507 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) 512 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated)
508 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) 513 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer)
509 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) 514 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated)
515 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext,
516 OnDidCreateOffscreenContext)
517 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext)
518 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext,
519 OnDidDestroyOffscreenContext)
510 #if defined(OS_MACOSX) 520 #if defined(OS_MACOSX)
511 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, 521 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
512 OnAcceleratedSurfaceBuffersSwapped) 522 OnAcceleratedSurfaceBuffersSwapped)
513 #endif 523 #endif
514 #if defined(OS_WIN) 524 #if defined(OS_WIN)
515 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, 525 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
516 OnAcceleratedSurfaceBuffersSwapped) 526 OnAcceleratedSurfaceBuffersSwapped)
517 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, 527 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer,
518 OnAcceleratedSurfacePostSubBuffer) 528 OnAcceleratedSurfacePostSubBuffer)
519 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, 529 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 void GpuProcessHost::OnImageCreated(const gfx::Size size) { 689 void GpuProcessHost::OnImageCreated(const gfx::Size size) {
680 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); 690 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated");
681 691
682 if (!create_image_requests_.empty()) { 692 if (!create_image_requests_.empty()) {
683 CreateImageCallback callback = create_image_requests_.front(); 693 CreateImageCallback callback = create_image_requests_.front();
684 create_image_requests_.pop(); 694 create_image_requests_.pop();
685 callback.Run(size); 695 callback.Run(size);
686 } 696 }
687 } 697 }
688 698
699 void GpuProcessHost::OnDidCreateOffscreenContext(
700 const GURL& url) {
701 urls_with_live_offscreen_contexts_.insert(url);
702 }
703
704 void GpuProcessHost::OnDidLoseContext(bool offscreen,
705 gpu::error::ContextLostReason reason,
706 const GURL& url) {
707 // TODO(kbr): would be nice to see the "offscreen" flag too.
708 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext",
709 "reason", reason,
710 "url",
711 url.possibly_invalid_spec());
712
713 if (!offscreen || url.is_empty()) {
714 // Assume that the loss of the compositor's or accelerated canvas'
715 // context is a serious event and blame the loss on all live
716 // offscreen contexts. This more robustly handles situations where
717 // the GPU process may not actually detect the context loss in the
718 // offscreen context.
719 BlockLiveOffscreenContexts();
720 return;
721 }
722
723 // Initialization only needed because compiler is stupid.
724 GpuDataManagerImpl::DomainGuilt guilt =
725 GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
726
727 switch (reason) {
728 case gpu::error::kGuilty:
729 guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
730 break;
731 case gpu::error::kUnknown:
732 guilt = GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
733 break;
734 case gpu::error::kInnocent:
735 return;
736 }
737
738 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
739 url, guilt);
740 }
741
742 void GpuProcessHost::OnDidDestroyOffscreenContext(
743 const GURL& url) {
744 urls_with_live_offscreen_contexts_.erase(url);
745 }
746
689 #if defined(OS_MACOSX) 747 #if defined(OS_MACOSX)
690 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( 748 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
691 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { 749 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
692 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); 750 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped");
693 751
694 gfx::PluginWindowHandle handle = 752 gfx::PluginWindowHandle handle =
695 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); 753 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id);
696 // Compositor window is always gfx::kNullPluginWindow. 754 // Compositor window is always gfx::kNullPluginWindow.
697 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no 755 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no
698 // plugin windows. 756 // plugin windows.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 void GpuProcessHost::CreateCommandBufferError( 1039 void GpuProcessHost::CreateCommandBufferError(
982 const CreateCommandBufferCallback& callback, int32 route_id) { 1040 const CreateCommandBufferCallback& callback, int32 route_id) {
983 callback.Run(route_id); 1041 callback.Run(route_id);
984 } 1042 }
985 1043
986 void GpuProcessHost::CreateImageError( 1044 void GpuProcessHost::CreateImageError(
987 const CreateImageCallback& callback, const gfx::Size size) { 1045 const CreateImageCallback& callback, const gfx::Size size) {
988 callback.Run(size); 1046 callback.Run(size);
989 } 1047 }
990 1048
1049 void GpuProcessHost::BlockLiveOffscreenContexts() {
1050 for (std::multiset<GURL>::iterator iter =
1051 urls_with_live_offscreen_contexts_.begin();
1052 iter != urls_with_live_offscreen_contexts_.end(); ++iter) {
1053 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
1054 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN);
1055 }
1056 }
1057
991 } // namespace content 1058 } // namespace content
OLDNEW
« 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