OLD | NEW |
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 else if (string_op == "contains") | 200 else if (string_op == "contains") |
201 return kContains; | 201 return kContains; |
202 else if (string_op == "beginwith") | 202 else if (string_op == "beginwith") |
203 return kBeginWith; | 203 return kBeginWith; |
204 else if (string_op == "endwith") | 204 else if (string_op == "endwith") |
205 return kEndWith; | 205 return kEndWith; |
206 return kUnknown; | 206 return kUnknown; |
207 } | 207 } |
208 | 208 |
209 // static | 209 // static |
210 GpuBlacklist::GpuBlacklistEntry* | 210 GpuBlacklist::ScopedGpuBlacklistEntry |
211 GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue( | 211 GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue( |
212 DictionaryValue* value, bool top_level) { | 212 DictionaryValue* value, bool top_level) { |
213 DCHECK(value); | 213 DCHECK(value); |
214 ScopedGpuBlacklistEntry entry(new GpuBlacklistEntry()); | 214 ScopedGpuBlacklistEntry entry(new GpuBlacklistEntry()); |
215 | 215 |
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)) || |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 DictionaryValue* browser_version_value = NULL; | 413 DictionaryValue* browser_version_value = NULL; |
414 // browser_version is processed in LoadGpuBlacklist(). | 414 // browser_version is processed in LoadGpuBlacklist(). |
415 if (value->GetDictionary("browser_version", &browser_version_value)) | 415 if (value->GetDictionary("browser_version", &browser_version_value)) |
416 dictionary_entry_count++; | 416 dictionary_entry_count++; |
417 } | 417 } |
418 | 418 |
419 if (value->size() != dictionary_entry_count) { | 419 if (value->size() != dictionary_entry_count) { |
420 LOG(WARNING) << "Entry with unknown fields " << entry->id(); | 420 LOG(WARNING) << "Entry with unknown fields " << entry->id(); |
421 entry->contains_unknown_fields_ = true; | 421 entry->contains_unknown_fields_ = true; |
422 } | 422 } |
423 return entry.release(); | 423 return entry; |
424 } | 424 } |
425 | 425 |
426 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() | 426 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() |
427 : id_(0), | 427 : id_(0), |
428 vendor_id_(0), | 428 vendor_id_(0), |
429 contains_unknown_fields_(false), | 429 contains_unknown_fields_(false), |
430 contains_unknown_features_(false) { | 430 contains_unknown_features_(false) { |
431 } | 431 } |
432 | 432 |
433 bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) { | 433 bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 contains_unknown_features_ = true; | 520 contains_unknown_features_ = true; |
521 break; | 521 break; |
522 } | 522 } |
523 } | 523 } |
524 feature_flags_.reset(new GpuFeatureFlags()); | 524 feature_flags_.reset(new GpuFeatureFlags()); |
525 feature_flags_->set_flags(flags); | 525 feature_flags_->set_flags(flags); |
526 return true; | 526 return true; |
527 } | 527 } |
528 | 528 |
529 void GpuBlacklist::GpuBlacklistEntry::AddException( | 529 void GpuBlacklist::GpuBlacklistEntry::AddException( |
530 GpuBlacklistEntry* exception) { | 530 ScopedGpuBlacklistEntry exception) { |
531 exceptions_.push_back(exception); | 531 exceptions_.push_back(exception); |
532 } | 532 } |
533 | 533 |
534 bool GpuBlacklist::GpuBlacklistEntry::Contains( | 534 bool GpuBlacklist::GpuBlacklistEntry::Contains( |
535 OsType os_type, const Version& os_version, const GPUInfo& gpu_info) const { | 535 OsType os_type, const Version& os_version, const GPUInfo& gpu_info) const { |
536 DCHECK(os_type != kOsAny); | 536 DCHECK(os_type != kOsAny); |
537 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) | 537 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) |
538 return false; | 538 return false; |
539 if (vendor_id_ != 0 && vendor_id_ != gpu_info.vendor_id) | 539 if (vendor_id_ != 0 && vendor_id_ != gpu_info.vendor_id) |
540 return false; | 540 return false; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 browser_version_info.reset( | 966 browser_version_info.reset( |
967 new VersionInfo(version_op, version_string, version_string2)); | 967 new VersionInfo(version_op, version_string, version_string2)); |
968 if (!browser_version_info->IsValid()) | 968 if (!browser_version_info->IsValid()) |
969 return kMalformed; | 969 return kMalformed; |
970 if (browser_version_info->Contains(*browser_version_)) | 970 if (browser_version_info->Contains(*browser_version_)) |
971 return kSupported; | 971 return kSupported; |
972 return kUnsupported; | 972 return kUnsupported; |
973 } | 973 } |
974 return kSupported; | 974 return kSupported; |
975 } | 975 } |
OLD | NEW |