Chromium Code Reviews| Index: chromeos/dbus/fake_media_analytics_client.h |
| diff --git a/chromeos/dbus/fake_media_analytics_client.h b/chromeos/dbus/fake_media_analytics_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..851fe3ab5d040f262b3d0c00c14c4fddca2023f6 |
| --- /dev/null |
| +++ b/chromeos/dbus/fake_media_analytics_client.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
| +#define CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chromeos/chromeos_export.h" |
| +#include "chromeos/dbus/media_analytics_client.h" |
| +#include "chromeos/media_perception/media_perception.pb.h" |
| + |
| +namespace chromeos { |
| + |
| +// MediaAnalyticsClient is used to communicate with a media analytics process |
| +// running outside of Chrome. |
| +class CHROMEOS_EXPORT FakeMediaAnalyticsClient : public MediaAnalyticsClient { |
| + public: |
| + FakeMediaAnalyticsClient(); |
| + ~FakeMediaAnalyticsClient() override; |
| + |
| + // Inherited from MediaAnalyticsClient. |
| + void GetState(const StateCallback& callback) override; |
| + void SetState(const mri::State& state, |
| + const StateCallback& callback) override; |
| + void SetMediaPerceptionSignalHandler( |
| + const MediaPerceptionSignalHandler& handler) override; |
| + void ClearMediaPerceptionSignalHandler() override; |
| + |
|
tbarzic
2017/05/11 18:49:57
nit: no new line here
Luke Sorenson
2017/05/11 22:01:55
Done.
|
| + void GetDiagnostics(const DiagnosticsCallback& callback) override; |
| + |
| + // Inherited from DBusClient. |
| + void Init(dbus::Bus* bus) override; |
| + |
| + // Fires a fake media perception event. |
| + bool FireMediaPerceptionEvent(mri::MediaPerception media_perception); |
| + |
| + // Sets the object to be returned from GetDiagnostics. |
| + void SetDiagnostics(mri::Diagnostics diagnostics); |
| + |
| + void set_process_running(bool running) { process_running_ = running; } |
| + |
| + bool process_running() const { return process_running_; } |
| + |
| + private: |
| + // Echoes back the previously set state. |
| + void OnState(const StateCallback& callback); |
| + |
| + // 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.
|
| + void OnGetDiagnostics(const DiagnosticsCallback& callback); |
| + |
| + // 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.
|
| + // FireMediaPerceptionEvent. |
| + void OnMediaPerception(mri::MediaPerception media_perception); |
| + |
| + // Stores a handler for receiving MediaPerception proto messages. |
| + MediaPerceptionSignalHandler media_perception_signal_handler_; |
| + |
| + // 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.
|
| + mri::State current_state_; |
| + |
| + // Stores a fake diagnostics object to be returned by the GetDiagnostics. |
| + mri::Diagnostics diagnostics_; |
| + |
| + // Whether the fake media analytics was started (for example by the fake |
| + // upstart client) - If not set, all requests to this client will fail. |
| + bool process_running_; |
| + |
| + base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |