| OLD | NEW |
| 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 #include "content/browser/gpu/gpu_data_manager_impl.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 6 | 6 |
| 7 #include <set> |
| 8 |
| 7 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
| 8 #include <ApplicationServices/ApplicationServices.h> | 10 #include <ApplicationServices/ApplicationServices.h> |
| 9 #endif // OS_MACOSX | 11 #endif // OS_MACOSX |
| 10 | 12 |
| 11 #include "base/bind.h" | 13 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 14 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 15 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
| 16 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/string16.h" |
| 17 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
| 18 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
| 19 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 20 #include "base/values.h" | 23 #include "base/values.h" |
| 21 #include "base/version.h" | 24 #include "base/version.h" |
| 22 #include "content/browser/gpu/gpu_process_host.h" | 25 #include "content/browser/gpu/gpu_process_host.h" |
| 23 #include "content/browser/gpu/gpu_util.h" | 26 #include "content/browser/gpu/gpu_util.h" |
| 24 #include "content/common/gpu/gpu_messages.h" | 27 #include "content/common/gpu/gpu_messages.h" |
| 25 #include "content/gpu/gpu_info_collector.h" | 28 #include "content/gpu/gpu_info_collector.h" |
| 26 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/gpu_data_manager_observer.h" | 30 #include "content/public/browser/gpu_data_manager_observer.h" |
| 28 #include "content/public/common/content_client.h" | 31 #include "content/public/common/content_client.h" |
| 29 #include "content/public/common/content_constants.h" | 32 #include "content/public/common/content_constants.h" |
| 30 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 31 #include "grit/content_resources.h" | 34 #include "grit/content_resources.h" |
| 32 #include "ui/base/ui_base_switches.h" | 35 #include "ui/base/ui_base_switches.h" |
| 33 #include "ui/gl/gl_implementation.h" | 36 #include "ui/gl/gl_implementation.h" |
| 34 #include "ui/gl/gl_switches.h" | 37 #include "ui/gl/gl_switches.h" |
| 35 #include "ui/gl/gpu_switching_manager.h" | 38 #include "ui/gl/gpu_switching_manager.h" |
| 36 #include "webkit/plugins/plugin_switches.h" | 39 #include "webkit/plugins/plugin_switches.h" |
| 37 | 40 |
| 38 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 42 #include "base/win/registry.h" |
| 39 #include "base/win/windows_version.h" | 43 #include "base/win/windows_version.h" |
| 40 #endif | 44 #endif |
| 41 | 45 |
| 42 namespace content { | 46 namespace content { |
| 43 namespace { | 47 namespace { |
| 44 | 48 |
| 45 // Strip out the non-digital info; if after that, we get an empty string, | 49 // Strip out the non-digital info; if after that, we get an empty string, |
| 46 // return "0". | 50 // return "0". |
| 47 std::string ProcessVersionString(const std::string& raw_string) { | 51 std::string ProcessVersionString(const std::string& raw_string) { |
| 48 const std::string valid_set = "0123456789."; | 52 const std::string valid_set = "0123456789."; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 76 const int kNumResetsWithinDuration = 1; | 80 const int kNumResetsWithinDuration = 1; |
| 77 | 81 |
| 78 // Enums for UMA histograms. | 82 // Enums for UMA histograms. |
| 79 enum BlockStatusHistogram { | 83 enum BlockStatusHistogram { |
| 80 BLOCK_STATUS_NOT_BLOCKED, | 84 BLOCK_STATUS_NOT_BLOCKED, |
| 81 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, | 85 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, |
| 82 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, | 86 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, |
| 83 BLOCK_STATUS_MAX | 87 BLOCK_STATUS_MAX |
| 84 }; | 88 }; |
| 85 | 89 |
| 90 #if defined(OS_WIN) |
| 91 bool GetInstalledProgramDisplayNames(std::set<string16>* display_names) { |
| 92 base::win::RegKey key; |
| 93 |
| 94 if (FAILED(key.Open( |
| 95 HKEY_LOCAL_MACHINE, L"SOFTWARE", KEY_READ | KEY_WOW64_64KEY))) { |
| 96 return false; |
| 97 } |
| 98 |
| 99 if (FAILED(key.OpenKey(L"Microsoft", KEY_READ | KEY_WOW64_64KEY))) |
| 100 return false; |
| 101 |
| 102 if (FAILED(key.OpenKey(L"Windows", KEY_READ | KEY_WOW64_64KEY))) |
| 103 return false; |
| 104 |
| 105 if (FAILED(key.OpenKey(L"CurrentVersion", KEY_READ | KEY_WOW64_64KEY))) |
| 106 return false; |
| 107 |
| 108 if (FAILED(key.OpenKey(L"Uninstall", KEY_READ | KEY_WOW64_64KEY))) |
| 109 return false; |
| 110 |
| 111 for (base::win::RegistryKeyIterator key_it(key.Handle(), NULL); |
| 112 key_it.Valid(); |
| 113 ++key_it) { |
| 114 base::win::RegKey sub_key; |
| 115 if (FAILED(sub_key.Open( |
| 116 key.Handle(), key_it.Name(), KEY_READ | KEY_WOW64_64KEY))) { |
| 117 continue; |
| 118 } |
| 119 |
| 120 string16 display_name; |
| 121 if (FAILED(sub_key.ReadValue(L"DisplayName", &display_name))) |
| 122 continue; |
| 123 |
| 124 display_names->insert(display_name); |
| 125 } |
| 126 |
| 127 return true; |
| 128 } |
| 129 #endif |
| 86 } // namespace anonymous | 130 } // namespace anonymous |
| 87 | 131 |
| 88 // static | 132 // static |
| 89 GpuDataManager* GpuDataManager::GetInstance() { | 133 GpuDataManager* GpuDataManager::GetInstance() { |
| 90 return GpuDataManagerImpl::GetInstance(); | 134 return GpuDataManagerImpl::GetInstance(); |
| 91 } | 135 } |
| 92 | 136 |
| 93 // static | 137 // static |
| 94 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { | 138 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { |
| 95 return Singleton<GpuDataManagerImpl>::get(); | 139 return Singleton<GpuDataManagerImpl>::get(); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 break; | 473 break; |
| 430 } | 474 } |
| 431 } else { | 475 } else { |
| 432 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); | 476 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); |
| 433 } | 477 } |
| 434 | 478 |
| 435 if (!swiftshader_path.empty()) | 479 if (!swiftshader_path.empty()) |
| 436 command_line->AppendSwitchPath(switches::kSwiftShaderPath, | 480 command_line->AppendSwitchPath(switches::kSwiftShaderPath, |
| 437 swiftshader_path); | 481 swiftshader_path); |
| 438 | 482 |
| 483 #if defined(OS_WIN) |
| 484 // DisplayLink drivers cause a hang when running in the GPU process sandbox. |
| 485 std::set<string16> installed_display_names; |
| 486 if (GetInstalledProgramDisplayNames(&installed_display_names)) { |
| 487 if (installed_display_names.find(L"DisplayLink Core Software") != |
| 488 installed_display_names.end()) { |
| 489 command_line->AppendSwitch(switches::kReduceGpuSandbox); |
| 490 } |
| 491 } |
| 492 #endif |
| 493 |
| 439 { | 494 { |
| 440 base::AutoLock auto_lock(gpu_info_lock_); | 495 base::AutoLock auto_lock(gpu_info_lock_); |
| 441 if (gpu_info_.optimus) | 496 if (gpu_info_.optimus) |
| 442 command_line->AppendSwitch(switches::kReduceGpuSandbox); | 497 command_line->AppendSwitch(switches::kReduceGpuSandbox); |
| 443 if (gpu_info_.amd_switchable) { | 498 if (gpu_info_.amd_switchable) { |
| 444 // The image transport surface currently doesn't work with AMD Dynamic | 499 // The image transport surface currently doesn't work with AMD Dynamic |
| 445 // Switchable graphics. | 500 // Switchable graphics. |
| 446 command_line->AppendSwitch(switches::kReduceGpuSandbox); | 501 command_line->AppendSwitch(switches::kReduceGpuSandbox); |
| 447 command_line->AppendSwitch(switches::kDisableImageTransportSurface); | 502 command_line->AppendSwitch(switches::kDisableImageTransportSurface); |
| 448 } | 503 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 | 852 |
| 798 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, | 853 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, |
| 799 int render_process_id, | 854 int render_process_id, |
| 800 int render_view_id, | 855 int render_view_id, |
| 801 ThreeDAPIType requester) { | 856 ThreeDAPIType requester) { |
| 802 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 857 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
| 803 url, render_process_id, render_view_id, requester); | 858 url, render_process_id, render_view_id, requester); |
| 804 } | 859 } |
| 805 | 860 |
| 806 } // namespace content | 861 } // namespace content |
| OLD | NEW |