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 27 matching lines...) Expand all Loading... |
38 kOsUnknown | 38 kOsUnknown |
39 }; | 39 }; |
40 | 40 |
41 enum OsFilter { | 41 enum OsFilter { |
42 // In loading, ignore all entries that belong to other OS. | 42 // In loading, ignore all entries that belong to other OS. |
43 kCurrentOsOnly, | 43 kCurrentOsOnly, |
44 // In loading, keep all entries. This is for testing only. | 44 // In loading, keep all entries. This is for testing only. |
45 kAllOs | 45 kAllOs |
46 }; | 46 }; |
47 | 47 |
48 explicit GpuBlacklist(const std::string& browser_info_string); | 48 explicit GpuBlacklist(const std::string& browser_version_string); |
49 ~GpuBlacklist(); | 49 ~GpuBlacklist(); |
50 | 50 |
51 // Loads blacklist information from a json file. | 51 // Loads blacklist information from a json file. |
52 // If failed, the current GpuBlacklist is un-touched. | 52 // If failed, the current GpuBlacklist is un-touched. |
53 bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter); | 53 bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter); |
54 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, | 54 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, |
55 OsFilter os_filter); | 55 OsFilter os_filter); |
56 | 56 |
57 // Collects system information and combines them with gpu_info and blacklist | 57 // Collects system information and combines them with gpu_info and blacklist |
58 // information to determine gpu feature flags. | 58 // information to determine gpu feature flags. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField); | 103 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField); |
104 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField); | 104 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField); |
105 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature); | 105 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature); |
106 | 106 |
107 enum BrowserVersionSupport { | 107 enum BrowserVersionSupport { |
108 kSupported, | 108 kSupported, |
109 kUnsupported, | 109 kUnsupported, |
110 kMalformed | 110 kMalformed |
111 }; | 111 }; |
112 | 112 |
113 enum BrowserChannel { | |
114 kStable, | |
115 kBeta, | |
116 kDev, | |
117 kCanary, | |
118 kUnknown | |
119 }; | |
120 | |
121 class VersionInfo { | 113 class VersionInfo { |
122 public: | 114 public: |
123 VersionInfo(const std::string& version_op, | 115 VersionInfo(const std::string& version_op, |
124 const std::string& version_string, | 116 const std::string& version_string, |
125 const std::string& version_string2); | 117 const std::string& version_string2); |
126 ~VersionInfo(); | 118 ~VersionInfo(); |
127 | 119 |
128 // Determines if a given version is included in the VersionInfo range. | 120 // Determines if a given version is included in the VersionInfo range. |
129 bool Contains(const Version& version) const; | 121 bool Contains(const Version& version) const; |
130 | 122 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> { | 199 class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> { |
208 public: | 200 public: |
209 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. | 201 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. |
210 // Top-level entry must have an id number. Others are exceptions. | 202 // Top-level entry must have an id number. Others are exceptions. |
211 static ScopedGpuBlacklistEntry GetGpuBlacklistEntryFromValue( | 203 static ScopedGpuBlacklistEntry GetGpuBlacklistEntryFromValue( |
212 base::DictionaryValue* value, bool top_level); | 204 base::DictionaryValue* value, bool top_level); |
213 | 205 |
214 // Determines if a given os/gc/driver is included in the Entry set. | 206 // Determines if a given os/gc/driver is included in the Entry set. |
215 bool Contains(OsType os_type, | 207 bool Contains(OsType os_type, |
216 const Version& os_version, | 208 const Version& os_version, |
217 BrowserChannel channel, | |
218 const content::GPUInfo& gpu_info) const; | 209 const content::GPUInfo& gpu_info) const; |
219 | 210 |
220 // Returns the OsType. | 211 // Returns the OsType. |
221 OsType GetOsType() const; | 212 OsType GetOsType() const; |
222 | 213 |
223 // Returns the entry's unique id. 0 is reserved. | 214 // Returns the entry's unique id. 0 is reserved. |
224 uint32 id() const; | 215 uint32 id() const; |
225 | 216 |
226 // Returns whether the entry is disabled. | 217 // Returns whether the entry is disabled. |
227 bool disabled() const; | 218 bool disabled() const; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 const std::string& vendor_value); | 270 const std::string& vendor_value); |
280 | 271 |
281 bool SetGLRendererInfo(const std::string& renderer_op, | 272 bool SetGLRendererInfo(const std::string& renderer_op, |
282 const std::string& renderer_value); | 273 const std::string& renderer_value); |
283 | 274 |
284 bool SetBlacklistedFeatures( | 275 bool SetBlacklistedFeatures( |
285 const std::vector<std::string>& blacklisted_features); | 276 const std::vector<std::string>& blacklisted_features); |
286 | 277 |
287 void AddException(ScopedGpuBlacklistEntry exception); | 278 void AddException(ScopedGpuBlacklistEntry exception); |
288 | 279 |
289 void AddBrowserChannel(BrowserChannel channel); | |
290 | |
291 uint32 id_; | 280 uint32 id_; |
292 bool disabled_; | 281 bool disabled_; |
293 std::string description_; | 282 std::string description_; |
294 std::vector<int> cr_bugs_; | 283 std::vector<int> cr_bugs_; |
295 std::vector<int> webkit_bugs_; | 284 std::vector<int> webkit_bugs_; |
296 scoped_ptr<OsInfo> os_info_; | 285 scoped_ptr<OsInfo> os_info_; |
297 uint32 vendor_id_; | 286 uint32 vendor_id_; |
298 std::vector<uint32> device_id_list_; | 287 std::vector<uint32> device_id_list_; |
299 scoped_ptr<StringInfo> driver_vendor_info_; | 288 scoped_ptr<StringInfo> driver_vendor_info_; |
300 scoped_ptr<VersionInfo> driver_version_info_; | 289 scoped_ptr<VersionInfo> driver_version_info_; |
301 scoped_ptr<VersionInfo> driver_date_info_; | 290 scoped_ptr<VersionInfo> driver_date_info_; |
302 scoped_ptr<StringInfo> gl_vendor_info_; | 291 scoped_ptr<StringInfo> gl_vendor_info_; |
303 scoped_ptr<StringInfo> gl_renderer_info_; | 292 scoped_ptr<StringInfo> gl_renderer_info_; |
304 scoped_ptr<GpuFeatureFlags> feature_flags_; | 293 scoped_ptr<GpuFeatureFlags> feature_flags_; |
305 std::vector<ScopedGpuBlacklistEntry> exceptions_; | 294 std::vector<ScopedGpuBlacklistEntry> exceptions_; |
306 std::vector<BrowserChannel> browser_channels_; | |
307 bool contains_unknown_fields_; | 295 bool contains_unknown_fields_; |
308 bool contains_unknown_features_; | 296 bool contains_unknown_features_; |
309 }; | 297 }; |
310 | 298 |
311 // Gets the current OS type. | 299 // Gets the current OS type. |
312 static OsType GetOsType(); | 300 static OsType GetOsType(); |
313 | 301 |
314 void Clear(); | 302 void Clear(); |
315 | 303 |
316 // Check if the entry is supported by the current version of browser. | 304 // Check if the entry is supported by the current version of browser. |
317 // By default, if there is no browser version information in the entry, | 305 // By default, if there is no browser version information in the entry, |
318 // return kSupported; | 306 // return kSupported; |
319 BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( | 307 BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( |
320 base::DictionaryValue* value); | 308 base::DictionaryValue* value); |
321 | 309 |
322 // Returns the number of entries. This is only for tests. | 310 // Returns the number of entries. This is only for tests. |
323 size_t num_entries() const; | 311 size_t num_entries() const; |
324 | 312 |
325 // Check if any entries contain unknown fields. This is only for tests. | 313 // Check if any entries contain unknown fields. This is only for tests. |
326 bool contains_unknown_fields() const { return contains_unknown_fields_; } | 314 bool contains_unknown_fields() const { return contains_unknown_fields_; } |
327 | 315 |
328 // The browser_info_string's format is "version channel". | 316 void SetBrowserVersion(const std::string& version_string); |
329 // For example, "13.0.123.4 canary". | |
330 void SetBrowserInfo(const std::string& browser_info_string); | |
331 | |
332 static BrowserChannel StringToBrowserChannel(const std::string& value); | |
333 | 317 |
334 scoped_ptr<Version> version_; | 318 scoped_ptr<Version> version_; |
335 std::vector<ScopedGpuBlacklistEntry> blacklist_; | 319 std::vector<ScopedGpuBlacklistEntry> blacklist_; |
336 | 320 |
337 scoped_ptr<Version> browser_version_; | 321 scoped_ptr<Version> browser_version_; |
338 BrowserChannel browser_channel_; | |
339 | 322 |
340 // This records all the blacklist entries that are appliable to the current | 323 // This records all the blacklist entries that are appliable to the current |
341 // user machine. It is updated everytime DetermineGpuFeatureFlags() is | 324 // user machine. It is updated everytime DetermineGpuFeatureFlags() is |
342 // called and is used later by GetGpuFeatureFlagEntries(). | 325 // called and is used later by GetGpuFeatureFlagEntries(). |
343 std::vector<ScopedGpuBlacklistEntry> active_entries_; | 326 std::vector<ScopedGpuBlacklistEntry> active_entries_; |
344 | 327 |
345 uint32 max_entry_id_; | 328 uint32 max_entry_id_; |
346 | 329 |
347 bool contains_unknown_fields_; | 330 bool contains_unknown_fields_; |
348 | 331 |
349 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); | 332 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); |
350 }; | 333 }; |
351 | 334 |
352 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ | 335 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ |
OLD | NEW |