Chromium Code Reviews| 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/browser/gpu_process_host_ui_shim.h" | 5 #include "chrome/browser/gpu_process_host_ui_shim.h" |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/gfx/gl/gl_implementation.h" | 8 #include "app/gfx/gl/gl_implementation.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
| 12 #include "chrome/browser/gpu_blacklist.h" | 12 #include "chrome/browser/gpu_blacklist.h" |
| 13 #include "chrome/browser/gpu_process_host.h" | 13 #include "chrome/browser/gpu_process_host.h" |
| 14 #include "chrome/browser/renderer_host/render_process_host.h" | 14 #include "chrome/browser/renderer_host/render_process_host.h" |
| 15 #include "chrome/browser/renderer_host/render_view_host.h" | 15 #include "chrome/browser/renderer_host/render_view_host.h" |
| 16 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 16 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 17 #include "chrome/common/child_process_logging.h" | 17 #include "chrome/common/child_process_logging.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/gpu_messages.h" | 19 #include "chrome/common/gpu_messages.h" |
| 20 #include "chrome/gpu/gpu_info_collector.h" | |
| 20 #include "grit/browser_resources.h" | 21 #include "grit/browser_resources.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 22 | 23 |
| 23 #if defined(OS_LINUX) | 24 #if defined(OS_LINUX) |
| 24 // These two #includes need to come after gpu_messages.h. | 25 // These two #includes need to come after gpu_messages.h. |
| 25 #include <gdk/gdkwindow.h> // NOLINT | 26 #include <gdk/gdkwindow.h> // NOLINT |
| 26 #include <gdk/gdkx.h> // NOLINT | 27 #include <gdk/gdkx.h> // NOLINT |
| 27 #include "ui/base/x/x11_util.h" | 28 #include "ui/base/x/x11_util.h" |
| 28 #include "ui/gfx/gtk_native_view_id_manager.h" | 29 #include "ui/gfx/gtk_native_view_id_manager.h" |
| 29 #include "ui/gfx/size.h" | 30 #include "ui/gfx/size.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 return OnControlMessageReceived(message); | 181 return OnControlMessageReceived(message); |
| 181 | 182 |
| 182 return router_.RouteMessage(message); | 183 return router_.RouteMessage(message); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void GpuProcessHostUIShim::EstablishGpuChannel( | 186 void GpuProcessHostUIShim::EstablishGpuChannel( |
| 186 int renderer_id, EstablishChannelCallback *callback) { | 187 int renderer_id, EstablishChannelCallback *callback) { |
| 187 DCHECK(CalledOnValidThread()); | 188 DCHECK(CalledOnValidThread()); |
| 188 linked_ptr<EstablishChannelCallback> wrapped_callback(callback); | 189 linked_ptr<EstablishChannelCallback> wrapped_callback(callback); |
| 189 | 190 |
| 191 // If GPU features are already blacklisted, no need to establish the channel. | |
| 192 if (EnsureInitialized() && gpu_feature_flags_.flags() != 0) { | |
| 193 EstablishChannelError( | |
| 194 wrapped_callback.release(), IPC::ChannelHandle(), GPUInfo()); | |
| 195 return; | |
| 196 } | |
| 197 | |
| 190 if (Send(new GpuMsg_EstablishChannel(renderer_id))) { | 198 if (Send(new GpuMsg_EstablishChannel(renderer_id))) { |
| 191 channel_requests_.push(wrapped_callback); | 199 channel_requests_.push(wrapped_callback); |
| 192 } else { | 200 } else { |
| 193 EstablishChannelError( | 201 EstablishChannelError( |
| 194 wrapped_callback.release(), IPC::ChannelHandle(), GPUInfo()); | 202 wrapped_callback.release(), IPC::ChannelHandle(), GPUInfo()); |
| 195 } | 203 } |
| 196 } | 204 } |
| 197 | 205 |
| 198 void GpuProcessHostUIShim::Synchronize(SynchronizeCallback* callback) { | 206 void GpuProcessHostUIShim::Synchronize(SynchronizeCallback* callback) { |
| 199 DCHECK(CalledOnValidThread()); | 207 DCHECK(CalledOnValidThread()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 window, render_view_id, renderer_id, init_params))) { | 260 window, render_view_id, renderer_id, init_params))) { |
| 253 create_command_buffer_requests_.push(wrapped_callback); | 261 create_command_buffer_requests_.push(wrapped_callback); |
| 254 } else { | 262 } else { |
| 255 CreateCommandBufferError(wrapped_callback.release(), MSG_ROUTING_NONE); | 263 CreateCommandBufferError(wrapped_callback.release(), MSG_ROUTING_NONE); |
| 256 } | 264 } |
| 257 } | 265 } |
| 258 | 266 |
| 259 void GpuProcessHostUIShim::CollectGraphicsInfoAsynchronously( | 267 void GpuProcessHostUIShim::CollectGraphicsInfoAsynchronously( |
| 260 GPUInfo::Level level) { | 268 GPUInfo::Level level) { |
| 261 DCHECK(CalledOnValidThread()); | 269 DCHECK(CalledOnValidThread()); |
| 270 // If GPU is already blacklisted, no more info will be collected. | |
| 271 if (gpu_feature_flags_.flags() != 0) | |
| 272 return; | |
| 262 Send(new GpuMsg_CollectGraphicsInfo(level)); | 273 Send(new GpuMsg_CollectGraphicsInfo(level)); |
| 263 } | 274 } |
| 264 | 275 |
| 265 void GpuProcessHostUIShim::SendAboutGpuCrash() { | 276 void GpuProcessHostUIShim::SendAboutGpuCrash() { |
| 266 DCHECK(CalledOnValidThread()); | 277 DCHECK(CalledOnValidThread()); |
| 267 Send(new GpuMsg_Crash()); | 278 Send(new GpuMsg_Crash()); |
| 268 } | 279 } |
| 269 | 280 |
| 270 void GpuProcessHostUIShim::SendAboutGpuHang() { | 281 void GpuProcessHostUIShim::SendAboutGpuHang() { |
| 271 DCHECK(CalledOnValidThread()); | 282 DCHECK(CalledOnValidThread()); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 289 | 300 |
| 290 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 301 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
| 291 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, | 302 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, |
| 292 OnChannelEstablished) | 303 OnChannelEstablished) |
| 293 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, | 304 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, |
| 294 OnCommandBufferCreated) | 305 OnCommandBufferCreated) |
| 295 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, | 306 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, |
| 296 OnDestroyCommandBuffer) | 307 OnDestroyCommandBuffer) |
| 297 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 308 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, |
| 298 OnGraphicsInfoCollected) | 309 OnGraphicsInfoCollected) |
| 310 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GraphicsInfoCollectedSafe, | |
| 311 OnGraphicsInfoCollectedSafe) | |
| 299 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 312 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, |
| 300 OnLogMessage) | 313 OnLogMessage) |
| 301 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, | 314 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, |
| 302 OnSynchronizeReply) | 315 OnSynchronizeReply) |
| 303 #if defined(OS_LINUX) | 316 #if defined(OS_LINUX) |
| 304 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) | 317 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) |
| 305 #elif defined(OS_MACOSX) | 318 #elif defined(OS_MACOSX) |
| 306 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 319 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
| 307 OnAcceleratedSurfaceSetIOSurface) | 320 OnAcceleratedSurfaceSetIOSurface) |
| 308 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 321 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 | 431 |
| 419 void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) { | 432 void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) { |
| 420 gpu_info_ = gpu_info; | 433 gpu_info_ = gpu_info; |
| 421 child_process_logging::SetGpuInfo(gpu_info); | 434 child_process_logging::SetGpuInfo(gpu_info); |
| 422 | 435 |
| 423 // Used only in testing. | 436 // Used only in testing. |
| 424 if (gpu_info_collected_callback_.get()) | 437 if (gpu_info_collected_callback_.get()) |
| 425 gpu_info_collected_callback_->Run(); | 438 gpu_info_collected_callback_->Run(); |
| 426 } | 439 } |
| 427 | 440 |
| 441 void GpuProcessHostUIShim::OnGraphicsInfoCollectedSafe( | |
|
Ken Russell (switch to Gerrit)
2011/02/18 22:21:24
This name is not really descriptive and also isn't
Zhenyao Mo
2011/02/18 22:41:52
Used Preliminary.
| |
| 442 const GPUInfo& gpu_info, IPC::Message* reply_msg) { | |
| 443 bool blacklisted = false; | |
| 444 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | |
| 445 if (!browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) && | |
| 446 browser_command_line.GetSwitchValueASCII( | |
| 447 switches::kUseGL) != gfx::kGLImplementationOSMesaName) { | |
| 448 gpu_feature_flags_ = gpu_blacklist_->DetermineGpuFeatureFlags( | |
| 449 GpuBlacklist::kOsAny, NULL, gpu_info); | |
| 450 if (gpu_feature_flags_.flags() != 0) { | |
| 451 blacklisted = true; | |
| 452 gpu_feature_flags_set_ = true; | |
| 453 AddCustomLogMessage( | |
| 454 logging::LOG_WARNING, "WARNING", "GPU is blacklisted (SAFE MODE)."); | |
|
Ken Russell (switch to Gerrit)
2011/02/18 22:21:24
This message isn't useful. Perhaps "GPU is blackli
Zhenyao Mo
2011/02/18 22:41:52
Since you suggested to add an error message in the
| |
| 455 gpu_info_ = gpu_info; | |
| 456 gpu_info_.SetLevel(GPUInfo::kComplete); | |
| 457 child_process_logging::SetGpuInfo(gpu_info); | |
| 458 uint32 max_entry_id = gpu_blacklist_->max_entry_id(); | |
| 459 std::vector<uint32> flag_entries; | |
| 460 gpu_blacklist_->GetGpuFeatureFlagEntries( | |
| 461 GpuFeatureFlags::kGpuFeatureAll, flag_entries); | |
| 462 DCHECK_GT(flag_entries.size(), 0u); | |
| 463 for (size_t i = 0; i < flag_entries.size(); ++i) { | |
| 464 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", | |
| 465 flag_entries[i], max_entry_id + 1); | |
| 466 } | |
| 467 } | |
| 468 } | |
| 469 | |
| 470 GpuHostMsg_GraphicsInfoCollectedSafe::WriteReplyParams( | |
| 471 reply_msg, blacklisted); | |
| 472 Send(reply_msg); | |
| 473 } | |
| 474 | |
| 428 void GpuProcessHostUIShim::OnLogMessage(int level, | 475 void GpuProcessHostUIShim::OnLogMessage(int level, |
| 429 const std::string& header, | 476 const std::string& header, |
| 430 const std::string& message) { | 477 const std::string& message) { |
| 431 DictionaryValue* dict = new DictionaryValue(); | 478 DictionaryValue* dict = new DictionaryValue(); |
| 432 dict->SetInteger("level", level); | 479 dict->SetInteger("level", level); |
| 433 dict->SetString("header", header); | 480 dict->SetString("header", header); |
| 434 dict->SetString("message", message); | 481 dict->SetString("message", message); |
| 435 log_messages_.Append(dict); | 482 log_messages_.Append(dict); |
| 436 } | 483 } |
| 437 | 484 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 return true; | 552 return true; |
| 506 static const base::StringPiece gpu_blacklist_json( | 553 static const base::StringPiece gpu_blacklist_json( |
| 507 ResourceBundle::GetSharedInstance().GetRawDataResource( | 554 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 508 IDR_GPU_BLACKLIST)); | 555 IDR_GPU_BLACKLIST)); |
| 509 gpu_blacklist_.reset(new GpuBlacklist()); | 556 gpu_blacklist_.reset(new GpuBlacklist()); |
| 510 if (gpu_blacklist_->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true)) | 557 if (gpu_blacklist_->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true)) |
| 511 return true; | 558 return true; |
| 512 gpu_blacklist_.reset(NULL); | 559 gpu_blacklist_.reset(NULL); |
| 513 return false; | 560 return false; |
| 514 } | 561 } |
| OLD | NEW |