Commit 30326986 authored by Luke Sorenson's avatar Luke Sorenson Committed by Commit Bot

Add Mojo bootstrapping interface to the MediaAnalyticsDbusClient.

Bug: b:74589757
Bug: 842718, 799739
Change-Id: I84f667ea521677928ef1b2c4f7f841ed2c0d11c2
Reviewed-on: https://chromium-review.googlesource.com/1042364
Commit-Queue: Luke Sorenson <lasoren@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568029}
parent 68e75c9d
...@@ -104,6 +104,13 @@ void FakeMediaAnalyticsClient::GetDiagnostics( ...@@ -104,6 +104,13 @@ void FakeMediaAnalyticsClient::GetDiagnostics(
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void FakeMediaAnalyticsClient::BootstrapMojoConnection(
base::ScopedFD file_descriptor,
VoidDBusMethodCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), false));
}
void FakeMediaAnalyticsClient::OnGetDiagnostics( void FakeMediaAnalyticsClient::OnGetDiagnostics(
DBusMethodCallback<mri::Diagnostics> callback) { DBusMethodCallback<mri::Diagnostics> callback) {
std::move(callback).Run(diagnostics_); std::move(callback).Run(diagnostics_);
......
...@@ -29,6 +29,8 @@ class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { ...@@ -29,6 +29,8 @@ class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient {
void SetState(const mri::State& state, void SetState(const mri::State& state,
DBusMethodCallback<mri::State> callback) override; DBusMethodCallback<mri::State> callback) override;
void GetDiagnostics(DBusMethodCallback<mri::Diagnostics> callback) override; void GetDiagnostics(DBusMethodCallback<mri::Diagnostics> callback) override;
void BootstrapMojoConnection(base::ScopedFD file_descriptor,
VoidDBusMethodCallback callback) override;
// Inherited from DBusClient. // Inherited from DBusClient.
void Init(dbus::Bus* bus) override; void Init(dbus::Bus* bus) override;
......
...@@ -70,6 +70,20 @@ class MediaAnalyticsClientImpl : public MediaAnalyticsClient { ...@@ -70,6 +70,20 @@ class MediaAnalyticsClientImpl : public MediaAnalyticsClient {
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void BootstrapMojoConnection(base::ScopedFD file_descriptor,
VoidDBusMethodCallback callback) override {
dbus::MethodCall method_call(media_perception::kMediaPerceptionServiceName,
media_perception::kBootstrapMojoConnection);
dbus::MessageWriter writer(&method_call);
writer.AppendFileDescriptor(file_descriptor.get());
dbus_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(
&MediaAnalyticsClientImpl::OnBootstrapMojoConnectionCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
protected: protected:
void Init(dbus::Bus* bus) override { void Init(dbus::Bus* bus) override {
dbus_proxy_ = bus->GetObjectProxy( dbus_proxy_ = bus->GetObjectProxy(
...@@ -86,6 +100,11 @@ class MediaAnalyticsClientImpl : public MediaAnalyticsClient { ...@@ -86,6 +100,11 @@ class MediaAnalyticsClientImpl : public MediaAnalyticsClient {
} }
private: private:
void OnBootstrapMojoConnectionCallback(VoidDBusMethodCallback callback,
dbus::Response* response) {
std::move(callback).Run(response != nullptr);
}
void OnSignalConnected(const std::string& interface, void OnSignalConnected(const std::string& interface,
const std::string& signal, const std::string& signal,
bool succeeded) { bool succeeded) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROMEOS_DBUS_MEDIA_ANALYTICS_CLIENT_H_ #define CHROMEOS_DBUS_MEDIA_ANALYTICS_CLIENT_H_
#include "base/callback.h" #include "base/callback.h"
#include "base/files/scoped_file.h"
#include "base/macros.h" #include "base/macros.h"
#include "chromeos/chromeos_export.h" #include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h" #include "chromeos/dbus/dbus_client.h"
...@@ -47,6 +48,12 @@ class CHROMEOS_EXPORT MediaAnalyticsClient : public DBusClient { ...@@ -47,6 +48,12 @@ class CHROMEOS_EXPORT MediaAnalyticsClient : public DBusClient {
virtual void GetDiagnostics( virtual void GetDiagnostics(
DBusMethodCallback<mri::Diagnostics> callback) = 0; DBusMethodCallback<mri::Diagnostics> callback) = 0;
// Bootstrap the Mojo connection between Chrome and the media analytics
// process. Should pass in the file descriptor for the child end of the Mojo
// pipe.
virtual void BootstrapMojoConnection(base::ScopedFD file_descriptor,
VoidDBusMethodCallback callback) = 0;
// Factory function, creates new instance and returns ownership. // Factory function, creates new instance and returns ownership.
// For normal usage, access the singleton via DbusThreadManager::Get(). // For normal usage, access the singleton via DbusThreadManager::Get().
static MediaAnalyticsClient* Create(); static MediaAnalyticsClient* Create();
......
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