Bug 1128472 - Part 3. Vendor string on windows. r=aklotz

This commit is contained in:
Milan Sreckovic 2015-09-03 13:10:00 +02:00
parent 79db27187c
commit 9a9792e17d
3 changed files with 18 additions and 6 deletions

View File

@ -80,7 +80,7 @@ Structure::
cpu: {
count: <number>, // desktop only, e.g. 8, or null on failure - logical cpus
cores: <number>, // desktop only, e.g., 4, or null on failure - physical cores
vendor: <string>, // e.g. "GenuineIntel", or null on failure, only on mac & linux
vendor: <string>, // desktop only, e.g. "GenuineIntel", or null on failure
family: <string>, // desktop only, null on failure
model: <string>, // desktop only, null on failure
stepping: <string>, // desktop only, null on failure

View File

@ -368,10 +368,7 @@ function checkSystemSection(data) {
if (gIsWindows || gIsMac || gIsLinux) {
let EXTRA_CPU_FIELDS = ["cores", "model", "family", "stepping",
"l2cacheKB", "l3cacheKB", "speedMHz"];
if (gIsMac || gIsLinux) {
EXTRA_CPU_FIELDS.push("vendor");
}
"l2cacheKB", "l3cacheKB", "speedMHz", "vendor"];
for (let f of EXTRA_CPU_FIELDS) {
// Note this is testing TelemetryEnvironment.js only, not that the

View File

@ -396,13 +396,28 @@ nsSystemInfo::Init()
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName , 0, KEY_QUERY_VALUE, &key)
== ERROR_SUCCESS) {
DWORD data, len;
DWORD data, len, vtype;
len = sizeof(data);
if (RegQueryValueEx(key, L"~Mhz", 0, 0, reinterpret_cast<LPBYTE>(&data),
&len) == ERROR_SUCCESS) {
cpuSpeed = static_cast<int>(data);
}
// Limit to 64 double byte characters, should be plenty, but create
// a buffer one larger as the result may not be null terminated. If
// it is more than 64, we will not get the value.
wchar_t cpuVendorStr[64+1];
len = sizeof(cpuVendorStr)-2;
if (RegQueryValueExW(key, L"VendorIdentifier",
0, &vtype,
reinterpret_cast<LPBYTE>(cpuVendorStr),
&len) == ERROR_SUCCESS &&
vtype == REG_SZ && len % 2 == 0 && len > 1) {
cpuVendorStr[len/2] = 0; // In case it isn't null terminated
CopyUTF16toUTF8(nsDependentString(cpuVendorStr), cpuVendor);
}
RegCloseKey(key);
}