Commit 709d6095 authored by Bettina's avatar Bettina Committed by Commit Bot

Remove WriteScanTime and UwSScanTimes histogram recording

WriteScanTime method is not called anymore
in Chrome Cleanup Tool. Thus, there is no
point in recording SoftwareReporter.UwSScanTimes
histogram anymore.

Bug: 1055885
Change-Id: I9be90ede011667285129eb2e9f9802ddd35570a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090591
Commit-Queue: Bettina Dea <bdea@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747808}
parent e69d9e34
......@@ -122,7 +122,6 @@ internal::SwReporterTestingDelegate* g_testing_delegate_ = nullptr;
const char kFoundUwsMetricName[] = "SoftwareReporter.FoundUwS";
const char kFoundUwsReadErrorMetricName[] =
"SoftwareReporter.FoundUwSReadError";
const char kScanTimesMetricName[] = "SoftwareReporter.UwSScanTimes";
const char kMemoryUsedMetricName[] = "SoftwareReporter.MemoryUsed";
const char kStepMetricName[] = "SoftwareReporter.Step";
const char kLogsUploadEnabledMetricName[] =
......@@ -314,45 +313,6 @@ class UMAHistogramReporter {
}
}
// Reports the UwS scan times of the software reporter tool via UMA.
void ReportScanTimes() const {
base::string16 scan_times_key_path = base::StringPrintf(
L"%ls\\%ls", registry_key_.c_str(), chrome_cleaner::kScanTimesSubKey);
// TODO(b/641081): This should only have KEY_QUERY_VALUE and KEY_SET_VALUE.
base::win::RegKey scan_times_key;
if (scan_times_key.Open(HKEY_CURRENT_USER, scan_times_key_path.c_str(),
KEY_ALL_ACCESS) != ERROR_SUCCESS) {
return;
}
base::string16 value_name;
int uws_id = 0;
int64_t raw_scan_time = 0;
int num_scan_times = scan_times_key.GetValueCount();
for (int i = 0; i < num_scan_times; ++i) {
if (scan_times_key.GetValueNameAt(i, &value_name) == ERROR_SUCCESS &&
base::StringToInt(value_name, &uws_id) &&
scan_times_key.ReadInt64(value_name.c_str(), &raw_scan_time) ==
ERROR_SUCCESS) {
base::TimeDelta scan_time =
base::TimeDelta::FromInternalValue(raw_scan_time);
// We report the number of seconds plus one because it can take less
// than one second to scan some UwS and the count passed to |AddCount|
// must be at least one.
RecordSparseHistogramCount(kScanTimesMetricName, uws_id,
scan_time.InSeconds() + 1);
}
}
// Clean up by deleting the scan times key, which is a subkey of the main
// reporter key.
scan_times_key.Close();
base::win::RegKey reporter_key;
if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(),
KEY_ENUMERATE_SUB_KEYS) == ERROR_SUCCESS) {
reporter_key.DeleteKey(chrome_cleaner::kScanTimesSubKey);
}
}
void RecordReporterStep(SwReporterUmaValue value) {
RecordEnumerationHistogram(kStepMetricName, value, SW_REPORTER_MAX);
}
......@@ -458,15 +418,6 @@ class UMAHistogramReporter {
histogram->Add(sample);
}
void RecordSparseHistogramCount(const std::string& name,
Sample sample,
int count) const {
auto* histogram =
base::SparseHistogram::FactoryGet(FullName(name), kUmaHistogramFlag);
if (histogram)
histogram->AddCount(sample, count);
}
const std::string suffix_;
const std::wstring registry_key_;
};
......@@ -759,7 +710,6 @@ class ReporterRunner {
now.ToInternalValue());
}
uma.ReportRuntime(reporter_running_time);
uma.ReportScanTimes();
uma.ReportMemoryUsage();
if (finished_invocation.reporter_logs_upload_enabled())
uma.RecordLogsUploadResult();
......
......@@ -152,17 +152,6 @@ void RegistryLogger::ClearScanTimes() {
CreateRegKey(&scan_times_key_, GetScanTimesKeyPath(mode_));
}
void RegistryLogger::WriteScanTime(UwSId pup_id,
const base::TimeDelta& scan_time) {
if (!scan_times_key_.Valid())
return;
int64_t scan_time_serialized = scan_time.InMicroseconds();
scan_times_key_.WriteValue(base::NumberToString16(pup_id).c_str(),
&scan_time_serialized,
sizeof(scan_time_serialized), REG_QWORD);
}
void RegistryLogger::WriteMemoryUsage(size_t memory_used_kb) {
if (logging_key_.Valid()) {
DWORD memory = memory_used_kb;
......
......@@ -64,9 +64,6 @@ class RegistryLogger {
// object.
void ClearScanTimes();
// Write the scan time of PUP with ID |pup_id| to the key specified by |mode|.
void WriteScanTime(UwSId pup_id, const base::TimeDelta& scan_time);
// Write |memory_usage_kb| to the key specified by |mode|. |memory_used_kb|
// must be given in units of KBs.
void WriteMemoryUsage(size_t memory_used_kb);
......
......@@ -132,30 +132,6 @@ TEST_F(RegistryLoggerTest, WriteReporterLogsUploadResult) {
upload_result);
}
TEST_F(RegistryLoggerTest, WriteAndClearScanTimes) {
const RegistryLogger::Mode mode = RegistryLogger::Mode::REPORTER;
TestRegistryLogger logger(mode);
base::TimeDelta scan_time = base::TimeDelta::FromSeconds(3);
logger.WriteScanTime(42, scan_time);
base::win::RegKey scan_times_key;
ASSERT_TRUE(
OpenScanTimeRegKey(&scan_times_key, logger, KEY_QUERY_VALUE, mode));
int64_t us_scan_time = 0;
LONG result = scan_times_key.ReadInt64(L"42", &us_scan_time);
EXPECT_EQ(ERROR_SUCCESS, result);
base::TimeDelta read_scan_time =
base::TimeDelta::FromMicroseconds(us_scan_time);
EXPECT_EQ(read_scan_time, scan_time);
logger.ClearScanTimes();
ASSERT_TRUE(
OpenScanTimeRegKey(&scan_times_key, logger, KEY_QUERY_VALUE, mode));
EXPECT_EQ(0U, scan_times_key.GetValueCount());
}
TEST_F(RegistryLoggerTest, AppendLogUploadResultMaxLength) {
const RegistryLogger::Mode mode = RegistryLogger::Mode::REMOVER;
TestRegistryLogger logger(RegistryLogger::Mode::REMOVER);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment