OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMEOS_DBUS_MEDIA_ANALYTICS_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_MEDIA_ANALYTICS_CLIENT_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "chromeos/chromeos_export.h" |
| 11 #include "chromeos/dbus/dbus_client.h" |
| 12 #include "chromeos/media_perception/media_perception.pb.h" |
| 13 |
| 14 namespace chromeos { |
| 15 |
| 16 // MediaAnalyticsClient is used to communicate with a media analytics process |
| 17 // running outside of Chrome. |
| 18 class CHROMEOS_EXPORT MediaAnalyticsClient : public DBusClient { |
| 19 public: |
| 20 using UpstartCallback = base::Callback<void(bool succeeded)>; |
| 21 // Callback type for a State proto message received from the media analytics |
| 22 // process. |
| 23 using StateCallback = |
| 24 base::Callback<void(bool succeeded, const mri::State& state)>; |
| 25 // Handler type for signal received from media analytics process. Contains a |
| 26 // byte array with a serialized MediaPerception proto. |
| 27 using MediaPerceptionSignalHandler = |
| 28 base::Callback<void(const mri::MediaPerception& media_perception)>; |
| 29 // Callback type for a Diagnostics proto message received from the media |
| 30 // analytics process. |
| 31 using DiagnosticsCallback = |
| 32 base::Callback<void(bool succeeded, const mri::Diagnostics& diagnostics)>; |
| 33 |
| 34 ~MediaAnalyticsClient() override; |
| 35 |
| 36 // Start the analytics binary with upstart using D-Bus method call. |
| 37 virtual void StartMediaAnalytics(const UpstartCallback& callback) = 0; |
| 38 |
| 39 // Restart the analytics binary with upstart using D-Bus method call. |
| 40 virtual void RestartMediaAnalytics(const UpstartCallback& callback) = 0; |
| 41 |
| 42 // API for getting and setting the state of the media analytics process over |
| 43 // D-Bus using a State proto. |
| 44 virtual void State(const mri::State& state, |
| 45 const StateCallback& callback) = 0; |
| 46 |
| 47 // Register event handler for the MediaPerception protos received as signal |
| 48 // from the media analytics process. |
| 49 virtual void SetMediaPerceptionSignalHandler( |
| 50 const MediaPerceptionSignalHandler& handler) = 0; |
| 51 |
| 52 virtual void UnsetMediaPerceptionSignalHandler() = 0; |
| 53 |
| 54 // API for getting diagnostic information from the media analytics process |
| 55 // over D-Bus as a Diagnostics proto message. |
| 56 virtual void GetDiagnostics(const DiagnosticsCallback& callback) = 0; |
| 57 |
| 58 // Factory function, creates new instance and returns ownership. |
| 59 // For normal usage, access the singleton via DbusThreadManager::Get(). |
| 60 static MediaAnalyticsClient* Create(); |
| 61 |
| 62 protected: |
| 63 MediaAnalyticsClient(); |
| 64 |
| 65 private: |
| 66 DISALLOW_COPY_AND_ASSIGN(MediaAnalyticsClient); |
| 67 }; |
| 68 |
| 69 } // namespace chromeos |
| 70 |
| 71 #endif // CHROMEOS_DBUS_MEDIA_ANALYTICS_CLIENT_H_ |
OLD | NEW |