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

Side by Side Diff: content/browser/gpu/gpu_blacklist.cc

Issue 7982034: Add a "disabled" field for GPU Blacklist entries. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | « content/browser/gpu/gpu_blacklist.h ('k') | content/browser/gpu/gpu_blacklist_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 size_t dictionary_entry_count = 0; 216 size_t dictionary_entry_count = 0;
217 217
218 if (top_level) { 218 if (top_level) {
219 uint32 id; 219 uint32 id;
220 if (!value->GetInteger("id", reinterpret_cast<int*>(&id)) || 220 if (!value->GetInteger("id", reinterpret_cast<int*>(&id)) ||
221 !entry->SetId(id)) { 221 !entry->SetId(id)) {
222 LOG(WARNING) << "Malformed id entry " << entry->id(); 222 LOG(WARNING) << "Malformed id entry " << entry->id();
223 return NULL; 223 return NULL;
224 } 224 }
225 dictionary_entry_count++; 225 dictionary_entry_count++;
226
227 bool disabled;
228 if (value->GetBoolean("disabled", &disabled)) {
229 entry->SetDisabled(disabled);
230 dictionary_entry_count++;
231 }
226 } 232 }
227 233
228 std::string description; 234 std::string description;
229 if (value->GetString("description", &description)) { 235 if (value->GetString("description", &description)) {
230 entry->description_ = description; 236 entry->description_ = description;
231 dictionary_entry_count++; 237 dictionary_entry_count++;
232 } else { 238 } else {
233 entry->description_ = "The GPU is unavailable for an unexplained reason."; 239 entry->description_ = "The GPU is unavailable for an unexplained reason.";
234 } 240 }
235 241
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 455
450 if (value->size() != dictionary_entry_count) { 456 if (value->size() != dictionary_entry_count) {
451 LOG(WARNING) << "Entry with unknown fields " << entry->id(); 457 LOG(WARNING) << "Entry with unknown fields " << entry->id();
452 entry->contains_unknown_fields_ = true; 458 entry->contains_unknown_fields_ = true;
453 } 459 }
454 return entry; 460 return entry;
455 } 461 }
456 462
457 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() 463 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry()
458 : id_(0), 464 : id_(0),
465 disabled_(false),
459 vendor_id_(0), 466 vendor_id_(0),
460 contains_unknown_fields_(false), 467 contains_unknown_fields_(false),
461 contains_unknown_features_(false) { 468 contains_unknown_features_(false) {
462 } 469 }
463 470
464 bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) { 471 bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) {
465 if (id != 0) { 472 if (id != 0) {
466 id_ = id; 473 id_ = id;
467 return true; 474 return true;
468 } 475 }
469 return false; 476 return false;
470 } 477 }
471 478
479 void GpuBlacklist::GpuBlacklistEntry::SetDisabled(bool disabled) {
480 disabled_ = disabled;
481 }
482
472 bool GpuBlacklist::GpuBlacklistEntry::SetOsInfo( 483 bool GpuBlacklist::GpuBlacklistEntry::SetOsInfo(
473 const std::string& os, 484 const std::string& os,
474 const std::string& version_op, 485 const std::string& version_op,
475 const std::string& version_string, 486 const std::string& version_string,
476 const std::string& version_string2) { 487 const std::string& version_string2) {
477 os_info_.reset(new OsInfo(os, version_op, version_string, version_string2)); 488 os_info_.reset(new OsInfo(os, version_op, version_string, version_string2));
478 return os_info_->IsValid(); 489 return os_info_->IsValid();
479 } 490 }
480 491
481 bool GpuBlacklist::GpuBlacklistEntry::SetVendorId( 492 bool GpuBlacklist::GpuBlacklistEntry::SetVendorId(
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { 648 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const {
638 if (os_info_.get() == NULL) 649 if (os_info_.get() == NULL)
639 return kOsAny; 650 return kOsAny;
640 return os_info_->type(); 651 return os_info_->type();
641 } 652 }
642 653
643 uint32 GpuBlacklist::GpuBlacklistEntry::id() const { 654 uint32 GpuBlacklist::GpuBlacklistEntry::id() const {
644 return id_; 655 return id_;
645 } 656 }
646 657
658 bool GpuBlacklist::GpuBlacklistEntry::disabled() const {
659 return disabled_;
660 }
661
647 GpuFeatureFlags GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureFlags() const { 662 GpuFeatureFlags GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureFlags() const {
648 return *feature_flags_; 663 return *feature_flags_;
649 } 664 }
650 665
651 GpuBlacklist::GpuBlacklist(const std::string& browser_info_string) 666 GpuBlacklist::GpuBlacklist(const std::string& browser_info_string)
652 : max_entry_id_(0), 667 : max_entry_id_(0),
653 contains_unknown_fields_(false) { 668 contains_unknown_fields_(false) {
654 SetBrowserInfo(browser_info_string); 669 SetBrowserInfo(browser_info_string);
655 } 670 }
656 671
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 size_t pos = version_string.find_first_not_of("0123456789."); 760 size_t pos = version_string.find_first_not_of("0123456789.");
746 if (pos != std::string::npos) 761 if (pos != std::string::npos)
747 version_string = version_string.substr(0, pos); 762 version_string = version_string.substr(0, pos);
748 my_os_version.reset(Version::GetVersionFromString(version_string)); 763 my_os_version.reset(Version::GetVersionFromString(version_string));
749 os_version = my_os_version.get(); 764 os_version = my_os_version.get();
750 } 765 }
751 DCHECK(os_version != NULL); 766 DCHECK(os_version != NULL);
752 767
753 for (size_t i = 0; i < blacklist_.size(); ++i) { 768 for (size_t i = 0; i < blacklist_.size(); ++i) {
754 if (blacklist_[i]->Contains(os, *os_version, browser_channel_, gpu_info)) { 769 if (blacklist_[i]->Contains(os, *os_version, browser_channel_, gpu_info)) {
755 flags.Combine(blacklist_[i]->GetGpuFeatureFlags()); 770 if (!blacklist_[i]->disabled())
771 flags.Combine(blacklist_[i]->GetGpuFeatureFlags());
756 active_entries_.push_back(blacklist_[i]); 772 active_entries_.push_back(blacklist_[i]);
757 } 773 }
758 } 774 }
759 return flags; 775 return flags;
760 } 776 }
761 777
762 void GpuBlacklist::GetGpuFeatureFlagEntries( 778 void GpuBlacklist::GetGpuFeatureFlagEntries(
763 GpuFeatureFlags::GpuFeatureType feature, 779 GpuFeatureFlags::GpuFeatureType feature,
764 std::vector<uint32>& entry_ids) const { 780 std::vector<uint32>& entry_ids,
781 bool disabled) const {
765 entry_ids.clear(); 782 entry_ids.clear();
766 for (size_t i = 0; i < active_entries_.size(); ++i) { 783 for (size_t i = 0; i < active_entries_.size(); ++i) {
767 if ((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) 784 if (((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) &&
785 disabled == active_entries_[i]->disabled())
768 entry_ids.push_back(active_entries_[i]->id()); 786 entry_ids.push_back(active_entries_[i]->id());
769 } 787 }
770 } 788 }
771 789
772 bool GpuBlacklist::IsFeatureBlacklisted( 790 bool GpuBlacklist::IsFeatureBlacklisted(
773 GpuFeatureFlags::GpuFeatureType feature) const 791 GpuFeatureFlags::GpuFeatureType feature) const
774 { 792 {
775 for (size_t i = 0; i < active_entries_.size(); ++i) { 793 for (size_t i = 0; i < active_entries_.size(); ++i) {
776 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) 794 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature)
777 return true; 795 return true;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 return kStable; 1072 return kStable;
1055 if (value == "beta") 1073 if (value == "beta")
1056 return kBeta; 1074 return kBeta;
1057 if (value == "dev") 1075 if (value == "dev")
1058 return kDev; 1076 return kDev;
1059 if (value == "canary") 1077 if (value == "canary")
1060 return kCanary; 1078 return kCanary;
1061 return kUnknown; 1079 return kUnknown;
1062 } 1080 }
1063 1081
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_blacklist.h ('k') | content/browser/gpu/gpu_blacklist_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698