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

Side by Side Diff: chromeos/dbus/fake_media_analytics_client.h

Issue 2791983004: DBus MediaAnalyticsClient and media_perception pb. (Closed)
Patch Set: Upstart process management 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 unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698