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

Unified Diff: chrome/gpu/gpu_channel.cc

Issue 6557006: Moved creation of GPU transfer buffers into the browser process.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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: chrome/gpu/gpu_channel.cc
===================================================================
--- chrome/gpu/gpu_channel.cc (revision 75655)
+++ chrome/gpu/gpu_channel.cc (working copy)
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/gpu/gpu_channel.h"
-
#if defined(OS_WIN)
#include <windows.h>
#endif
+#include "chrome/gpu/gpu_channel.h"
+
#include "base/command_line.h"
#include "base/process_util.h"
#include "base/string_util.h"
@@ -22,23 +22,25 @@
#include "ipc/ipc_channel_posix.h"
#endif
-GpuChannel::GpuChannel(GpuThread* gpu_thread, int renderer_id)
+GpuChannel::GpuChannel(GpuThread* gpu_thread,
+ int renderer_id)
: gpu_thread_(gpu_thread),
- renderer_id_(renderer_id) {
+ renderer_id_(renderer_id),
+ renderer_process_(NULL),
+ renderer_pid_(NULL) {
DCHECK(gpu_thread);
+ DCHECK(renderer_id);
const CommandLine* command_line = CommandLine::ForCurrentProcess();
log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
}
GpuChannel::~GpuChannel() {
+#if defined(OS_WIN)
+ if (renderer_process_)
+ CloseHandle(renderer_process_);
+#endif
}
-void GpuChannel::OnChannelConnected(int32 peer_pid) {
- if (!renderer_process_.Open(peer_pid)) {
- NOTREACHED();
- }
-}
-
bool GpuChannel::OnMessageReceived(const IPC::Message& message) {
if (log_messages_) {
VLOG(1) << "received message @" << &message << " on channel @" << this
@@ -57,6 +59,10 @@
gpu_thread_->RemoveChannel(renderer_id_);
}
+void GpuChannel::OnChannelConnected(int32 peer_pid) {
+ renderer_pid_ = peer_pid;
+}
+
bool GpuChannel::Send(IPC::Message* message) {
if (log_messages_) {
VLOG(1) << "sending message @" << message << " on channel @" << this
@@ -114,6 +120,7 @@
bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg)
+ IPC_MESSAGE_HANDLER(GpuChannelMsg_Initialize, OnInitialize)
IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer,
OnCreateOffscreenCommandBuffer)
IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer,
@@ -133,6 +140,15 @@
return ++last_id;
}
+void GpuChannel::OnInitialize(base::ProcessHandle renderer_process) {
+ // Initialize should only happen once.
+ DCHECK(!renderer_process_);
+
+ // Verify that the renderer has passed its own process handle.
+ if (base::GetProcId(renderer_process) == renderer_pid_)
+ renderer_process_ = renderer_process;
+}
+
void GpuChannel::OnCreateOffscreenCommandBuffer(
int32 parent_route_id,
const gfx::Size& size,

Powered by Google App Engine
This is Rietveld 408576698