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_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chromeos/chromeos_export.h" |
| 12 #include "chromeos/dbus/media_analytics_client.h" |
| 13 #include "chromeos/media_perception/media_perception.pb.h" |
| 14 |
| 15 namespace chromeos { |
| 16 |
| 17 // MediaAnalyticsClient is used to communicate with a media analytics process |
| 18 // running outside of Chrome. The FakeMediaAnalyticsClient is used for |
| 19 // integration testing the MediaPerceptionPrivate API without any requirement on |
| 20 // D-Bus communications to an external process. |
| 21 class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { |
| 22 public: |
| 23 FakeMediaAnalyticsClient(); |
| 24 ~FakeMediaAnalyticsClient() override; |
| 25 |
| 26 // Used for Upstart D-Bus command to start the media analytics process. |
| 27 // These do nothing in the fake D-Bus client. |
| 28 void StartMediaAnalytics(const UpstartCallback& callback) override; |
| 29 void RestartMediaAnalytics(const UpstartCallback& callback) override; |
| 30 |
| 31 // Inherited from MediaAnalyticsClient. |
| 32 void State(const uint8_t* bytes, |
| 33 size_t length, |
| 34 const StateCallback& callback) override; |
| 35 |
| 36 void SetMediaPerceptionSignalHandler( |
| 37 const MediaPerceptionSignalHandler& handler) override; |
| 38 |
| 39 void GetDiagnostics(const DiagnoticsCallback& callback) override; |
| 40 |
| 41 // Inherited from DBusClient. |
| 42 void Init(dbus::Bus* bus) override; |
| 43 |
| 44 private: |
| 45 // Simply echoes back the previously set state. |
| 46 void OnState(const StateCallback& callback); |
| 47 |
| 48 // Returns a fake, nearly empty serialized Diagnostic proto. |
| 49 void OnGetDiagnostics(const DiagnoticsCallback& callback); |
| 50 |
| 51 // Returns a fake, nearly empty serialized MediaPerception proto. |
| 52 void OnMediaPerception(); |
| 53 |
| 54 // Stores a handler for receiving MediaPerception proto messages. |
| 55 MediaPerceptionSignalHandler media_perception_signal_handler_; |
| 56 |
| 57 // Stores the current state of the fake system. |
| 58 mri::State state_; |
| 59 |
| 60 base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); |
| 63 }; |
| 64 |
| 65 } // namespace chromeos |
| 66 |
| 67 #endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
OLD | NEW |