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..d3656818d9d01ffc4d4292781c423d8498d5423f |
| --- /dev/null |
| +++ b/chromeos/dbus/fake_media_analytics_client.h |
| @@ -0,0 +1,80 @@ |
| +// 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; |
| + |
|
tbarzic
2017/05/11 16:55:55
nit: remove new lines between overrides of the sam
Luke Sorenson
2017/05/11 18:16:48
Done.
|
| + void SetMediaPerceptionSignalHandler( |
| + const MediaPerceptionSignalHandler& handler) override; |
| + void ClearMediaPerceptionSignalHandler() override; |
| + |
| + void GetDiagnostics(const DiagnosticsCallback& callback) override; |
| + |
| + // Inherited from DBusClient. |
| + void Init(dbus::Bus* bus) override; |
| + |
| + // Fires a fake media perception event so that we can verify the signal is |
| + // recieved by the app. |
|
tbarzic
2017/05/11 16:55:55
Just: Fires a fake media perception event.
Luke Sorenson
2017/05/11 18:16:47
Done.
|
| + void FireMediaPerceptionEvent(mri::MediaPerception media_perception); |
| + |
| + // Sets the object to be returned from GetDiagnostics. Allows the apitest |
| + // to set the value being returned. |
|
tbarzic
2017/05/11 16:55:55
nit: remove the second sentence.
Maybe append For
Luke Sorenson
2017/05/11 18:16:48
Done.
|
| + void SetDiagnostics(mri::Diagnostics diagnostics); |
| + |
| + // Make the media analytics process as launched or not running. |
|
tbarzic
2017/05/11 16:55:55
I'm fine without this comment - process_running_ c
Luke Sorenson
2017/05/11 18:16:48
Done.
|
| + void set_process_running(bool running) { process_running_ = running; } |
| + |
| + bool process_running() const { return process_running_; } |
| + |
| + private: |
| + // Simply echoes back the previously set state. |
|
tbarzic
2017/05/11 16:55:55
nit: no "Simply"
Luke Sorenson
2017/05/11 18:16:47
Done.
|
| + void OnState(const StateCallback& callback); |
| + |
| + // Returns a fake, nearly empty serialized Diagnostic proto. |
|
tbarzic
2017/05/11 16:55:55
nit: Update comment in respect to SetDiagnostics c
Luke Sorenson
2017/05/11 18:16:47
Done.
|
| + void OnGetDiagnostics(const DiagnosticsCallback& callback); |
| + |
| + // Returns a fake, nearly empty serialized MediaPerception proto. |
|
tbarzic
2017/05/11 16:55:55
nit: Update the comment.
Luke Sorenson
2017/05/11 18:16:47
Done.
|
| + 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. |
| + mri::State current_state_; |
| + |
| + // Stores a fake diagnostics object to be returned by the GetDiagnostics. |
| + mri::Diagnostics diagnostics_; |
| + |
| + // Stores the launch state of the fake media analytics process. |
|
tbarzic
2017/05/11 16:55:55
Whether the fake media analytics was started (for
Luke Sorenson
2017/05/11 18:16:47
Done.
|
| + bool process_running_; |
| + |
| + base::WeakPtrFactory<FakeMediaAnalyticsClient> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeMediaAnalyticsClient); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_DBUS_FAKE_MEDIA_ANALYTICS_CLIENT_H_ |