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

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 7129006: Make EstablishGpuChannel synchronous. Remove obsolete Synchronize msg. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix indentation and rebase Created 9 years, 6 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return true; 309 return true;
310 } 310 }
311 311
312 return BrowserChildProcessHost::Send(msg); 312 return BrowserChildProcessHost::Send(msg);
313 } 313 }
314 314
315 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { 315 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
316 DCHECK(CalledOnValidThread()); 316 DCHECK(CalledOnValidThread());
317 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) 317 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
318 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) 318 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished)
319 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply)
320 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) 319 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated)
321 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) 320 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer)
322 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, 321 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
323 OnGraphicsInfoCollected) 322 OnGraphicsInfoCollected)
324 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) 323 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message))
325 IPC_END_MESSAGE_MAP() 324 IPC_END_MESSAGE_MAP()
326 325
327 return true; 326 return true;
328 } 327 }
329 328
(...skipping 21 matching lines...) Expand all
351 350
352 if (Send(new GpuMsg_EstablishChannel(renderer_id))) { 351 if (Send(new GpuMsg_EstablishChannel(renderer_id))) {
353 channel_requests_.push(wrapped_callback); 352 channel_requests_.push(wrapped_callback);
354 } else { 353 } else {
355 EstablishChannelError( 354 EstablishChannelError(
356 wrapped_callback.release(), IPC::ChannelHandle(), 355 wrapped_callback.release(), IPC::ChannelHandle(),
357 base::kNullProcessHandle, GPUInfo()); 356 base::kNullProcessHandle, GPUInfo());
358 } 357 }
359 } 358 }
360 359
361 void GpuProcessHost::Synchronize(SynchronizeCallback* callback) {
362 DCHECK(CalledOnValidThread());
363 linked_ptr<SynchronizeCallback> wrapped_callback(callback);
364
365 if (Send(new GpuMsg_Synchronize())) {
366 synchronize_requests_.push(wrapped_callback);
367 } else {
368 SynchronizeError(wrapped_callback.release());
369 }
370 }
371
372 void GpuProcessHost::CreateViewCommandBuffer( 360 void GpuProcessHost::CreateViewCommandBuffer(
373 gfx::PluginWindowHandle compositing_surface, 361 gfx::PluginWindowHandle compositing_surface,
374 int32 render_view_id, 362 int32 render_view_id,
375 int32 renderer_id, 363 int32 renderer_id,
376 const GPUCreateCommandBufferConfig& init_params, 364 const GPUCreateCommandBufferConfig& init_params,
377 CreateCommandBufferCallback* callback) { 365 CreateCommandBufferCallback* callback) {
378 DCHECK(CalledOnValidThread()); 366 DCHECK(CalledOnValidThread());
379 linked_ptr<CreateCommandBufferCallback> wrapped_callback(callback); 367 linked_ptr<CreateCommandBufferCallback> wrapped_callback(callback);
380 368
381 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) 369 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 logging::LOG_WARNING, 416 logging::LOG_WARNING,
429 "WARNING", 417 "WARNING",
430 "Hardware acceleration is unavailable.")); 418 "Hardware acceleration is unavailable."));
431 return; 419 return;
432 } 420 }
433 421
434 callback->Run( 422 callback->Run(
435 channel_handle, gpu_process_, GpuDataManager::GetInstance()->gpu_info()); 423 channel_handle, gpu_process_, GpuDataManager::GetInstance()->gpu_info());
436 } 424 }
437 425
438 void GpuProcessHost::OnSynchronizeReply() {
439 // Guard against race conditions in abrupt GPU process termination.
440 if (!synchronize_requests_.empty()) {
441 linked_ptr<SynchronizeCallback> callback(synchronize_requests_.front());
442 synchronize_requests_.pop();
443 callback->Run();
444 }
445 }
446
447 void GpuProcessHost::OnCommandBufferCreated(const int32 route_id) { 426 void GpuProcessHost::OnCommandBufferCreated(const int32 route_id) {
448 if (!create_command_buffer_requests_.empty()) { 427 if (!create_command_buffer_requests_.empty()) {
449 linked_ptr<CreateCommandBufferCallback> callback = 428 linked_ptr<CreateCommandBufferCallback> callback =
450 create_command_buffer_requests_.front(); 429 create_command_buffer_requests_.front();
451 create_command_buffer_requests_.pop(); 430 create_command_buffer_requests_.pop();
452 if (route_id == MSG_ROUTING_NONE) 431 if (route_id == MSG_ROUTING_NONE)
453 CreateCommandBufferError(callback.release(), route_id); 432 CreateCommandBufferError(callback.release(), route_id);
454 else 433 else
455 callback->Run(route_id); 434 callback->Run(route_id);
456 } 435 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 void GpuProcessHost::SendOutstandingReplies() { 564 void GpuProcessHost::SendOutstandingReplies() {
586 // First send empty channel handles for all EstablishChannel requests. 565 // First send empty channel handles for all EstablishChannel requests.
587 while (!channel_requests_.empty()) { 566 while (!channel_requests_.empty()) {
588 linked_ptr<EstablishChannelCallback> callback = channel_requests_.front(); 567 linked_ptr<EstablishChannelCallback> callback = channel_requests_.front();
589 channel_requests_.pop(); 568 channel_requests_.pop();
590 EstablishChannelError(callback.release(), 569 EstablishChannelError(callback.release(),
591 IPC::ChannelHandle(), 570 IPC::ChannelHandle(),
592 base::kNullProcessHandle, 571 base::kNullProcessHandle,
593 GPUInfo()); 572 GPUInfo());
594 } 573 }
595
596 // Now unblock all renderers waiting for synchronization replies.
597 while (!synchronize_requests_.empty()) {
598 linked_ptr<SynchronizeCallback> callback = synchronize_requests_.front();
599 synchronize_requests_.pop();
600 SynchronizeError(callback.release());
601 }
602 } 574 }
603 575
604 void GpuProcessHost::EstablishChannelError( 576 void GpuProcessHost::EstablishChannelError(
605 EstablishChannelCallback* callback, 577 EstablishChannelCallback* callback,
606 const IPC::ChannelHandle& channel_handle, 578 const IPC::ChannelHandle& channel_handle,
607 base::ProcessHandle renderer_process_for_gpu, 579 base::ProcessHandle renderer_process_for_gpu,
608 const GPUInfo& gpu_info) { 580 const GPUInfo& gpu_info) {
609 scoped_ptr<EstablishChannelCallback> wrapped_callback(callback); 581 scoped_ptr<EstablishChannelCallback> wrapped_callback(callback);
610 wrapped_callback->Run(channel_handle, renderer_process_for_gpu, gpu_info); 582 wrapped_callback->Run(channel_handle, renderer_process_for_gpu, gpu_info);
611 } 583 }
612 584
613 void GpuProcessHost::CreateCommandBufferError( 585 void GpuProcessHost::CreateCommandBufferError(
614 CreateCommandBufferCallback* callback, int32 route_id) { 586 CreateCommandBufferCallback* callback, int32 route_id) {
615 scoped_ptr<GpuProcessHost::CreateCommandBufferCallback> 587 scoped_ptr<GpuProcessHost::CreateCommandBufferCallback>
616 wrapped_callback(callback); 588 wrapped_callback(callback);
617 callback->Run(route_id); 589 callback->Run(route_id);
618 } 590 }
619
620 void GpuProcessHost::SynchronizeError(SynchronizeCallback* callback) {
621 scoped_ptr<SynchronizeCallback> wrapped_callback(callback);
622 wrapped_callback->Run();
623 }
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/renderer_host/gpu_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698