metricsd: Removing brillo::Any from weaved's public APIs
Weaved replaces brillo::Any with base::Value in its client library, so need to update clients. Also this removes last D-Bus dependencies from metrics_collector. BUG: 26558300 Change-Id: I82d571d7e2bd17347daeb1b70f48ec05378894f0
This commit is contained in:
parent
36ba2fad01
commit
eca14e3722
|
@ -72,10 +72,7 @@ metrics_includes := external/gtest/include \
|
|||
libmetrics_shared_libraries := libchrome libbinder libbrillo libutils
|
||||
metrics_collector_shared_libraries := $(libmetrics_shared_libraries) \
|
||||
libbrillo-binder \
|
||||
libbrillo-dbus \
|
||||
libbrillo-http \
|
||||
libchrome-dbus \
|
||||
libdbus \
|
||||
libmetrics \
|
||||
librootdev \
|
||||
libweaved
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "averaged_statistics_collector.h"
|
||||
|
||||
#include <base/bind.h>
|
||||
#include <base/files/file_util.h>
|
||||
#include <base/files/file_path.h>
|
||||
#include <base/strings/string_number_conversions.h>
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include <base/strings/stringprintf.h>
|
||||
#include <brillo/binder_watcher.h>
|
||||
#include <brillo/osrelease_reader.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/message.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "metrics_collector_service_impl.h"
|
||||
|
@ -142,7 +140,7 @@ int MetricsCollector::Run() {
|
|||
// Watch Binder events in the main loop
|
||||
brillo::BinderWatcher binder_watcher;
|
||||
CHECK(binder_watcher.Init()) << "Binder FD watcher init failed";
|
||||
return brillo::DBusDaemon::Run();
|
||||
return brillo::Daemon::Run();
|
||||
}
|
||||
|
||||
uint32_t MetricsCollector::GetOsVersionHash() {
|
||||
|
@ -218,7 +216,7 @@ void MetricsCollector::Init(bool testing, MetricsLibraryInterface* metrics_lib,
|
|||
}
|
||||
|
||||
int MetricsCollector::OnInit() {
|
||||
int return_code = brillo::DBusDaemon::OnInit();
|
||||
int return_code = brillo::Daemon::OnInit();
|
||||
if (return_code != EX_OK)
|
||||
return return_code;
|
||||
|
||||
|
@ -232,9 +230,6 @@ int MetricsCollector::OnInit() {
|
|||
if (testing_)
|
||||
return EX_OK;
|
||||
|
||||
bus_->AssertOnDBusThread();
|
||||
CHECK(bus_->SetUpAsyncOperations());
|
||||
|
||||
weave_service_subscription_ = weaved::Service::Connect(
|
||||
brillo::MessageLoop::current(),
|
||||
base::Bind(&MetricsCollector::OnWeaveServiceConnected,
|
||||
|
@ -249,10 +244,6 @@ int MetricsCollector::OnInit() {
|
|||
return EX_OK;
|
||||
}
|
||||
|
||||
void MetricsCollector::OnShutdown(int* return_code) {
|
||||
brillo::DBusDaemon::OnShutdown(return_code);
|
||||
}
|
||||
|
||||
void MetricsCollector::OnWeaveServiceConnected(
|
||||
const std::weak_ptr<weaved::Service>& service) {
|
||||
service_ = service;
|
||||
|
@ -311,7 +302,8 @@ void MetricsCollector::UpdateWeaveState() {
|
|||
metrics_lib_->AreMetricsEnabled() ? "enabled" : "disabled";
|
||||
|
||||
if (!weave_service->SetStateProperty(kWeaveComponent, kWeaveTrait,
|
||||
"analyticsReportingState", enabled,
|
||||
"analyticsReportingState",
|
||||
*brillo::ToValue(enabled),
|
||||
nullptr)) {
|
||||
LOG(ERROR) << "failed to update weave's state";
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <base/memory/weak_ptr.h>
|
||||
#include <base/time/time.h>
|
||||
#include <brillo/binder_watcher.h>
|
||||
#include <brillo/daemons/dbus_daemon.h>
|
||||
#include <brillo/daemons/daemon.h>
|
||||
#include <libweaved/command.h>
|
||||
#include <libweaved/service.h>
|
||||
#include <gtest/gtest_prod.h> // for FRIEND_TEST
|
||||
|
@ -42,7 +42,7 @@
|
|||
using chromeos_metrics::PersistentInteger;
|
||||
using std::unique_ptr;
|
||||
|
||||
class MetricsCollector : public brillo::DBusDaemon {
|
||||
class MetricsCollector : public brillo::Daemon {
|
||||
public:
|
||||
MetricsCollector();
|
||||
~MetricsCollector();
|
||||
|
@ -54,12 +54,9 @@ class MetricsCollector : public brillo::DBusDaemon {
|
|||
const base::FilePath& private_metrics_directory,
|
||||
const base::FilePath& shared_metrics_directory);
|
||||
|
||||
// Initializes DBus and MessageLoop variables before running the MessageLoop.
|
||||
// Initializes the daemon.
|
||||
int OnInit() override;
|
||||
|
||||
// Clean up data set up in OnInit before shutting down message loop.
|
||||
void OnShutdown(int* return_code) override;
|
||||
|
||||
// Does all the work.
|
||||
int Run() override;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
service metricscollector /system/bin/metrics_collector --foreground --logtosyslog
|
||||
class late_start
|
||||
user metrics_coll
|
||||
group metrics_coll dbus
|
||||
group metrics_coll
|
||||
|
|
|
@ -64,37 +64,6 @@ class MetricsCollectorTest : public testing::Test {
|
|||
.RetiresOnSaturation();
|
||||
}
|
||||
|
||||
// Creates a new DBus signal message with zero or more string arguments.
|
||||
// The message can be deallocated through DeleteDBusMessage.
|
||||
//
|
||||
// |path| is the object emitting the signal.
|
||||
// |interface| is the interface the signal is emitted from.
|
||||
// |name| is the name of the signal.
|
||||
// |arg_values| contains the values of the string arguments.
|
||||
DBusMessage* NewDBusSignalString(const string& path,
|
||||
const string& interface,
|
||||
const string& name,
|
||||
const vector<string>& arg_values) {
|
||||
DBusMessage* msg = dbus_message_new_signal(path.c_str(),
|
||||
interface.c_str(),
|
||||
name.c_str());
|
||||
DBusMessageIter iter;
|
||||
dbus_message_iter_init_append(msg, &iter);
|
||||
for (vector<string>::const_iterator it = arg_values.begin();
|
||||
it != arg_values.end(); ++it) {
|
||||
const char* str_value = it->c_str();
|
||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &str_value);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
// Deallocates the DBus message |msg| previously allocated through
|
||||
// dbus_message_new*.
|
||||
void DeleteDBusMessage(DBusMessage* msg) {
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
||||
// Creates or overwrites the file in |path| so that it contains the printable
|
||||
// representation of |value|.
|
||||
void CreateUint64ValueFile(const base::FilePath& path, uint64_t value) {
|
||||
|
|
|
@ -6,4 +6,4 @@ on post-fs-data
|
|||
service metricsd /system/bin/metricsd --foreground --logtosyslog
|
||||
class late_start
|
||||
user metricsd
|
||||
group system dbus inet
|
||||
group system inet
|
||||
|
|
Loading…
Reference in New Issue