Index: content/browser/gpu/gpu_blacklist.h |
=================================================================== |
--- content/browser/gpu/gpu_blacklist.h (revision 98082) |
+++ content/browser/gpu/gpu_blacklist.h (working copy) |
@@ -10,6 +10,8 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/gtest_prod_util.h" |
+#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/values.h" |
#include "content/common/gpu/gpu_feature_flags.h" |
@@ -32,18 +34,21 @@ |
kOsUnknown |
}; |
+ enum OsFilter { |
+ // In loading, ignore all entries that belong to other OS. |
+ kCurrentOsOnly, |
+ // In loading, keep all entries. This is for testing only. |
+ kAllOs |
+ }; |
+ |
explicit GpuBlacklist(const std::string& browser_version_string); |
~GpuBlacklist(); |
// Loads blacklist information from a json file. |
- // current_os_only==true indicates all blacklist entries that don't belong to |
- // the current OS are discarded; current_os_only==false should only be used |
- // for testing purpose. |
// If failed, the current GpuBlacklist is un-touched. |
- bool LoadGpuBlacklist(const std::string& json_context, |
- bool current_os_only); |
+ bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter); |
bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, |
- bool current_os_only); |
+ OsFilter os_filter); |
// Collects system information and combines them with gpu_info and blacklist |
// information to determine gpu feature flags. |
@@ -63,7 +68,6 @@ |
void GetGpuFeatureFlagEntries(GpuFeatureFlags::GpuFeatureType feature, |
std::vector<uint32>& entry_ids) const; |
- |
// Returns status information on the blacklist. This is two parted: |
// { |
// featureStatus: [] |
@@ -109,6 +113,11 @@ |
const base::DictionaryValue& parsed_json, uint16* major, uint16* minor); |
private: |
+ FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, CurrentBlacklistValidation); |
+ FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField); |
+ FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField); |
+ FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature); |
+ |
class VersionInfo { |
public: |
VersionInfo(const std::string& version_op, |
@@ -192,7 +201,10 @@ |
std::string value_; |
}; |
- class GpuBlacklistEntry { |
+ class GpuBlacklistEntry; |
+ typedef scoped_refptr<GpuBlacklistEntry> ScopedGpuBlacklistEntry; |
+ |
+ class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> { |
public: |
// Constructs GpuBlacklistEntry from DictionaryValue loaded from json. |
// Top-level entry must have an id number. Others are exceptions. |
@@ -213,17 +225,27 @@ |
// Returns the description of the entry |
const std::string& description() const { return description_; } |
- // Returs a list of Chromium and Webkit bugs applicable to this entry |
+ // Returns a list of Chromium and Webkit bugs applicable to this entry |
const std::vector<int>& cr_bugs() const { return cr_bugs_; } |
const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } |
// Returns the GpuFeatureFlags. |
GpuFeatureFlags GetGpuFeatureFlags() const; |
- ~GpuBlacklistEntry(); |
+ // Returns true if an unknown field is encountered. |
+ bool contains_unknown_fields() const { |
+ return contains_unknown_fields_; |
+ } |
+ // Returns true if an unknown blacklist feature is encountered. |
+ bool contains_unknown_features() const { |
+ return contains_unknown_features_; |
+ } |
private: |
+ friend class base::RefCounted<GpuBlacklistEntry>; |
+ |
GpuBlacklistEntry(); |
+ ~GpuBlacklistEntry() { } |
bool SetId(uint32 id); |
@@ -267,7 +289,9 @@ |
scoped_ptr<VersionInfo> driver_date_info_; |
scoped_ptr<StringInfo> gl_renderer_info_; |
scoped_ptr<GpuFeatureFlags> feature_flags_; |
- std::vector<GpuBlacklistEntry*> exceptions_; |
+ std::vector<ScopedGpuBlacklistEntry> exceptions_; |
+ bool contains_unknown_fields_; |
+ bool contains_unknown_features_; |
}; |
enum BrowserVersionSupport { |
@@ -289,18 +313,26 @@ |
BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( |
base::DictionaryValue* value); |
+ // Returns the number of entries. This is only for tests. |
+ size_t num_entries() const; |
+ |
+ // Check if any entries contain unknown field. This is only for tests. |
vangelis
2011/08/25 01:18:52
typo: field -> fields
|
+ bool contains_unknown_fields() const { return contains_unknown_fields_; } |
+ |
scoped_ptr<Version> version_; |
- std::vector<GpuBlacklistEntry*> blacklist_; |
+ std::vector<ScopedGpuBlacklistEntry> blacklist_; |
scoped_ptr<Version> browser_version_; |
// This records all the blacklist entries that are appliable to the current |
// user machine. It is updated everytime DetermineGpuFeatureFlags() is |
// called and is used later by GetGpuFeatureFlagEntries(). |
- std::vector<GpuBlacklistEntry*> active_entries_; |
+ std::vector<ScopedGpuBlacklistEntry> active_entries_; |
uint32 max_entry_id_; |
+ bool contains_unknown_fields_; |
+ |
DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); |
}; |