This source file includes following definitions.
- FindTestInfo
- GetTestName
- GetTestDescription
- RecordUMARecoveryResult
- RecordUMATestResult
#include "chrome/browser/diagnostics/diagnostics_metrics.h"
#include <string>
#include "base/basictypes.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/diagnostics/diagnostics_test.h"
namespace diagnostics {
namespace {
struct TestNameInfo {
const char* name;
const char* description;
};
const TestNameInfo kTestNameInfo[] = {
{"ConflictingDlls", "Conflicting modules"},
{"DiskSpace", "Available disk space"},
{"InstallType", "Install type"},
{"JSONBookmarks", "Bookmark file"},
{"JSONLocalState", "Local state integrity"},
{"JSONPreferences", "User preferences integrity"},
{"OperatingSystem", "Operating system supported version"},
{"PathDictionaries", "App dictionaries directory path"},
{"PathLocalState", "Local state path"},
{"PathResources", "Resources path"},
{"PathUserData", "User data path"},
{"Version", "Chrome version test"},
{"SQLiteIntegrityAppCache", "Application cache database"},
{"SQLiteIntegrityArchivedHistory", "Archived history database"},
{"SQLiteIntegrityCookie", "Cookie database"},
{"SQLiteIntegrityDatabaseTracker", "Database tracker database"},
{"SQLiteIntegrityHistory", "History database"},
{"SQLiteIntegrityNSSCert", "NSS certificate database"},
{"SQLiteIntegrityNSSKey", "NSS Key database"},
{"SQLiteIntegrityThumbnails", "Thumbnails database"},
{"SQLiteIntegrityWebData", "Web Data database"},
};
COMPILE_ASSERT(arraysize(kTestNameInfo) == DIAGNOSTICS_TEST_ID_COUNT,
diagnostics_test_info_mismatch);
const TestNameInfo* FindTestInfo(DiagnosticsTestId id) {
DCHECK(id < DIAGNOSTICS_TEST_ID_COUNT);
return &kTestNameInfo[id];
}
}
std::string GetTestName(DiagnosticsTestId id) {
return std::string(FindTestInfo(id)->name);
}
std::string GetTestDescription(DiagnosticsTestId id) {
return std::string(FindTestInfo(id)->description);
}
#define TEST_CASE(name, id) \
case id: \
UMA_HISTOGRAM_ENUMERATION(name, result, RESULT_COUNT); \
break
#define TEST_CASES(name) \
TEST_CASE(name, DIAGNOSTICS_CONFLICTING_DLLS_TEST); \
TEST_CASE(name, DIAGNOSTICS_DISK_SPACE_TEST); \
TEST_CASE(name, DIAGNOSTICS_INSTALL_TYPE_TEST); \
TEST_CASE(name, DIAGNOSTICS_JSON_BOOKMARKS_TEST); \
TEST_CASE(name, DIAGNOSTICS_JSON_LOCAL_STATE_TEST); \
TEST_CASE(name, DIAGNOSTICS_JSON_PREFERENCES_TEST); \
TEST_CASE(name, DIAGNOSTICS_OPERATING_SYSTEM_TEST); \
TEST_CASE(name, DIAGNOSTICS_PATH_DICTIONARIES_TEST); \
TEST_CASE(name, DIAGNOSTICS_PATH_LOCAL_STATE_TEST); \
TEST_CASE(name, DIAGNOSTICS_PATH_RESOURCES_TEST); \
TEST_CASE(name, DIAGNOSTICS_PATH_USER_DATA_TEST); \
TEST_CASE(name, DIAGNOSTICS_VERSION_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_APP_CACHE_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_ARCHIVED_HISTORY_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_COOKIE_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_DATABASE_TRACKER_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_HISTORY_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_NSS_CERT_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_NSS_KEY_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_THUMBNAILS_TEST); \
TEST_CASE(name, DIAGNOSTICS_SQLITE_INTEGRITY_WEB_DATA_TEST)
void RecordUMARecoveryResult(DiagnosticsTestId id, RunResultMetrics result) {
const std::string name("Diagnostics.Recovery." +
GetTestName(static_cast<DiagnosticsTestId>(id)));
switch (id) {
TEST_CASES(name);
default:
NOTREACHED() << "Unhandled UMA Metric type" << id;
}
}
void RecordUMATestResult(DiagnosticsTestId id, RunResultMetrics result) {
const std::string name("Diagnostics.Test." +
GetTestName(static_cast<DiagnosticsTestId>(id)));
switch (id) {
TEST_CASES(name);
default:
NOTREACHED() << "Unhandled UMA Metric type" << id;
}
}
#undef TEST_CASE
#undef TEST_CASES
}