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

Side by Side Diff: content/common/gpu/gpu_channel.cc

Issue 10081018: Revert 132218 - Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_channel.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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
(...skipping 22 matching lines...) Expand all
33 const int64 kHandleMoreWorkPeriodBusyMs = 1; 33 const int64 kHandleMoreWorkPeriodBusyMs = 1;
34 } 34 }
35 35
36 GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, 36 GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager,
37 GpuWatchdog* watchdog, 37 GpuWatchdog* watchdog,
38 gfx::GLShareGroup* share_group, 38 gfx::GLShareGroup* share_group,
39 int client_id, 39 int client_id,
40 bool software) 40 bool software)
41 : gpu_channel_manager_(gpu_channel_manager), 41 : gpu_channel_manager_(gpu_channel_manager),
42 client_id_(client_id), 42 client_id_(client_id),
43 renderer_process_(base::kNullProcessHandle),
44 renderer_pid_(base::kNullProcessId),
43 share_group_(share_group ? share_group : new gfx::GLShareGroup), 45 share_group_(share_group ? share_group : new gfx::GLShareGroup),
44 watchdog_(watchdog), 46 watchdog_(watchdog),
45 software_(software), 47 software_(software),
46 handle_messages_scheduled_(false), 48 handle_messages_scheduled_(false),
47 processed_get_state_fast_(false), 49 processed_get_state_fast_(false),
48 num_contexts_preferring_discrete_gpu_(0), 50 num_contexts_preferring_discrete_gpu_(0),
49 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 51 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
50 DCHECK(gpu_channel_manager); 52 DCHECK(gpu_channel_manager);
51 DCHECK(client_id); 53 DCHECK(client_id);
52 54
53 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); 55 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu");
54 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 56 const CommandLine* command_line = CommandLine::ForCurrentProcess();
55 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); 57 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
56 disallowed_features_.multisampling = 58 disallowed_features_.multisampling =
57 command_line->HasSwitch(switches::kDisableGLMultisampling); 59 command_line->HasSwitch(switches::kDisableGLMultisampling);
58 disallowed_features_.driver_bug_workarounds = 60 disallowed_features_.driver_bug_workarounds =
59 command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds); 61 command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds);
60 } 62 }
61 63
62 GpuChannel::~GpuChannel() { 64 GpuChannel::~GpuChannel() {
65 #if defined(OS_WIN)
66 if (renderer_process_)
67 CloseHandle(renderer_process_);
68 #endif
63 } 69 }
64 70
65 bool GpuChannel::OnMessageReceived(const IPC::Message& message) { 71 bool GpuChannel::OnMessageReceived(const IPC::Message& message) {
66 if (log_messages_) { 72 if (log_messages_) {
67 DVLOG(1) << "received message @" << &message << " on channel @" << this 73 DVLOG(1) << "received message @" << &message << " on channel @" << this
68 << " with type " << message.type(); 74 << " with type " << message.type();
69 } 75 }
70 76
71 // Control messages are not deferred and can be handled out of order with 77 // Control messages are not deferred and can be handled out of order with
72 // respect to routed ones. 78 // respect to routed ones.
(...skipping 27 matching lines...) Expand all
100 106
101 OnScheduled(); 107 OnScheduled();
102 108
103 return true; 109 return true;
104 } 110 }
105 111
106 void GpuChannel::OnChannelError() { 112 void GpuChannel::OnChannelError() {
107 gpu_channel_manager_->RemoveChannel(client_id_); 113 gpu_channel_manager_->RemoveChannel(client_id_);
108 } 114 }
109 115
116 void GpuChannel::OnChannelConnected(int32 peer_pid) {
117 renderer_pid_ = peer_pid;
118 }
119
110 bool GpuChannel::Send(IPC::Message* message) { 120 bool GpuChannel::Send(IPC::Message* message) {
111 // The GPU process must never send a synchronous IPC message to the renderer 121 // The GPU process must never send a synchronous IPC message to the renderer
112 // process. This could result in deadlock. 122 // process. This could result in deadlock.
113 DCHECK(!message->is_sync()); 123 DCHECK(!message->is_sync());
114 if (log_messages_) { 124 if (log_messages_) {
115 DVLOG(1) << "sending message @" << message << " on channel @" << this 125 DVLOG(1) << "sending message @" << message << " on channel @" << this
116 << " with type " << message->type(); 126 << " with type " << message->type();
117 } 127 }
118 128
119 if (!channel_.get()) { 129 if (!channel_.get()) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 204
195 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { 205 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) {
196 return stubs_.Lookup(route_id); 206 return stubs_.Lookup(route_id);
197 } 207 }
198 208
199 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { 209 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
200 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers 210 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers
201 // here. This is so the reply can be delayed if the scheduler is unscheduled. 211 // here. This is so the reply can be delayed if the scheduler is unscheduled.
202 bool handled = true; 212 bool handled = true;
203 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) 213 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg)
214 IPC_MESSAGE_HANDLER(GpuChannelMsg_Initialize, OnInitialize)
204 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_CreateOffscreenCommandBuffer, 215 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_CreateOffscreenCommandBuffer,
205 OnCreateOffscreenCommandBuffer) 216 OnCreateOffscreenCommandBuffer)
206 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_DestroyCommandBuffer, 217 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_DestroyCommandBuffer,
207 OnDestroyCommandBuffer) 218 OnDestroyCommandBuffer)
208 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_WillGpuSwitchOccur, 219 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_WillGpuSwitchOccur,
209 OnWillGpuSwitchOccur) 220 OnWillGpuSwitchOccur)
210 IPC_MESSAGE_HANDLER(GpuChannelMsg_CloseChannel, OnCloseChannel) 221 IPC_MESSAGE_HANDLER(GpuChannelMsg_CloseChannel, OnCloseChannel)
211 IPC_MESSAGE_UNHANDLED(handled = false) 222 IPC_MESSAGE_UNHANDLED(handled = false)
212 IPC_END_MESSAGE_MAP() 223 IPC_END_MESSAGE_MAP()
213 DCHECK(handled) << msg.type(); 224 DCHECK(handled) << msg.type();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 305 }
295 306
296 void GpuChannel::RemoveRoute(int32 route_id) { 307 void GpuChannel::RemoveRoute(int32 route_id) {
297 router_.RemoveRoute(route_id); 308 router_.RemoveRoute(route_id);
298 } 309 }
299 310
300 bool GpuChannel::ShouldPreferDiscreteGpu() const { 311 bool GpuChannel::ShouldPreferDiscreteGpu() const {
301 return num_contexts_preferring_discrete_gpu_ > 0; 312 return num_contexts_preferring_discrete_gpu_ > 0;
302 } 313 }
303 314
315 void GpuChannel::OnInitialize(base::ProcessHandle renderer_process) {
316 // Initialize should only happen once.
317 DCHECK(!renderer_process_);
318
319 // Verify that the renderer has passed its own process handle.
320 if (base::GetProcId(renderer_process) == renderer_pid_)
321 renderer_process_ = renderer_process;
322 }
323
304 void GpuChannel::OnCreateOffscreenCommandBuffer( 324 void GpuChannel::OnCreateOffscreenCommandBuffer(
305 const gfx::Size& size, 325 const gfx::Size& size,
306 const GPUCreateCommandBufferConfig& init_params, 326 const GPUCreateCommandBufferConfig& init_params,
307 IPC::Message* reply_message) { 327 IPC::Message* reply_message) {
308 int32 route_id = MSG_ROUTING_NONE; 328 int32 route_id = MSG_ROUTING_NONE;
309 329
310 content::GetContentClient()->SetActiveURL(init_params.active_url); 330 content::GetContentClient()->SetActiveURL(init_params.active_url);
311 #if defined(ENABLE_GPU) 331 #if defined(ENABLE_GPU)
312 WillCreateCommandBuffer(init_params.gpu_preference); 332 WillCreateCommandBuffer(init_params.gpu_preference);
313 333
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 444
425 #if defined(OS_POSIX) 445 #if defined(OS_POSIX)
426 int GpuChannel::TakeRendererFileDescriptor() { 446 int GpuChannel::TakeRendererFileDescriptor() {
427 if (!channel_.get()) { 447 if (!channel_.get()) {
428 NOTREACHED(); 448 NOTREACHED();
429 return -1; 449 return -1;
430 } 450 }
431 return channel_->TakeClientFileDescriptor(); 451 return channel_->TakeClientFileDescriptor();
432 } 452 }
433 #endif // defined(OS_POSIX) 453 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.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