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/cpu.h" |
8 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
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" |
(...skipping 553 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 if (perf_overall_info_.get() != NULL && | 1065 if (perf_overall_info_.get() != NULL && |
1044 (gpu_info.performance_stats.overall == 0.0 || | 1066 (gpu_info.performance_stats.overall == 0.0 || |
1045 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) | 1067 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) |
1046 return false; | 1068 return false; |
1047 if (machine_model_info_.get() != NULL && | 1069 if (machine_model_info_.get() != NULL && |
1048 !machine_model_info_->Contains(machine_model_name, machine_model_version)) | 1070 !machine_model_info_->Contains(machine_model_name, machine_model_version)) |
1049 return false; | 1071 return false; |
1050 if (gpu_count_info_.get() != NULL && | 1072 if (gpu_count_info_.get() != NULL && |
1051 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) | 1073 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) |
1052 return false; | 1074 return false; |
| 1075 if (cpu_brand_.get() != NULL) { |
| 1076 base::CPU cpu_info; |
| 1077 if (!cpu_brand_->Contains(cpu_info.cpu_brand())) |
| 1078 return false; |
| 1079 } |
| 1080 |
1053 for (size_t i = 0; i < exceptions_.size(); ++i) { | 1081 for (size_t i = 0; i < exceptions_.size(); ++i) { |
1054 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name, | 1082 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name, |
1055 machine_model_version, gpu_info)) | 1083 machine_model_version, gpu_info)) |
1056 return false; | 1084 return false; |
1057 } | 1085 } |
1058 return true; | 1086 return true; |
1059 } | 1087 } |
1060 | 1088 |
1061 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { | 1089 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { |
1062 if (os_info_.get() == NULL) | 1090 if (os_info_.get() == NULL) |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 if (op == ">") | 1376 if (op == ">") |
1349 return kGT; | 1377 return kGT; |
1350 if (op == ">=") | 1378 if (op == ">=") |
1351 return kGE; | 1379 return kGE; |
1352 if (op == "any") | 1380 if (op == "any") |
1353 return kAny; | 1381 return kAny; |
1354 if (op == "between") | 1382 if (op == "between") |
1355 return kBetween; | 1383 return kBetween; |
1356 return kUnknown; | 1384 return kUnknown; |
1357 } | 1385 } |
OLD | NEW |