Chromium Code Reviews| 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_blacklist.h" | 5 #include "content/browser/gpu/gpu_blacklist.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/cpu.h" | |
|
Zhenyao Mo
2012/10/02 22:01:32
nit: still wrong order, move one line up
| |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 | 11 |
| 11 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
| 12 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
| 13 #endif // OS_MACOSX | 14 #endif // OS_MACOSX |
| 14 | 15 |
| 15 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 16 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 18 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 std::string renderer_value; | 572 std::string renderer_value; |
| 572 gl_renderer_value->GetString("op", &renderer_op); | 573 gl_renderer_value->GetString("op", &renderer_op); |
| 573 gl_renderer_value->GetString("value", &renderer_value); | 574 gl_renderer_value->GetString("value", &renderer_value); |
| 574 if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) { | 575 if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) { |
| 575 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id(); | 576 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id(); |
| 576 return NULL; | 577 return NULL; |
| 577 } | 578 } |
| 578 dictionary_entry_count++; | 579 dictionary_entry_count++; |
| 579 } | 580 } |
| 580 | 581 |
| 582 const DictionaryValue* cpu_brand_value = NULL; | |
| 583 if (value->GetDictionary("cpu_info", &cpu_brand_value)) { | |
| 584 std::string cpu_op; | |
| 585 std::string cpu_value; | |
| 586 cpu_brand_value->GetString("op", &cpu_op); | |
| 587 cpu_brand_value->GetString("value", &cpu_value); | |
| 588 if (!entry->SetCpuBrand(cpu_op, cpu_value)) { | |
| 589 LOG(WARNING) << "Malformed cpu_brand entry " << entry->id(); | |
| 590 return NULL; | |
| 591 } | |
| 592 dictionary_entry_count++; | |
| 593 } | |
| 594 | |
| 581 const DictionaryValue* perf_graphics_value = NULL; | 595 const DictionaryValue* perf_graphics_value = NULL; |
| 582 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) { | 596 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) { |
| 583 std::string op; | 597 std::string op; |
| 584 std::string float_value; | 598 std::string float_value; |
| 585 std::string float_value2; | 599 std::string float_value2; |
| 586 perf_graphics_value->GetString("op", &op); | 600 perf_graphics_value->GetString("op", &op); |
| 587 perf_graphics_value->GetString("value", &float_value); | 601 perf_graphics_value->GetString("value", &float_value); |
| 588 perf_graphics_value->GetString("value2", &float_value2); | 602 perf_graphics_value->GetString("value2", &float_value2); |
| 589 if (!entry->SetPerfGraphicsInfo(op, float_value, float_value2)) { | 603 if (!entry->SetPerfGraphicsInfo(op, float_value, float_value2)) { |
| 590 LOG(WARNING) << "Malformed perf_graphics entry " << entry->id(); | 604 LOG(WARNING) << "Malformed perf_graphics entry " << entry->id(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 } | 853 } |
| 840 | 854 |
| 841 bool GpuBlacklist::GpuBlacklistEntry::SetGLRendererInfo( | 855 bool GpuBlacklist::GpuBlacklistEntry::SetGLRendererInfo( |
| 842 const std::string& renderer_op, | 856 const std::string& renderer_op, |
| 843 const std::string& renderer_value) { | 857 const std::string& renderer_value) { |
| 844 gl_renderer_info_.reset( | 858 gl_renderer_info_.reset( |
| 845 new StringInfo(renderer_op, renderer_value)); | 859 new StringInfo(renderer_op, renderer_value)); |
| 846 return gl_renderer_info_->IsValid(); | 860 return gl_renderer_info_->IsValid(); |
| 847 } | 861 } |
| 848 | 862 |
| 863 bool GpuBlacklist::GpuBlacklistEntry::SetCpuBrand( | |
| 864 const std::string& cpu_op, | |
| 865 const std::string& cpu_value) { | |
| 866 cpu_brand_.reset( | |
| 867 new StringInfo(cpu_op, cpu_value)); | |
| 868 return cpu_brand_->IsValid(); | |
| 869 } | |
| 870 | |
| 849 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGraphicsInfo( | 871 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGraphicsInfo( |
| 850 const std::string& op, | 872 const std::string& op, |
| 851 const std::string& float_string, | 873 const std::string& float_string, |
| 852 const std::string& float_string2) { | 874 const std::string& float_string2) { |
| 853 perf_graphics_info_.reset( | 875 perf_graphics_info_.reset( |
| 854 new FloatInfo(op, float_string, float_string2)); | 876 new FloatInfo(op, float_string, float_string2)); |
| 855 return perf_graphics_info_->IsValid(); | 877 return perf_graphics_info_->IsValid(); |
| 856 } | 878 } |
| 857 | 879 |
| 858 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGamingInfo( | 880 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGamingInfo( |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 if (perf_overall_info_.get() != NULL && | 1063 if (perf_overall_info_.get() != NULL && |
| 1042 (gpu_info.performance_stats.overall == 0.0 || | 1064 (gpu_info.performance_stats.overall == 0.0 || |
| 1043 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) | 1065 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) |
| 1044 return false; | 1066 return false; |
| 1045 if (machine_model_info_.get() != NULL && | 1067 if (machine_model_info_.get() != NULL && |
| 1046 !machine_model_info_->Contains(machine_model_name, machine_model_version)) | 1068 !machine_model_info_->Contains(machine_model_name, machine_model_version)) |
| 1047 return false; | 1069 return false; |
| 1048 if (gpu_count_info_.get() != NULL && | 1070 if (gpu_count_info_.get() != NULL && |
| 1049 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) | 1071 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) |
| 1050 return false; | 1072 return false; |
| 1073 if (cpu_brand_.get() != NULL) { | |
| 1074 base::CPU cpu_info; | |
| 1075 if (!cpu_brand_->Contains(cpu_info.cpu_brand())) | |
| 1076 return false; | |
| 1077 } | |
| 1078 | |
| 1051 for (size_t i = 0; i < exceptions_.size(); ++i) { | 1079 for (size_t i = 0; i < exceptions_.size(); ++i) { |
| 1052 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name, | 1080 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name, |
| 1053 machine_model_version, gpu_info)) | 1081 machine_model_version, gpu_info)) |
| 1054 return false; | 1082 return false; |
| 1055 } | 1083 } |
| 1056 return true; | 1084 return true; |
| 1057 } | 1085 } |
| 1058 | 1086 |
| 1059 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { | 1087 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { |
| 1060 if (os_info_.get() == NULL) | 1088 if (os_info_.get() == NULL) |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 if (op == ">") | 1374 if (op == ">") |
| 1347 return kGT; | 1375 return kGT; |
| 1348 if (op == ">=") | 1376 if (op == ">=") |
| 1349 return kGE; | 1377 return kGE; |
| 1350 if (op == "any") | 1378 if (op == "any") |
| 1351 return kAny; | 1379 return kAny; |
| 1352 if (op == "between") | 1380 if (op == "between") |
| 1353 return kBetween; | 1381 return kBetween; |
| 1354 return kUnknown; | 1382 return kUnknown; |
| 1355 } | 1383 } |
| OLD | NEW |