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

Side by Side Diff: chrome/browser/gpu_process_host.cc

Issue 5612002: Blacklist bad GPU drivers: currenly we disable all gpu related features if th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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) 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/browser/gpu_process_host.h" 5 #include "chrome/browser/gpu_process_host.h"
6 6
7 #include "app/app_switches.h" 7 #include "app/app_switches.h"
8 #include "app/resource_bundle.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/string_piece.h"
10 #include "base/thread.h" 12 #include "base/thread.h"
11 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_thread.h" 14 #include "chrome/browser/browser_thread.h"
13 #include "chrome/browser/gpu_process_host_ui_shim.h" 15 #include "chrome/browser/gpu_process_host_ui_shim.h"
14 #include "chrome/browser/renderer_host/render_view_host.h" 16 #include "chrome/browser/renderer_host/render_view_host.h"
15 #include "chrome/browser/renderer_host/render_widget_host_view.h" 17 #include "chrome/browser/renderer_host/render_widget_host_view.h"
16 #include "chrome/browser/renderer_host/resource_message_filter.h" 18 #include "chrome/browser/renderer_host/resource_message_filter.h"
17 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" 19 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
18 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/gpu_info.h" 21 #include "chrome/common/gpu_info.h"
20 #include "chrome/common/gpu_messages.h" 22 #include "chrome/common/gpu_messages.h"
21 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
24 #include "grit/browser_resources.h"
22 #include "ipc/ipc_channel_handle.h" 25 #include "ipc/ipc_channel_handle.h"
23 #include "ipc/ipc_switches.h" 26 #include "ipc/ipc_switches.h"
24 #include "media/base/media_switches.h" 27 #include "media/base/media_switches.h"
25 28
26 #if defined(OS_LINUX) 29 #if defined(OS_LINUX)
27 #include <gdk/gdkwindow.h> 30 #include <gdk/gdkwindow.h>
28 #include <gdk/gdkx.h> 31 #include <gdk/gdkx.h>
29 #include "app/x11_util.h" 32 #include "app/x11_util.h"
30 #include "gfx/gtk_native_view_id_manager.h" 33 #include "gfx/gtk_native_view_id_manager.h"
31 #include "gfx/size.h" 34 #include "gfx/size.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 bool GpuProcessHost::EnsureInitialized() { 94 bool GpuProcessHost::EnsureInitialized() {
92 if (!initialized_) { 95 if (!initialized_) {
93 initialized_ = true; 96 initialized_ = true;
94 initialized_successfully_ = Init(); 97 initialized_successfully_ = Init();
95 } 98 }
96 return initialized_successfully_; 99 return initialized_successfully_;
97 } 100 }
98 101
99 bool GpuProcessHost::Init() { 102 bool GpuProcessHost::Init() {
103 if (!LoadGpuBlacklist())
104 return false;
105
100 if (!CreateChannel()) 106 if (!CreateChannel())
101 return false; 107 return false;
102 108
103 if (!CanLaunchGpuProcess()) 109 if (!CanLaunchGpuProcess())
104 return false; 110 return false;
105 111
106 return LaunchGpuProcess(); 112 return LaunchGpuProcess();
107 } 113 }
108 114
109 // static 115 // static
(...skipping 23 matching lines...) Expand all
133 RouteOnUIThread(message); 139 RouteOnUIThread(message);
134 } 140 }
135 141
136 void GpuProcessHost::EstablishGpuChannel(int renderer_id, 142 void GpuProcessHost::EstablishGpuChannel(int renderer_id,
137 ResourceMessageFilter* filter) { 143 ResourceMessageFilter* filter) {
138 DCHECK(CalledOnValidThread()); 144 DCHECK(CalledOnValidThread());
139 145
140 if (Send(new GpuMsg_EstablishChannel(renderer_id))) { 146 if (Send(new GpuMsg_EstablishChannel(renderer_id))) {
141 sent_requests_.push(ChannelRequest(filter)); 147 sent_requests_.push(ChannelRequest(filter));
142 } else { 148 } else {
143 SendEstablishChannelReply(IPC::ChannelHandle(), GPUInfo(), filter); 149 SendEstablishChannelReply(IPC::ChannelHandle(), GPUInfo(),
150 GpuFeatureFlags(), filter);
144 } 151 }
145 } 152 }
146 153
147 void GpuProcessHost::Synchronize(IPC::Message* reply, 154 void GpuProcessHost::Synchronize(IPC::Message* reply,
148 ResourceMessageFilter* filter) { 155 ResourceMessageFilter* filter) {
149 DCHECK(CalledOnValidThread()); 156 DCHECK(CalledOnValidThread());
150 157
151 if (Send(new GpuMsg_Synchronize())) { 158 if (Send(new GpuMsg_Synchronize())) {
152 queued_synchronization_replies_.push(SynchronizationRequest(reply, filter)); 159 queued_synchronization_replies_.push(SynchronizationRequest(reply, filter));
153 } else { 160 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // If the IO thread does not handle the message then automatically route it 199 // If the IO thread does not handle the message then automatically route it
193 // to the UI thread. The UI thread will report an error if it does not 200 // to the UI thread. The UI thread will report an error if it does not
194 // handle it. 201 // handle it.
195 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) 202 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message))
196 IPC_END_MESSAGE_MAP() 203 IPC_END_MESSAGE_MAP()
197 } 204 }
198 205
199 void GpuProcessHost::OnChannelEstablished( 206 void GpuProcessHost::OnChannelEstablished(
200 const IPC::ChannelHandle& channel_handle, 207 const IPC::ChannelHandle& channel_handle,
201 const GPUInfo& gpu_info) { 208 const GPUInfo& gpu_info) {
209 GpuFeatureFlags gpu_feature_flags = gpu_blacklist_->DetermineGpuFeatureFlags(
210 GpuBlacklist::kOsAny, NULL, gpu_info);
202 const ChannelRequest& request = sent_requests_.front(); 211 const ChannelRequest& request = sent_requests_.front();
203 SendEstablishChannelReply(channel_handle, gpu_info, request.filter); 212 SendEstablishChannelReply(
213 channel_handle, gpu_info, gpu_feature_flags, request.filter);
204 sent_requests_.pop(); 214 sent_requests_.pop();
205 } 215 }
206 216
207 void GpuProcessHost::OnSynchronizeReply() { 217 void GpuProcessHost::OnSynchronizeReply() {
208 const SynchronizationRequest& request = 218 const SynchronizationRequest& request =
209 queued_synchronization_replies_.front(); 219 queued_synchronization_replies_.front();
210 SendSynchronizationReply(request.reply, request.filter); 220 SendSynchronizationReply(request.reply, request.filter);
211 queued_synchronization_replies_.pop(); 221 queued_synchronization_replies_.pop();
212 } 222 }
213 223
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 BrowserThread::UI, FROM_HERE, 443 BrowserThread::UI, FROM_HERE,
434 NewRunnableFunction(&CreateCompositorHostWindowDispatcher, 444 NewRunnableFunction(&CreateCompositorHostWindowDispatcher,
435 renderer_id, render_view_id, reply_message)); 445 renderer_id, render_view_id, reply_message));
436 } 446 }
437 447
438 #endif 448 #endif
439 449
440 void GpuProcessHost::SendEstablishChannelReply( 450 void GpuProcessHost::SendEstablishChannelReply(
441 const IPC::ChannelHandle& channel, 451 const IPC::ChannelHandle& channel,
442 const GPUInfo& gpu_info, 452 const GPUInfo& gpu_info,
453 const GpuFeatureFlags& gpu_feature_flags,
443 ResourceMessageFilter* filter) { 454 ResourceMessageFilter* filter) {
444 ViewMsg_GpuChannelEstablished* message = 455 ViewMsg_GpuChannelEstablished* message =
445 new ViewMsg_GpuChannelEstablished(channel, gpu_info); 456 new ViewMsg_GpuChannelEstablished(channel, gpu_info, gpu_feature_flags);
446 // If the renderer process is performing synchronous initialization, 457 // If the renderer process is performing synchronous initialization,
447 // it needs to handle this message before receiving the reply for 458 // it needs to handle this message before receiving the reply for
448 // the synchronous ViewHostMsg_SynchronizeGpu message. 459 // the synchronous ViewHostMsg_SynchronizeGpu message.
449 message->set_unblock(true); 460 message->set_unblock(true);
450 filter->Send(message); 461 filter->Send(message);
451 } 462 }
452 463
453 // Sends the response for synchronization request to the renderer. 464 // Sends the response for synchronization request to the renderer.
454 void GpuProcessHost::SendSynchronizationReply( 465 void GpuProcessHost::SendSynchronizationReply(
455 IPC::Message* reply, 466 IPC::Message* reply,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 false, // Never use the zygote (GPU plugin can't be sandboxed). 541 false, // Never use the zygote (GPU plugin can't be sandboxed).
531 base::environment_vector(), 542 base::environment_vector(),
532 #endif 543 #endif
533 cmd_line); 544 cmd_line);
534 545
535 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", 546 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents",
536 kLaunched, kGPUProcessLifetimeEvent_Max); 547 kLaunched, kGPUProcessLifetimeEvent_Max);
537 return true; 548 return true;
538 } 549 }
539 550
551 bool GpuProcessHost::LoadGpuBlacklist() {
552 if (gpu_blacklist_.get() != NULL)
553 return true;
554 static const base::StringPiece gpu_blacklist_json(
555 ResourceBundle::GetSharedInstance().GetRawDataResource(
556 IDR_GPU_BLACKLIST));
557 GpuBlacklist* blacklist = new GpuBlacklist();
558 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
559 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) ||
560 blacklist->LoadGpuBlacklist(gpu_blacklist_json.as_string())) {
561 gpu_blacklist_.reset(blacklist);
562 return true;
563 }
564 delete blacklist;
565 return false;
566 }
567
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698