Chromium Code Reviews| 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. | |
| 19 class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { | |
| 20 public: | |
| 21 FakeMediaAnalyticsClient(); | |
| 22 ~FakeMediaAnalyticsClient() override; | |
| 23 | |
| 24 // Inherited from MediaAnalyticsClient. | |
| 25 void GetState(const StateCallback& callback) override; | |
| 26 void SetState(const mri::State& state, | |
| 27 const StateCallback& callback) override; | |
| 28 void SetMediaPerceptionSignalHandler( | |
| 29 const MediaPerceptionSignalHandler& handler) override; | |
| 30 void ClearMediaPerceptionSignalHandler() override; | |
| 31 | |
|
tbarzic
2017/05/11 18:49:57
nit: no new line here
Luke Sorenson
2017/05/11 22:01:55
Done.
| |
| 32 void GetDiagnostics(const DiagnosticsCallback& callback) override; | |
| 33 | |
| 34 // Inherited from DBusClient. | |
| 35 void Init(dbus::Bus* bus) override; | |
| 36 | |
| 37 // Fires a fake media perception event. | |
| 38 bool FireMediaPerceptionEvent(mri::MediaPerception media_perception); | |
| 39 | |
| 40 // Sets the object to be returned from GetDiagnostics. | |
| 41 void SetDiagnostics(mri::Diagnostics diagnostics); | |
| 42 | |
| 43 void set_process_running(bool running) { process_running_ = running; } | |
| 44 | |
| 45 bool process_running() const { return process_running_; } | |
| 46 | |
| 47 private: | |
| 48 // Echoes back the previously set state. | |
| 49 void OnState(const StateCallback& callback); | |
| 50 | |
| 51 // Callback fires the Diagnostics proto provided in SetDiagnostics. | |
|
tbarzic
2017/05/11 18:49:57
Runs callback with ...
Luke Sorenson
2017/05/11 22:01:56
Done.
| |
| 52 void OnGetDiagnostics(const DiagnosticsCallback& callback); | |
| 53 | |
| 54 // Callback fires a MediaPerception proto provided in | |
|
tbarzic
2017/05/11 18:49:57
Runs callback with ...
Luke Sorenson
2017/05/11 22:01:55
Done.
| |
| 55 // FireMediaPerceptionEvent. | |
| 56 void OnMediaPerception(mri::MediaPerception media_perception); | |
| 57 | |
| 58 // Stores a handler for receiving MediaPerception proto messages. | |
| 59 MediaPerceptionSignalHandler media_perception_signal_handler_; | |
| 60 | |
| 61 // Stores a fake current state for the media analytics process. | |
|
tbarzic
2017/05/11 18:49:57
nit: drop "Stores" in these comments
Luke Sorenson
2017/05/11 22:01:55
Done.
| |
| 62 mri::State current_state_; | |
| 63 | |
| 64 // Stores a fake diagnostics object to be returned by the GetDiagnostics. | |
| 65 mri::Diagnostics diagnostics_; | |
| 66 | |
| 67 // Whether the fake media analytics was started (for example by the fake | |
| 68 // upstart client) - If not set, all requests to this client will fail. | |
| 69 bool process_running_; | |
| 70 | |
| 71 base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); | |
| 74 }; | |
| 75 | |
| 76 } // namespace chromeos | |
| 77 | |
| 78 #endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ | |
| OLD | NEW |