| 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 #ifndef CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ |
| 6 #define CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 public: | 25 public: |
| 26 enum OsType { | 26 enum OsType { |
| 27 kOsLinux, | 27 kOsLinux, |
| 28 kOsMacosx, | 28 kOsMacosx, |
| 29 kOsWin, | 29 kOsWin, |
| 30 kOsChromeOS, | 30 kOsChromeOS, |
| 31 kOsAny, | 31 kOsAny, |
| 32 kOsUnknown | 32 kOsUnknown |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 enum OsFilter { |
| 36 // In loading, Ignore all entries that belong to other OS. |
| 37 kCurrentOsOnly, |
| 38 // In loading, keep all entries. This is for testing only. |
| 39 kAllOs |
| 40 }; |
| 41 |
| 42 enum UnknownFieldOption { |
| 43 // Ignore any entries with unknown field. |
| 44 kIgnoreEntryWithUnknownField, |
| 45 // The same as kIgnoreEntryWithUnknownField; however, if an exception entry |
| 46 // contains an unknown field, ignore that exception entry but still keep |
| 47 // the main entry. |
| 48 kIgnoreExceptionWithUnknownField, |
| 49 // Ignore all entries if an unknown field exists. This is for testing only. |
| 50 kFailOnUnknownField |
| 51 }; |
| 52 |
| 35 explicit GpuBlacklist(const std::string& browser_version_string); | 53 explicit GpuBlacklist(const std::string& browser_version_string); |
| 36 ~GpuBlacklist(); | 54 ~GpuBlacklist(); |
| 37 | 55 |
| 38 // Loads blacklist information from a json file. | 56 // Loads blacklist information from a json file. |
| 39 // current_os_only==true indicates all blacklist entries that don't belong to | |
| 40 // the current OS are discarded; current_os_only==false should only be used | |
| 41 // for testing purpose. | |
| 42 // If failed, the current GpuBlacklist is un-touched. | 57 // If failed, the current GpuBlacklist is un-touched. |
| 43 bool LoadGpuBlacklist(const std::string& json_context, | 58 bool LoadGpuBlacklist(const std::string& json_context, |
| 44 bool current_os_only); | 59 OsFilter os_filter, |
| 60 UnknownFieldOption unknown_field_option); |
| 45 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, | 61 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, |
| 46 bool current_os_only); | 62 OsFilter os_filter, |
| 63 UnknownFieldOption unknown_field_option); |
| 47 | 64 |
| 48 // Collects system information and combines them with gpu_info and blacklist | 65 // Collects system information and combines them with gpu_info and blacklist |
| 49 // information to determine gpu feature flags. | 66 // information to determine gpu feature flags. |
| 50 // If os is kOsAny, use the current OS; if os_version is null, use the | 67 // If os is kOsAny, use the current OS; if os_version is null, use the |
| 51 // current OS version. | 68 // current OS version. |
| 52 GpuFeatureFlags DetermineGpuFeatureFlags(OsType os, | 69 GpuFeatureFlags DetermineGpuFeatureFlags(OsType os, |
| 53 Version* os_version, | 70 Version* os_version, |
| 54 const GPUInfo& gpu_info); | 71 const GPUInfo& gpu_info); |
| 55 | 72 |
| 56 // Collects the entries that set the "feature" flag from the last | 73 // Collects the entries that set the "feature" flag from the last |
| 57 // DetermineGpuFeatureFlags() call. This tells which entries are responsible | 74 // DetermineGpuFeatureFlags() call. This tells which entries are responsible |
| 58 // for raising a certain flag, i.e, for blacklisting a certain feature. | 75 // for raising a certain flag, i.e, for blacklisting a certain feature. |
| 59 // Examples of "feature": | 76 // Examples of "feature": |
| 60 // kGpuFeatureAll - any of the supported features; | 77 // kGpuFeatureAll - any of the supported features; |
| 61 // kGpuFeatureWebgl - a single feature; | 78 // kGpuFeatureWebgl - a single feature; |
| 62 // kGpuFeatureWebgl | kGpuFeatureAcceleratedCompositing - two features. | 79 // kGpuFeatureWebgl | kGpuFeatureAcceleratedCompositing - two features. |
| 63 void GetGpuFeatureFlagEntries(GpuFeatureFlags::GpuFeatureType feature, | 80 void GetGpuFeatureFlagEntries(GpuFeatureFlags::GpuFeatureType feature, |
| 64 std::vector<uint32>& entry_ids) const; | 81 std::vector<uint32>& entry_ids) const; |
| 65 | 82 |
| 66 | |
| 67 // Returns status information on the blacklist. This is two parted: | 83 // Returns status information on the blacklist. This is two parted: |
| 68 // { | 84 // { |
| 69 // featureStatus: [] | 85 // featureStatus: [] |
| 70 // problems: [] | 86 // problems: [] |
| 71 // } | 87 // } |
| 72 // | 88 // |
| 73 // Each entry in feature_status has: | 89 // Each entry in feature_status has: |
| 74 // { | 90 // { |
| 75 // name: "name of feature" | 91 // name: "name of feature" |
| 76 // status: "enabled" | "unavailable_software" | "unavailable_off" | | 92 // status: "enabled" | "unavailable_software" | "unavailable_off" | |
| (...skipping 12 matching lines...) Expand all Loading... |
| 89 // "description": "Your GPU is too old", | 105 // "description": "Your GPU is too old", |
| 90 // "crBugs": [1234], | 106 // "crBugs": [1234], |
| 91 // "webkitBugs": [] | 107 // "webkitBugs": [] |
| 92 // } | 108 // } |
| 93 base::Value* GetFeatureStatus(bool gpu_access_allowed, | 109 base::Value* GetFeatureStatus(bool gpu_access_allowed, |
| 94 bool disable_accelerated_compositing, | 110 bool disable_accelerated_compositing, |
| 95 bool disable_accelerated_2D_canvas, | 111 bool disable_accelerated_2D_canvas, |
| 96 bool disable_experimental_webgl, | 112 bool disable_experimental_webgl, |
| 97 bool disable_multisampling) const; | 113 bool disable_multisampling) const; |
| 98 | 114 |
| 115 // Returns the number of entries. |
| 116 size_t num_entries() const; |
| 117 |
| 99 // Return the largest entry id. This is used for histogramming. | 118 // Return the largest entry id. This is used for histogramming. |
| 100 uint32 max_entry_id() const; | 119 uint32 max_entry_id() const; |
| 101 | 120 |
| 102 // Collects the version of the current blacklist. Returns false and sets | 121 // Collects the version of the current blacklist. Returns false and sets |
| 103 // major and minor to 0 on failure. | 122 // major and minor to 0 on failure. |
| 104 bool GetVersion(uint16* major, uint16* monir) const; | 123 bool GetVersion(uint16* major, uint16* monir) const; |
| 105 | 124 |
| 106 // Collects the version of the current blacklist from a parsed json file. | 125 // Collects the version of the current blacklist from a parsed json file. |
| 107 // Returns false and sets major and minor to 0 on failure. | 126 // Returns false and sets major and minor to 0 on failure. |
| 108 static bool GetVersion( | 127 static bool GetVersion( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 225 |
| 207 // Returns the OsType. | 226 // Returns the OsType. |
| 208 OsType GetOsType() const; | 227 OsType GetOsType() const; |
| 209 | 228 |
| 210 // Returns the entry's unique id. 0 is reserved. | 229 // Returns the entry's unique id. 0 is reserved. |
| 211 uint32 id() const; | 230 uint32 id() const; |
| 212 | 231 |
| 213 // Returns the description of the entry | 232 // Returns the description of the entry |
| 214 const std::string& description() const { return description_; } | 233 const std::string& description() const { return description_; } |
| 215 | 234 |
| 216 // Returs a list of Chromium and Webkit bugs applicable to this entry | 235 // Returns a list of Chromium and Webkit bugs applicable to this entry |
| 217 const std::vector<int>& cr_bugs() const { return cr_bugs_; } | 236 const std::vector<int>& cr_bugs() const { return cr_bugs_; } |
| 218 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } | 237 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } |
| 219 | 238 |
| 220 // Returns the GpuFeatureFlags. | 239 // Returns the GpuFeatureFlags. |
| 221 GpuFeatureFlags GetGpuFeatureFlags() const; | 240 GpuFeatureFlags GetGpuFeatureFlags() const; |
| 222 | 241 |
| 242 bool contains_unknown_field() const { |
| 243 return contains_unknown_field_; |
| 244 } |
| 245 |
| 246 bool contains_exception_with_unknown_field() const { |
| 247 return contains_exception_with_unknown_field_; |
| 248 } |
| 249 |
| 223 ~GpuBlacklistEntry(); | 250 ~GpuBlacklistEntry(); |
| 224 | 251 |
| 225 private: | 252 private: |
| 226 GpuBlacklistEntry(); | 253 GpuBlacklistEntry(); |
| 227 | 254 |
| 228 bool SetId(uint32 id); | 255 bool SetId(uint32 id); |
| 229 | 256 |
| 230 bool SetOsInfo(const std::string& os, | 257 bool SetOsInfo(const std::string& os, |
| 231 const std::string& version_op, | 258 const std::string& version_op, |
| 232 const std::string& version_string, | 259 const std::string& version_string, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 261 std::vector<int> webkit_bugs_; | 288 std::vector<int> webkit_bugs_; |
| 262 scoped_ptr<OsInfo> os_info_; | 289 scoped_ptr<OsInfo> os_info_; |
| 263 uint32 vendor_id_; | 290 uint32 vendor_id_; |
| 264 std::vector<uint32> device_id_list_; | 291 std::vector<uint32> device_id_list_; |
| 265 scoped_ptr<StringInfo> driver_vendor_info_; | 292 scoped_ptr<StringInfo> driver_vendor_info_; |
| 266 scoped_ptr<VersionInfo> driver_version_info_; | 293 scoped_ptr<VersionInfo> driver_version_info_; |
| 267 scoped_ptr<VersionInfo> driver_date_info_; | 294 scoped_ptr<VersionInfo> driver_date_info_; |
| 268 scoped_ptr<StringInfo> gl_renderer_info_; | 295 scoped_ptr<StringInfo> gl_renderer_info_; |
| 269 scoped_ptr<GpuFeatureFlags> feature_flags_; | 296 scoped_ptr<GpuFeatureFlags> feature_flags_; |
| 270 std::vector<GpuBlacklistEntry*> exceptions_; | 297 std::vector<GpuBlacklistEntry*> exceptions_; |
| 298 bool contains_unknown_field_; |
| 299 bool contains_exception_with_unknown_field_; |
| 271 }; | 300 }; |
| 272 | 301 |
| 273 enum BrowserVersionSupport { | 302 enum BrowserVersionSupport { |
| 274 kSupported, | 303 kSupported, |
| 275 kUnsupported, | 304 kUnsupported, |
| 276 kMalformed | 305 kMalformed |
| 277 }; | 306 }; |
| 278 | 307 |
| 279 // Gets the current OS type. | 308 // Gets the current OS type. |
| 280 static OsType GetOsType(); | 309 static OsType GetOsType(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 298 // user machine. It is updated everytime DetermineGpuFeatureFlags() is | 327 // user machine. It is updated everytime DetermineGpuFeatureFlags() is |
| 299 // called and is used later by GetGpuFeatureFlagEntries(). | 328 // called and is used later by GetGpuFeatureFlagEntries(). |
| 300 std::vector<GpuBlacklistEntry*> active_entries_; | 329 std::vector<GpuBlacklistEntry*> active_entries_; |
| 301 | 330 |
| 302 uint32 max_entry_id_; | 331 uint32 max_entry_id_; |
| 303 | 332 |
| 304 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); | 333 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); |
| 305 }; | 334 }; |
| 306 | 335 |
| 307 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ | 336 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ |
| OLD | NEW |