Bug 944529: Obtain HDD info for GRE path and Windows directory; r=froydnj

This commit is contained in:
Aaron Klotz 2013-12-02 10:41:44 -07:00
parent de7c513c3b
commit fc6cc3bdcf
2 changed files with 22 additions and 4 deletions

View File

@ -360,7 +360,8 @@ TelemetryPing.prototype = {
"hasMMX", "hasSSE", "hasSSE2", "hasSSE3",
"hasSSSE3", "hasSSE4A", "hasSSE4_1", "hasSSE4_2",
"hasEDSP", "hasARMv6", "hasARMv7", "hasNEON", "isWow64",
"profileHDDModel", "profileHDDRevision"];
"profileHDDModel", "profileHDDRevision", "binHDDModel",
"binHDDRevision", "winHDDModel", "winHDDRevision"];
for each (let field in fields) {
let value;
try {

View File

@ -17,6 +17,7 @@
#include <winioctl.h>
#include "base/scoped_handle_win.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#endif
@ -41,13 +42,14 @@ NS_EXPORT int android_sdk_version;
#if defined(XP_WIN)
namespace {
nsresult GetProfileHDDInfo(nsAutoCString& aModel, nsAutoCString& aRevision)
nsresult GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
nsAutoCString& aRevision)
{
aModel.Truncate();
aRevision.Truncate();
nsCOMPtr<nsIFile> profDir;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
nsresult rv = NS_GetSpecialDirectory(aSpecialDirName,
getter_AddRefs(profDir));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString profDirPath;
@ -198,13 +200,28 @@ nsSystemInfo::Init()
return rv;
}
nsAutoCString hddModel, hddRevision;
if (NS_SUCCEEDED(GetProfileHDDInfo(hddModel, hddRevision))) {
if (NS_SUCCEEDED(GetHDDInfo(NS_APP_USER_PROFILE_50_DIR, hddModel,
hddRevision))) {
rv = SetPropertyAsACString(NS_LITERAL_STRING("profileHDDModel"), hddModel);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPropertyAsACString(NS_LITERAL_STRING("profileHDDRevision"),
hddRevision);
NS_ENSURE_SUCCESS(rv, rv);
}
if (NS_SUCCEEDED(GetHDDInfo(NS_GRE_DIR, hddModel, hddRevision))) {
rv = SetPropertyAsACString(NS_LITERAL_STRING("binHDDModel"), hddModel);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPropertyAsACString(NS_LITERAL_STRING("binHDDRevision"),
hddRevision);
NS_ENSURE_SUCCESS(rv, rv);
}
if (NS_SUCCEEDED(GetHDDInfo(NS_WIN_WINDOWS_DIR, hddModel, hddRevision))) {
rv = SetPropertyAsACString(NS_LITERAL_STRING("winHDDModel"), hddModel);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPropertyAsACString(NS_LITERAL_STRING("winHDDRevision"),
hddRevision);
NS_ENSURE_SUCCESS(rv, rv);
}
#endif
#if defined(MOZ_WIDGET_GTK)