Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8370)

Unified Diff: chromeos/dbus/upstart_client.cc

Issue 2791983004: DBus MediaAnalyticsClient and media_perception pb. (Closed)
Patch Set: Changing the type of a couple vars to const. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/upstart_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/upstart_client.cc
diff --git a/chromeos/dbus/upstart_client.cc b/chromeos/dbus/upstart_client.cc
index 2f4d61555fff317b016b02bfa5ac9c734720dc86..066676388416212215ad6a4b4b8346ffb51fd7b6 100644
--- a/chromeos/dbus/upstart_client.cc
+++ b/chromeos/dbus/upstart_client.cc
@@ -18,8 +18,11 @@ const char kUpstartServiceName[] = "com.ubuntu.Upstart";
const char kUpstartJobInterface[] = "com.ubuntu.Upstart0_6.Job";
const char kUpstartStartMethod[] = "Start";
const char kUpstartRestartMethod[] = "Restart";
+const char kUpstartStopMethod[] = "Stop";
const char kUpstartAuthPolicyPath[] = "/com/ubuntu/Upstart/jobs/authpolicyd";
+const char kUpstartMediaAnalyticsPath[] =
+ "/com/ubuntu/Upstart/jobs/rtanalytics";
class UpstartClientImpl : public UpstartClient {
public:
@@ -50,11 +53,35 @@ class UpstartClientImpl : public UpstartClient {
weak_ptr_factory_.GetWeakPtr()));
}
+ void StartMediaAnalytics(const UpstartCallback& callback) override {
+ dbus::MethodCall method_call(kUpstartJobInterface, kUpstartStartMethod);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendArrayOfStrings(std::vector<std::string>());
+ writer.AppendBool(true); // Wait for response.
+ ma_proxy_->CallMethod(
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&UpstartClientImpl::HandleStartMediaAnalyticsResponse,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+ }
+
+ void StopMediaAnalytics() override {
+ dbus::MethodCall method_call(kUpstartJobInterface, kUpstartStopMethod);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendArrayOfStrings(std::vector<std::string>());
+ writer.AppendBool(true); // Wait for response.
+ ma_proxy_->CallMethod(
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&UpstartClientImpl::HandleStopMediaAnalyticsResponse,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+
protected:
void Init(dbus::Bus* bus) override {
bus_ = bus;
auth_proxy_ = bus_->GetObjectProxy(
kUpstartServiceName, dbus::ObjectPath(kUpstartAuthPolicyPath));
+ ma_proxy_ = bus_->GetObjectProxy(
+ kUpstartServiceName, dbus::ObjectPath(kUpstartMediaAnalyticsPath));
}
private:
@@ -62,8 +89,23 @@ class UpstartClientImpl : public UpstartClient {
LOG_IF(ERROR, !response) << "Failed to signal Upstart, response is null";
}
+ void HandleStartMediaAnalyticsResponse(const UpstartCallback& callback,
+ dbus::Response* response) {
+ if (!response) {
+ LOG(ERROR) << "Failed to signal Upstart, response is null.";
+ callback.Run(false);
+ return;
+ }
+ callback.Run(true);
+ }
+
+ void HandleStopMediaAnalyticsResponse(dbus::Response* response) {
+ LOG_IF(ERROR, !response) << "Failed to signal Upstart, response is null";
+ }
+
dbus::Bus* bus_ = nullptr;
dbus::ObjectProxy* auth_proxy_ = nullptr;
+ dbus::ObjectProxy* ma_proxy_ = nullptr;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
« no previous file with comments | « chromeos/dbus/upstart_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698