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

Side by Side Diff: gpu/config/gpu_control_list.cc

Issue 452293002: Use RE string pattern matching for blacklist strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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
« no previous file with comments | « gpu/config/gpu_control_list.h ('k') | gpu/config/gpu_control_list_entry_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "gpu/config/gpu_control_list.h" 5 #include "gpu/config/gpu_control_list.h"
6 6
7 #include "base/cpu.h" 7 #include "base/cpu.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/sys_info.h" 14 #include "base/sys_info.h"
15 #include "gpu/config/gpu_info.h" 15 #include "gpu/config/gpu_info.h"
16 #include "gpu/config/gpu_util.h" 16 #include "gpu/config/gpu_util.h"
17 #include "third_party/re2/re2/re2.h"
17 18
18 namespace gpu { 19 namespace gpu {
19 namespace { 20 namespace {
20 21
21 // Break a version string into segments. Return true if each segment is 22 // Break a version string into segments. Return true if each segment is
22 // a valid number, and not all segment is 0. 23 // a valid number, and not all segment is 0.
23 bool ProcessVersionString(const std::string& version_string, 24 bool ProcessVersionString(const std::string& version_string,
24 char splitter, 25 char splitter,
25 std::vector<std::string>* version) { 26 std::vector<std::string>* version) {
26 DCHECK(version); 27 DCHECK(version);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 value1 = number[i] - '0'; 83 value1 = number[i] - '0';
83 unsigned value2 = number_ref[i] - '0'; 84 unsigned value2 = number_ref[i] - '0';
84 if (value1 > value2) 85 if (value1 > value2)
85 return 1; 86 return 1;
86 if (value1 < value2) 87 if (value1 < value2)
87 return -1; 88 return -1;
88 } 89 }
89 return 0; 90 return 0;
90 } 91 }
91 92
93 // A mismatch is identified only if both |input| and |pattern| are not empty.
94 bool StringMismatch(const std::string& input, const std::string& pattern) {
95 if (input.empty() || pattern.empty())
96 return false;
97 return !RE2::FullMatch(input, pattern);
98 }
99
92 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable"; 100 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable";
93 const char kMultiGpuStyleStringAMDSwitchableDiscrete[] = 101 const char kMultiGpuStyleStringAMDSwitchableDiscrete[] =
94 "amd_switchable_discrete"; 102 "amd_switchable_discrete";
95 const char kMultiGpuStyleStringAMDSwitchableIntegrated[] = 103 const char kMultiGpuStyleStringAMDSwitchableIntegrated[] =
96 "amd_switchable_integrated"; 104 "amd_switchable_integrated";
97 const char kMultiGpuStyleStringOptimus[] = "optimus"; 105 const char kMultiGpuStyleStringOptimus[] = "optimus";
98 106
99 const char kMultiGpuCategoryStringPrimary[] = "primary"; 107 const char kMultiGpuCategoryStringPrimary[] = "primary";
100 const char kMultiGpuCategoryStringSecondary[] = "secondary"; 108 const char kMultiGpuCategoryStringSecondary[] = "secondary";
101 const char kMultiGpuCategoryStringActive[] = "active"; 109 const char kMultiGpuCategoryStringActive[] = "active";
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return kOsAndroid; 262 return kOsAndroid;
255 else if (os == "linux") 263 else if (os == "linux")
256 return kOsLinux; 264 return kOsLinux;
257 else if (os == "chromeos") 265 else if (os == "chromeos")
258 return kOsChromeOS; 266 return kOsChromeOS;
259 else if (os == "any") 267 else if (os == "any")
260 return kOsAny; 268 return kOsAny;
261 return kOsUnknown; 269 return kOsUnknown;
262 } 270 }
263 271
264 GpuControlList::StringInfo::StringInfo(const std::string& string_op,
265 const std::string& string_value) {
266 op_ = StringToOp(string_op);
267 value_ = base::StringToLowerASCII(string_value);
268 }
269
270 bool GpuControlList::StringInfo::Contains(const std::string& value) const {
271 std::string my_value = base::StringToLowerASCII(value);
272 switch (op_) {
273 case kContains:
274 return strstr(my_value.c_str(), value_.c_str()) != NULL;
275 case kBeginWith:
276 return StartsWithASCII(my_value, value_, false);
277 case kEndWith:
278 return EndsWith(my_value, value_, false);
279 case kEQ:
280 return value_ == my_value;
281 default:
282 return false;
283 }
284 }
285
286 bool GpuControlList::StringInfo::IsValid() const {
287 return op_ != kUnknown;
288 }
289
290 GpuControlList::StringInfo::Op GpuControlList::StringInfo::StringToOp(
291 const std::string& string_op) {
292 if (string_op == "=")
293 return kEQ;
294 else if (string_op == "contains")
295 return kContains;
296 else if (string_op == "beginwith")
297 return kBeginWith;
298 else if (string_op == "endwith")
299 return kEndWith;
300 return kUnknown;
301 }
302
303 GpuControlList::FloatInfo::FloatInfo(const std::string& float_op, 272 GpuControlList::FloatInfo::FloatInfo(const std::string& float_op,
304 const std::string& float_value, 273 const std::string& float_value,
305 const std::string& float_value2) 274 const std::string& float_value2)
306 : op_(kUnknown), 275 : op_(kUnknown),
307 value_(0.f), 276 value_(0.f),
308 value2_(0.f) { 277 value2_(0.f) {
309 op_ = StringToNumericOp(float_op); 278 op_ = StringToNumericOp(float_op);
310 if (op_ == kAny) 279 if (op_ == kAny)
311 return; 280 return;
312 double dvalue = 0; 281 double dvalue = 0;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 482
514 std::string multi_gpu_category; 483 std::string multi_gpu_category;
515 if (value->GetString("multi_gpu_category", &multi_gpu_category)) { 484 if (value->GetString("multi_gpu_category", &multi_gpu_category)) {
516 if (!entry->SetMultiGpuCategory(multi_gpu_category)) { 485 if (!entry->SetMultiGpuCategory(multi_gpu_category)) {
517 LOG(WARNING) << "Malformed multi_gpu_category entry " << entry->id(); 486 LOG(WARNING) << "Malformed multi_gpu_category entry " << entry->id();
518 return NULL; 487 return NULL;
519 } 488 }
520 dictionary_entry_count++; 489 dictionary_entry_count++;
521 } 490 }
522 491
523 const base::DictionaryValue* driver_vendor_value = NULL; 492 std::string driver_vendor_value;
524 if (value->GetDictionary("driver_vendor", &driver_vendor_value)) { 493 if (value->GetString("driver_vendor", &driver_vendor_value)) {
525 std::string vendor_op; 494 if (!entry->SetDriverVendorInfo(driver_vendor_value)) {
526 std::string vendor_value;
527 driver_vendor_value->GetString(kOp, &vendor_op);
528 driver_vendor_value->GetString("value", &vendor_value);
529 if (!entry->SetDriverVendorInfo(vendor_op, vendor_value)) {
530 LOG(WARNING) << "Malformed driver_vendor entry " << entry->id(); 495 LOG(WARNING) << "Malformed driver_vendor entry " << entry->id();
531 return NULL; 496 return NULL;
532 } 497 }
533 dictionary_entry_count++; 498 dictionary_entry_count++;
534 } 499 }
535 500
536 const base::DictionaryValue* driver_version_value = NULL; 501 const base::DictionaryValue* driver_version_value = NULL;
537 if (value->GetDictionary("driver_version", &driver_version_value)) { 502 if (value->GetDictionary("driver_version", &driver_version_value)) {
538 std::string driver_version_op = "any"; 503 std::string driver_version_op = "any";
539 std::string driver_version_style; 504 std::string driver_version_style;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 gl_version_value->GetString("value", &version_string); 552 gl_version_value->GetString("value", &version_string);
588 gl_version_value->GetString("value2", &version_string2); 553 gl_version_value->GetString("value2", &version_string2);
589 if (!entry->SetGLVersionInfo( 554 if (!entry->SetGLVersionInfo(
590 version_op, version_string, version_string2)) { 555 version_op, version_string, version_string2)) {
591 LOG(WARNING) << "Malformed gl_version entry " << entry->id(); 556 LOG(WARNING) << "Malformed gl_version entry " << entry->id();
592 return NULL; 557 return NULL;
593 } 558 }
594 dictionary_entry_count++; 559 dictionary_entry_count++;
595 } 560 }
596 561
597 const base::DictionaryValue* gl_vendor_value = NULL; 562 std::string gl_vendor_value;
598 if (value->GetDictionary("gl_vendor", &gl_vendor_value)) { 563 if (value->GetString("gl_vendor", &gl_vendor_value)) {
599 std::string vendor_op; 564 if (!entry->SetGLVendorInfo(gl_vendor_value)) {
600 std::string vendor_value;
601 gl_vendor_value->GetString(kOp, &vendor_op);
602 gl_vendor_value->GetString("value", &vendor_value);
603 if (!entry->SetGLVendorInfo(vendor_op, vendor_value)) {
604 LOG(WARNING) << "Malformed gl_vendor entry " << entry->id(); 565 LOG(WARNING) << "Malformed gl_vendor entry " << entry->id();
605 return NULL; 566 return NULL;
606 } 567 }
607 dictionary_entry_count++; 568 dictionary_entry_count++;
608 } 569 }
609 570
610 const base::DictionaryValue* gl_renderer_value = NULL; 571 std::string gl_renderer_value;
611 if (value->GetDictionary("gl_renderer", &gl_renderer_value)) { 572 if (value->GetString("gl_renderer", &gl_renderer_value)) {
612 std::string renderer_op; 573 if (!entry->SetGLRendererInfo(gl_renderer_value)) {
613 std::string renderer_value;
614 gl_renderer_value->GetString(kOp, &renderer_op);
615 gl_renderer_value->GetString("value", &renderer_value);
616 if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) {
617 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id(); 574 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id();
618 return NULL; 575 return NULL;
619 } 576 }
620 dictionary_entry_count++; 577 dictionary_entry_count++;
621 } 578 }
622 579
623 const base::DictionaryValue* gl_extensions_value = NULL; 580 std::string gl_extensions_value;
624 if (value->GetDictionary("gl_extensions", &gl_extensions_value)) { 581 if (value->GetString("gl_extensions", &gl_extensions_value)) {
625 std::string extensions_op; 582 if (!entry->SetGLExtensionsInfo(gl_extensions_value)) {
626 std::string extensions_value;
627 gl_extensions_value->GetString(kOp, &extensions_op);
628 gl_extensions_value->GetString("value", &extensions_value);
629 if (!entry->SetGLExtensionsInfo(extensions_op, extensions_value)) {
630 LOG(WARNING) << "Malformed gl_extensions entry " << entry->id(); 583 LOG(WARNING) << "Malformed gl_extensions entry " << entry->id();
631 return NULL; 584 return NULL;
632 } 585 }
633 dictionary_entry_count++; 586 dictionary_entry_count++;
634 } 587 }
635 588
636 const base::DictionaryValue* gl_reset_notification_strategy_value = NULL; 589 const base::DictionaryValue* gl_reset_notification_strategy_value = NULL;
637 if (value->GetDictionary("gl_reset_notification_strategy", 590 if (value->GetDictionary("gl_reset_notification_strategy",
638 &gl_reset_notification_strategy_value)) { 591 &gl_reset_notification_strategy_value)) {
639 std::string op; 592 std::string op;
640 std::string int_value; 593 std::string int_value;
641 std::string int_value2; 594 std::string int_value2;
642 gl_reset_notification_strategy_value->GetString(kOp, &op); 595 gl_reset_notification_strategy_value->GetString(kOp, &op);
643 gl_reset_notification_strategy_value->GetString("value", &int_value); 596 gl_reset_notification_strategy_value->GetString("value", &int_value);
644 gl_reset_notification_strategy_value->GetString("value2", &int_value2); 597 gl_reset_notification_strategy_value->GetString("value2", &int_value2);
645 if (!entry->SetGLResetNotificationStrategyInfo( 598 if (!entry->SetGLResetNotificationStrategyInfo(
646 op, int_value, int_value2)) { 599 op, int_value, int_value2)) {
647 LOG(WARNING) << "Malformed gl_reset_notification_strategy entry " 600 LOG(WARNING) << "Malformed gl_reset_notification_strategy entry "
648 << entry->id(); 601 << entry->id();
649 return NULL; 602 return NULL;
650 } 603 }
651 dictionary_entry_count++; 604 dictionary_entry_count++;
652 } 605 }
653 606
654 const base::DictionaryValue* cpu_brand_value = NULL; 607 std::string cpu_brand_value;
655 if (value->GetDictionary("cpu_info", &cpu_brand_value)) { 608 if (value->GetString("cpu_info", &cpu_brand_value)) {
656 std::string cpu_op; 609 if (!entry->SetCpuBrand(cpu_brand_value)) {
657 std::string cpu_value;
658 cpu_brand_value->GetString(kOp, &cpu_op);
659 cpu_brand_value->GetString("value", &cpu_value);
660 if (!entry->SetCpuBrand(cpu_op, cpu_value)) {
661 LOG(WARNING) << "Malformed cpu_brand entry " << entry->id(); 610 LOG(WARNING) << "Malformed cpu_brand entry " << entry->id();
662 return NULL; 611 return NULL;
663 } 612 }
664 dictionary_entry_count++; 613 dictionary_entry_count++;
665 } 614 }
666 615
667 const base::DictionaryValue* perf_graphics_value = NULL; 616 const base::DictionaryValue* perf_graphics_value = NULL;
668 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) { 617 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) {
669 std::string op; 618 std::string op;
670 std::string float_value; 619 std::string float_value;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 bool GpuControlList::GpuControlListEntry::SetGLType( 840 bool GpuControlList::GpuControlListEntry::SetGLType(
892 const std::string& gl_type_string) { 841 const std::string& gl_type_string) {
893 GLType gl_type = StringToGLType(gl_type_string); 842 GLType gl_type = StringToGLType(gl_type_string);
894 if (gl_type == kGLTypeNone) 843 if (gl_type == kGLTypeNone)
895 return false; 844 return false;
896 gl_type_ = gl_type; 845 gl_type_ = gl_type;
897 return true; 846 return true;
898 } 847 }
899 848
900 bool GpuControlList::GpuControlListEntry::SetDriverVendorInfo( 849 bool GpuControlList::GpuControlListEntry::SetDriverVendorInfo(
901 const std::string& vendor_op,
902 const std::string& vendor_value) { 850 const std::string& vendor_value) {
903 driver_vendor_info_.reset(new StringInfo(vendor_op, vendor_value)); 851 driver_vendor_info_ = vendor_value;
904 return driver_vendor_info_->IsValid(); 852 return !driver_vendor_info_.empty();
905 } 853 }
906 854
907 bool GpuControlList::GpuControlListEntry::SetDriverVersionInfo( 855 bool GpuControlList::GpuControlListEntry::SetDriverVersionInfo(
908 const std::string& version_op, 856 const std::string& version_op,
909 const std::string& version_style, 857 const std::string& version_style,
910 const std::string& version_string, 858 const std::string& version_string,
911 const std::string& version_string2) { 859 const std::string& version_string2) {
912 driver_version_info_.reset(new VersionInfo( 860 driver_version_info_.reset(new VersionInfo(
913 version_op, version_style, version_string, version_string2)); 861 version_op, version_style, version_string, version_string2));
914 return driver_version_info_->IsValid(); 862 return driver_version_info_->IsValid();
(...skipping 11 matching lines...) Expand all
926 bool GpuControlList::GpuControlListEntry::SetGLVersionInfo( 874 bool GpuControlList::GpuControlListEntry::SetGLVersionInfo(
927 const std::string& version_op, 875 const std::string& version_op,
928 const std::string& version_string, 876 const std::string& version_string,
929 const std::string& version_string2) { 877 const std::string& version_string2) {
930 gl_version_info_.reset(new VersionInfo( 878 gl_version_info_.reset(new VersionInfo(
931 version_op, std::string(), version_string, version_string2)); 879 version_op, std::string(), version_string, version_string2));
932 return gl_version_info_->IsValid(); 880 return gl_version_info_->IsValid();
933 } 881 }
934 882
935 bool GpuControlList::GpuControlListEntry::SetGLVendorInfo( 883 bool GpuControlList::GpuControlListEntry::SetGLVendorInfo(
936 const std::string& vendor_op,
937 const std::string& vendor_value) { 884 const std::string& vendor_value) {
938 gl_vendor_info_.reset(new StringInfo(vendor_op, vendor_value)); 885 gl_vendor_info_ = vendor_value;
939 return gl_vendor_info_->IsValid(); 886 return !gl_vendor_info_.empty();
940 } 887 }
941 888
942 bool GpuControlList::GpuControlListEntry::SetGLRendererInfo( 889 bool GpuControlList::GpuControlListEntry::SetGLRendererInfo(
943 const std::string& renderer_op,
944 const std::string& renderer_value) { 890 const std::string& renderer_value) {
945 gl_renderer_info_.reset(new StringInfo(renderer_op, renderer_value)); 891 gl_renderer_info_ = renderer_value;
946 return gl_renderer_info_->IsValid(); 892 return !gl_renderer_info_.empty();
947 } 893 }
948 894
949 bool GpuControlList::GpuControlListEntry::SetGLExtensionsInfo( 895 bool GpuControlList::GpuControlListEntry::SetGLExtensionsInfo(
950 const std::string& extensions_op,
951 const std::string& extensions_value) { 896 const std::string& extensions_value) {
952 gl_extensions_info_.reset(new StringInfo(extensions_op, extensions_value)); 897 gl_extensions_info_ = extensions_value;
953 return gl_extensions_info_->IsValid(); 898 return !gl_extensions_info_.empty();
954 } 899 }
955 900
956 bool GpuControlList::GpuControlListEntry::SetGLResetNotificationStrategyInfo( 901 bool GpuControlList::GpuControlListEntry::SetGLResetNotificationStrategyInfo(
957 const std::string& op, 902 const std::string& op,
958 const std::string& int_string, 903 const std::string& int_string,
959 const std::string& int_string2) { 904 const std::string& int_string2) {
960 gl_reset_notification_strategy_info_.reset( 905 gl_reset_notification_strategy_info_.reset(
961 new IntInfo(op, int_string, int_string2)); 906 new IntInfo(op, int_string, int_string2));
962 return gl_reset_notification_strategy_info_->IsValid(); 907 return gl_reset_notification_strategy_info_->IsValid();
963 } 908 }
964 909
965 bool GpuControlList::GpuControlListEntry::SetCpuBrand( 910 bool GpuControlList::GpuControlListEntry::SetCpuBrand(
966 const std::string& cpu_op,
967 const std::string& cpu_value) { 911 const std::string& cpu_value) {
968 cpu_brand_.reset(new StringInfo(cpu_op, cpu_value)); 912 cpu_brand_ = cpu_value;
969 return cpu_brand_->IsValid(); 913 return !cpu_brand_.empty();
970 } 914 }
971 915
972 bool GpuControlList::GpuControlListEntry::SetPerfGraphicsInfo( 916 bool GpuControlList::GpuControlListEntry::SetPerfGraphicsInfo(
973 const std::string& op, 917 const std::string& op,
974 const std::string& float_string, 918 const std::string& float_string,
975 const std::string& float_string2) { 919 const std::string& float_string2) {
976 perf_graphics_info_.reset(new FloatInfo(op, float_string, float_string2)); 920 perf_graphics_info_.reset(new FloatInfo(op, float_string, float_string2));
977 return perf_graphics_info_->IsValid(); 921 return perf_graphics_info_->IsValid();
978 } 922 }
979 923
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 if (!gpu_info.amd_switchable) 1173 if (!gpu_info.amd_switchable)
1230 return false; 1174 return false;
1231 // Assume the integrated GPU is the first in the secondary GPU list. 1175 // Assume the integrated GPU is the first in the secondary GPU list.
1232 if (gpu_info.secondary_gpus.size() == 0 || 1176 if (gpu_info.secondary_gpus.size() == 0 ||
1233 !gpu_info.secondary_gpus[0].active) 1177 !gpu_info.secondary_gpus[0].active)
1234 return false; 1178 return false;
1235 break; 1179 break;
1236 case kMultiGpuStyleNone: 1180 case kMultiGpuStyleNone:
1237 break; 1181 break;
1238 } 1182 }
1239 if (driver_vendor_info_.get() != NULL && !gpu_info.driver_vendor.empty() && 1183 if (StringMismatch(gpu_info.driver_vendor, driver_vendor_info_))
1240 !driver_vendor_info_->Contains(gpu_info.driver_vendor))
1241 return false; 1184 return false;
1242 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) { 1185 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) {
1243 if (!driver_version_info_->Contains(gpu_info.driver_version)) 1186 if (!driver_version_info_->Contains(gpu_info.driver_version))
1244 return false; 1187 return false;
1245 } 1188 }
1246 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) { 1189 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) {
1247 if (!driver_date_info_->Contains(gpu_info.driver_date, '-')) 1190 if (!driver_date_info_->Contains(gpu_info.driver_date, '-'))
1248 return false; 1191 return false;
1249 } 1192 }
1250 if (GLVersionInfoMismatch(gpu_info.gl_version)) 1193 if (GLVersionInfoMismatch(gpu_info.gl_version))
1251 return false; 1194 return false;
1252 if (gl_vendor_info_.get() != NULL && !gpu_info.gl_vendor.empty() && 1195 if (StringMismatch(gpu_info.gl_vendor, gl_vendor_info_))
1253 !gl_vendor_info_->Contains(gpu_info.gl_vendor))
1254 return false; 1196 return false;
1255 if (gl_renderer_info_.get() != NULL && !gpu_info.gl_renderer.empty() && 1197 if (StringMismatch(gpu_info.gl_renderer, gl_renderer_info_))
1256 !gl_renderer_info_->Contains(gpu_info.gl_renderer))
1257 return false; 1198 return false;
1258 if (gl_extensions_info_.get() != NULL && !gpu_info.gl_extensions.empty() && 1199 if (StringMismatch(gpu_info.gl_extensions, gl_extensions_info_))
1259 !gl_extensions_info_->Contains(gpu_info.gl_extensions))
1260 return false; 1200 return false;
1261 if (gl_reset_notification_strategy_info_.get() != NULL && 1201 if (gl_reset_notification_strategy_info_.get() != NULL &&
1262 !gl_reset_notification_strategy_info_->Contains( 1202 !gl_reset_notification_strategy_info_->Contains(
1263 gpu_info.gl_reset_notification_strategy)) 1203 gpu_info.gl_reset_notification_strategy))
1264 return false; 1204 return false;
1265 if (perf_graphics_info_.get() != NULL && 1205 if (perf_graphics_info_.get() != NULL &&
1266 (gpu_info.performance_stats.graphics == 0.0 || 1206 (gpu_info.performance_stats.graphics == 0.0 ||
1267 !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics))) 1207 !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics)))
1268 return false; 1208 return false;
1269 if (perf_gaming_info_.get() != NULL && 1209 if (perf_gaming_info_.get() != NULL &&
1270 (gpu_info.performance_stats.gaming == 0.0 || 1210 (gpu_info.performance_stats.gaming == 0.0 ||
1271 !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming))) 1211 !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming)))
1272 return false; 1212 return false;
1273 if (perf_overall_info_.get() != NULL && 1213 if (perf_overall_info_.get() != NULL &&
1274 (gpu_info.performance_stats.overall == 0.0 || 1214 (gpu_info.performance_stats.overall == 0.0 ||
1275 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) 1215 !perf_overall_info_->Contains(gpu_info.performance_stats.overall)))
1276 return false; 1216 return false;
1277 if (!machine_model_name_list_.empty()) { 1217 if (!machine_model_name_list_.empty()) {
1278 if (gpu_info.machine_model_name.empty()) 1218 if (gpu_info.machine_model_name.empty())
1279 return false; 1219 return false;
1280 bool found_match = false; 1220 bool found_match = false;
1281 for (size_t ii = 0; ii < machine_model_name_list_.size(); ++ii) { 1221 for (size_t ii = 0; ii < machine_model_name_list_.size(); ++ii) {
1282 if (machine_model_name_list_[ii] == gpu_info.machine_model_name) { 1222 if (RE2::FullMatch(gpu_info.machine_model_name,
1223 machine_model_name_list_[ii])) {
1283 found_match = true; 1224 found_match = true;
1284 break; 1225 break;
1285 } 1226 }
1286 } 1227 }
1287 if (!found_match) 1228 if (!found_match)
1288 return false; 1229 return false;
1289 } 1230 }
1290 if (machine_model_version_info_.get() != NULL && 1231 if (machine_model_version_info_.get() != NULL &&
1291 (gpu_info.machine_model_version.empty() || 1232 (gpu_info.machine_model_version.empty() ||
1292 !machine_model_version_info_->Contains(gpu_info.machine_model_version))) 1233 !machine_model_version_info_->Contains(gpu_info.machine_model_version)))
1293 return false; 1234 return false;
1294 if (gpu_count_info_.get() != NULL && 1235 if (gpu_count_info_.get() != NULL &&
1295 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) 1236 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1))
1296 return false; 1237 return false;
1297 if (direct_rendering_info_.get() != NULL && 1238 if (direct_rendering_info_.get() != NULL &&
1298 !direct_rendering_info_->Contains(gpu_info.direct_rendering)) 1239 !direct_rendering_info_->Contains(gpu_info.direct_rendering))
1299 return false; 1240 return false;
1300 if (cpu_brand_.get() != NULL) { 1241 if (!cpu_brand_.empty()) {
1301 base::CPU cpu_info; 1242 base::CPU cpu_info;
1302 if (!cpu_brand_->Contains(cpu_info.cpu_brand())) 1243 if (StringMismatch(cpu_info.cpu_brand(), cpu_brand_))
1303 return false; 1244 return false;
1304 } 1245 }
1305 1246
1306 for (size_t i = 0; i < exceptions_.size(); ++i) { 1247 for (size_t i = 0; i < exceptions_.size(); ++i) {
1307 if (exceptions_[i]->Contains(os_type, os_version, gpu_info) && 1248 if (exceptions_[i]->Contains(os_type, os_version, gpu_info) &&
1308 !exceptions_[i]->NeedsMoreInfo(gpu_info)) 1249 !exceptions_[i]->NeedsMoreInfo(gpu_info))
1309 return false; 1250 return false;
1310 } 1251 }
1311 return true; 1252 return true;
1312 } 1253 }
1313 1254
1314 bool GpuControlList::GpuControlListEntry::NeedsMoreInfo( 1255 bool GpuControlList::GpuControlListEntry::NeedsMoreInfo(
1315 const GPUInfo& gpu_info) const { 1256 const GPUInfo& gpu_info) const {
1316 // We only check for missing info that might be collected with a gl context. 1257 // We only check for missing info that might be collected with a gl context.
1317 // If certain info is missing due to some error, say, we fail to collect 1258 // If certain info is missing due to some error, say, we fail to collect
1318 // vendor_id/device_id, then even if we launch GPU process and create a gl 1259 // vendor_id/device_id, then even if we launch GPU process and create a gl
1319 // context, we won't gather such missing info, so we still return false. 1260 // context, we won't gather such missing info, so we still return false.
1320 if (driver_vendor_info_.get() && gpu_info.driver_vendor.empty()) 1261 if (!driver_vendor_info_.empty() && gpu_info.driver_vendor.empty())
1321 return true; 1262 return true;
1322 if (driver_version_info_.get() && gpu_info.driver_version.empty()) 1263 if (driver_version_info_.get() && gpu_info.driver_version.empty())
1323 return true; 1264 return true;
1324 if (gl_vendor_info_.get() && gpu_info.gl_vendor.empty()) 1265 if (!gl_vendor_info_.empty() && gpu_info.gl_vendor.empty())
1325 return true; 1266 return true;
1326 if (gl_renderer_info_.get() && gpu_info.gl_renderer.empty()) 1267 if (!gl_renderer_info_.empty() && gpu_info.gl_renderer.empty())
1327 return true; 1268 return true;
1328 for (size_t i = 0; i < exceptions_.size(); ++i) { 1269 for (size_t i = 0; i < exceptions_.size(); ++i) {
1329 if (exceptions_[i]->NeedsMoreInfo(gpu_info)) 1270 if (exceptions_[i]->NeedsMoreInfo(gpu_info))
1330 return true; 1271 return true;
1331 } 1272 }
1332 return false; 1273 return false;
1333 } 1274 }
1334 1275
1335 GpuControlList::OsType GpuControlList::GpuControlListEntry::GetOsType() const { 1276 GpuControlList::OsType GpuControlList::GpuControlListEntry::GetOsType() const {
1336 if (os_info_.get() == NULL) 1277 if (os_info_.get() == NULL)
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 const std::string& feature_name, int feature_id) { 1519 const std::string& feature_name, int feature_id) {
1579 feature_map_[feature_name] = feature_id; 1520 feature_map_[feature_name] = feature_id;
1580 } 1521 }
1581 1522
1582 void GpuControlList::set_supports_feature_type_all(bool supported) { 1523 void GpuControlList::set_supports_feature_type_all(bool supported) {
1583 supports_feature_type_all_ = supported; 1524 supports_feature_type_all_ = supported;
1584 } 1525 }
1585 1526
1586 } // namespace gpu 1527 } // namespace gpu
1587 1528
OLDNEW
« no previous file with comments | « gpu/config/gpu_control_list.h ('k') | gpu/config/gpu_control_list_entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698