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

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

Powered by Google App Engine
This is Rietveld 408576698