summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gpu_process_host_ui_shim.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 22:54:50 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 22:54:50 +0000
commit0100b7a2759c96bfa3813c0eb5f92e9683edff2e (patch)
tree516c5b77a95bacf27a4414e75e7d8e29aaba3f3d /chrome/browser/gpu_process_host_ui_shim.cc
parentf7c6df64064e4298e45635903264fe6b2971b229 (diff)
downloadchromium_src-0100b7a2759c96bfa3813c0eb5f92e9683edff2e.zip
chromium_src-0100b7a2759c96bfa3813c0eb5f92e9683edff2e.tar.gz
chromium_src-0100b7a2759c96bfa3813c0eb5f92e9683edff2e.tar.bz2
Moved creation of GPU transfer buffers into the browser process.
Transfer buffer creation was previously done in the GPU process. This is one step required to sandbox the GPU process. Rather than the GPU process opening a renderer process's handle by PID, which can't been done when sandboxed on Windows, the browser process passes the handle to the GPU process via the renderer process. TEST=try BUG=none Review URL: http://codereview.chromium.org/6557006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gpu_process_host_ui_shim.cc')
-rw-r--r--chrome/browser/gpu_process_host_ui_shim.cc53
1 files changed, 44 insertions, 9 deletions
diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc
index 3b7781b..cb49353 100644
--- a/chrome/browser/gpu_process_host_ui_shim.cc
+++ b/chrome/browser/gpu_process_host_ui_shim.cc
@@ -167,6 +167,7 @@ RenderWidgetHostView* GpuProcessHostUIShim::ViewSurface::
GpuProcessHostUIShim::GpuProcessHostUIShim()
: host_id_(++g_last_host_id),
+ gpu_process_(NULL),
gpu_feature_flags_set_(false) {
g_hosts_by_id.AddWithID(this, host_id_);
}
@@ -206,6 +207,18 @@ void GpuProcessHostUIShim::Destroy(int host_id) {
}
// static
+void GpuProcessHostUIShim::NotifyGpuProcessLaunched(
+ int host_id,
+ base::ProcessHandle gpu_process) {
+ DCHECK(gpu_process);
+
+ GpuProcessHostUIShim* ui_shim = FromID(host_id);
+ DCHECK(ui_shim);
+
+ ui_shim->gpu_process_ = gpu_process;
+}
+
+// static
GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (host_id == 0)
@@ -230,20 +243,25 @@ namespace {
void EstablishChannelCallbackDispatcher(
GpuProcessHostUIShim::EstablishChannelCallback* callback,
const IPC::ChannelHandle& channel_handle,
+ base::ProcessHandle renderer_process_for_gpu,
const GPUInfo& gpu_info) {
scoped_ptr<GpuProcessHostUIShim::EstablishChannelCallback>
wrapped_callback(callback);
- wrapped_callback->Run(channel_handle, gpu_info);
+ wrapped_callback->Run(channel_handle, renderer_process_for_gpu, gpu_info);
}
void EstablishChannelError(
GpuProcessHostUIShim::EstablishChannelCallback* callback,
const IPC::ChannelHandle& channel_handle,
+ base::ProcessHandle renderer_process_for_gpu,
const GPUInfo& gpu_info) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableFunction(&EstablishChannelCallbackDispatcher,
- callback, channel_handle, gpu_info));
+ callback,
+ channel_handle,
+ renderer_process_for_gpu,
+ gpu_info));
}
void SynchronizeCallbackDispatcher(
@@ -284,7 +302,10 @@ void GpuProcessHostUIShim::SendOutstandingReplies() {
while (!channel_requests_.empty()) {
linked_ptr<EstablishChannelCallback> callback = channel_requests_.front();
channel_requests_.pop();
- EstablishChannelError(callback.release(), IPC::ChannelHandle(), GPUInfo());
+ EstablishChannelError(callback.release(),
+ IPC::ChannelHandle(),
+ NULL,
+ GPUInfo());
}
// Now unblock all renderers waiting for synchronization replies.
@@ -305,14 +326,15 @@ bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
}
void GpuProcessHostUIShim::EstablishGpuChannel(
- int renderer_id, EstablishChannelCallback *callback) {
+ int renderer_id,
+ EstablishChannelCallback *callback) {
DCHECK(CalledOnValidThread());
linked_ptr<EstablishChannelCallback> wrapped_callback(callback);
// If GPU features are already blacklisted, no need to establish the channel.
if (gpu_feature_flags_.flags() != 0) {
EstablishChannelError(
- wrapped_callback.release(), IPC::ChannelHandle(), GPUInfo());
+ wrapped_callback.release(), IPC::ChannelHandle(), NULL, GPUInfo());
return;
}
@@ -320,7 +342,7 @@ void GpuProcessHostUIShim::EstablishGpuChannel(
channel_requests_.push(wrapped_callback);
} else {
EstablishChannelError(
- wrapped_callback.release(), IPC::ChannelHandle(), GPUInfo());
+ wrapped_callback.release(), IPC::ChannelHandle(), NULL, GPUInfo());
}
}
@@ -399,6 +421,11 @@ const GPUInfo& GpuProcessHostUIShim::gpu_info() const {
GpuProcessHostUIShim::~GpuProcessHostUIShim() {
DCHECK(CalledOnValidThread());
g_hosts_by_id.Remove(host_id_);
+
+#if defined(OS_WIN)
+ if (gpu_process_)
+ CloseHandle(gpu_process_);
+#endif
}
bool GpuProcessHostUIShim::Init() {
@@ -449,6 +476,10 @@ bool GpuProcessHostUIShim::OnControlMessageReceived(
void GpuProcessHostUIShim::OnChannelEstablished(
const IPC::ChannelHandle& channel_handle,
const GPUInfo& gpu_info) {
+ // The GPU process should have launched at this point and this object should
+ // have been notified of its process handle.
+ DCHECK(gpu_process_);
+
uint32 max_entry_id = gpu_blacklist_->max_entry_id();
// max_entry_id can be zero if we failed to load the GPU blacklist, don't
// bother with histograms then.
@@ -488,11 +519,15 @@ void GpuProcessHostUIShim::OnChannelEstablished(
// GPU channel.
if (gpu_feature_flags_.flags() != 0) {
Send(new GpuMsg_CloseChannel(channel_handle));
- EstablishChannelError(callback.release(), IPC::ChannelHandle(), gpu_info);
+ EstablishChannelError(callback.release(),
+ IPC::ChannelHandle(),
+ NULL,
+ gpu_info);
AddCustomLogMessage(logging::LOG_WARNING, "WARNING", "GPU is blacklisted.");
- } else {
- callback->Run(channel_handle, gpu_info);
+ return;
}
+
+ callback->Run(channel_handle, gpu_process_, gpu_info);
}
void GpuProcessHostUIShim::OnSynchronizeReply() {