summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/gpu_blacklist.cc31
-rw-r--r--content/browser/gpu_blacklist.h7
2 files changed, 35 insertions, 3 deletions
diff --git a/content/browser/gpu_blacklist.cc b/content/browser/gpu_blacklist.cc
index 544a656..771de1d 100644
--- a/content/browser/gpu_blacklist.cc
+++ b/content/browser/gpu_blacklist.cc
@@ -426,7 +426,6 @@ GpuBlacklist::~GpuBlacklist() {
bool GpuBlacklist::LoadGpuBlacklist(const std::string& json_context,
bool current_os_only) {
- std::vector<GpuBlacklistEntry*> entries;
scoped_ptr<Value> root;
root.reset(base::JSONReader::Read(json_context, false));
if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY))
@@ -434,14 +433,21 @@ bool GpuBlacklist::LoadGpuBlacklist(const std::string& json_context,
DictionaryValue* root_dictionary = static_cast<DictionaryValue*>(root.get());
DCHECK(root_dictionary);
+ return LoadGpuBlacklist(*root_dictionary, current_os_only);
+}
+
+bool GpuBlacklist::LoadGpuBlacklist(const DictionaryValue& parsed_json,
+ bool current_os_only) {
+ std::vector<GpuBlacklistEntry*> entries;
+
std::string version_string;
- root_dictionary->GetString("version", &version_string);
+ parsed_json.GetString("version", &version_string);
version_.reset(Version::GetVersionFromString(version_string));
if (version_.get() == NULL)
return false;
ListValue* list = NULL;
- root_dictionary->GetList("entries", &list);
+ parsed_json.GetList("entries", &list);
if (list == NULL)
return false;
@@ -556,6 +562,25 @@ bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const {
return true;
}
+bool GpuBlacklist::GetVersion(
+ const DictionaryValue& parsed_json, uint16* major, uint16* minor) {
+ DCHECK(major && minor);
+ *major = 0;
+ *minor = 0;
+ std::string version_string;
+ if (!parsed_json.GetString("version", &version_string))
+ return false;
+ scoped_ptr<Version> version(Version::GetVersionFromString(version_string));
+ if (version.get() == NULL)
+ return false;
+ const std::vector<uint16>& components_reference = version->components();
+ if (components_reference.size() != 2)
+ return false;
+ *major = components_reference[0];
+ *minor = components_reference[1];
+ return true;
+}
+
GpuBlacklist::OsType GpuBlacklist::GetOsType() {
#if defined(OS_WIN)
return kOsWin;
diff --git a/content/browser/gpu_blacklist.h b/content/browser/gpu_blacklist.h
index f732af9..7758b65 100644
--- a/content/browser/gpu_blacklist.h
+++ b/content/browser/gpu_blacklist.h
@@ -37,6 +37,8 @@ class GpuBlacklist {
// If failed, the current GpuBlacklist is un-touched.
bool LoadGpuBlacklist(const std::string& json_context,
bool current_os_only);
+ bool LoadGpuBlacklist(const DictionaryValue& parsed_json,
+ bool current_os_only);
// Collects system information and combines them with gpu_info and blacklist
// information to determine gpu feature flags.
@@ -63,6 +65,11 @@ class GpuBlacklist {
// major and minor to 0 on failure.
bool GetVersion(uint16* major, uint16* monir) const;
+ // Collects the version of the current blacklist from a parsed json file.
+ // Returns false and sets major and minor to 0 on failure.
+ static bool GetVersion(
+ const DictionaryValue& parsed_json, uint16* major, uint16* minor);
+
private:
class VersionInfo {
public: