Merge "metricsd: Split out the trait name from the command name"

This commit is contained in:
Alex Vakulenko 2016-01-08 22:00:35 +00:00 committed by Gerrit Code Review
commit c480b8e6dd
1 changed files with 6 additions and 8 deletions

View File

@ -71,6 +71,7 @@ const char kMeminfoFileName[] = "/proc/meminfo";
const char kVmStatFileName[] = "/proc/vmstat";
const char kWeaveComponent[] = "metrics";
const char kWeaveTrait[] = "_metrics";
} // namespace
@ -259,15 +260,13 @@ void MetricsCollector::OnWeaveServiceConnected(
if (!weave_service)
return;
weave_service->AddComponent(kWeaveComponent, {"_metrics"}, nullptr);
weave_service->AddComponent(kWeaveComponent, {kWeaveTrait}, nullptr);
weave_service->AddCommandHandler(
kWeaveComponent,
"_metrics.enableAnalyticsReporting",
kWeaveComponent, kWeaveTrait, "enableAnalyticsReporting",
base::Bind(&MetricsCollector::OnEnableMetrics,
weak_ptr_factory_.GetWeakPtr()));
weave_service->AddCommandHandler(
kWeaveComponent,
"_metrics.disableAnalyticsReporting",
kWeaveComponent, kWeaveTrait, "disableAnalyticsReporting",
base::Bind(&MetricsCollector::OnDisableMetrics,
weak_ptr_factory_.GetWeakPtr()));
@ -311,9 +310,8 @@ void MetricsCollector::UpdateWeaveState() {
std::string enabled =
metrics_lib_->AreMetricsEnabled() ? "enabled" : "disabled";
if (!weave_service->SetStateProperty(kWeaveComponent,
"_metrics.analyticsReportingState",
enabled,
if (!weave_service->SetStateProperty(kWeaveComponent, kWeaveTrait,
"analyticsReportingState", enabled,
nullptr)) {
LOG(ERROR) << "failed to update weave's state";
}