OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/gpu/gpu_channel.h" | 5 #include "chrome/gpu/gpu_channel.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/lock.h" | 12 #include "base/lock.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "chrome/common/child_process.h" | 15 #include "chrome/common/child_process.h" |
16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/gpu_messages.h" | 18 #include "chrome/common/gpu_messages.h" |
19 #include "chrome/gpu/gpu_thread.h" | 19 #include "chrome/gpu/gpu_thread.h" |
20 #include "chrome/gpu/gpu_video_service.h" | 20 #include "chrome/gpu/gpu_video_service.h" |
21 | 21 |
22 #if defined(OS_POSIX) | 22 #if defined(OS_POSIX) |
23 #include "ipc/ipc_channel_posix.h" | 23 #include "ipc/ipc_channel_posix.h" |
24 #endif | 24 #endif |
25 | 25 |
26 GpuChannel::GpuChannel(int renderer_id) | 26 GpuChannel::GpuChannel(GpuThread* gpu_thread, int renderer_id) |
27 : renderer_id_(renderer_id) { | 27 : gpu_thread_(gpu_thread), |
| 28 renderer_id_(renderer_id) { |
| 29 DCHECK(gpu_thread); |
28 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 30 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
29 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 31 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
30 } | 32 } |
31 | 33 |
32 GpuChannel::~GpuChannel() { | 34 GpuChannel::~GpuChannel() { |
33 } | 35 } |
34 | 36 |
35 void GpuChannel::OnChannelConnected(int32 peer_pid) { | 37 void GpuChannel::OnChannelConnected(int32 peer_pid) { |
36 if (!renderer_process_.Open(peer_pid)) { | 38 if (!renderer_process_.Open(peer_pid)) { |
37 NOTREACHED(); | 39 NOTREACHED(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 std::string channel_name = GetChannelName(); | 249 std::string channel_name = GetChannelName(); |
248 channel_.reset(new IPC::SyncChannel( | 250 channel_.reset(new IPC::SyncChannel( |
249 channel_name, IPC::Channel::MODE_SERVER, this, | 251 channel_name, IPC::Channel::MODE_SERVER, this, |
250 ChildProcess::current()->io_message_loop(), false, | 252 ChildProcess::current()->io_message_loop(), false, |
251 ChildProcess::current()->GetShutDownEvent())); | 253 ChildProcess::current()->GetShutDownEvent())); |
252 | 254 |
253 return true; | 255 return true; |
254 } | 256 } |
255 | 257 |
256 std::string GpuChannel::GetChannelName() { | 258 std::string GpuChannel::GetChannelName() { |
257 return StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id_); | 259 return StringPrintf("%d.r%d.gpu", base::GetCurrentProcId(), renderer_id_); |
258 } | 260 } |
259 | 261 |
260 #if defined(OS_POSIX) | 262 #if defined(OS_POSIX) |
261 int GpuChannel::GetRendererFileDescriptor() { | 263 int GpuChannel::GetRendererFileDescriptor() { |
262 int fd = -1; | 264 int fd = -1; |
263 if (channel_.get()) { | 265 if (channel_.get()) { |
264 fd = channel_->GetClientFileDescriptor(); | 266 fd = channel_->GetClientFileDescriptor(); |
265 } | 267 } |
266 return fd; | 268 return fd; |
267 } | 269 } |
268 #endif // defined(OS_POSIX) | 270 #endif // defined(OS_POSIX) |
269 | 271 |
OLD | NEW |