fake_remote_device_life_cycle.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2015 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. #ifndef ASH_COMPONENTS_PROXIMITY_AUTH_FAKE_REMOTE_DEVICE_LIFE_CYCLE_H_
  5. #define ASH_COMPONENTS_PROXIMITY_AUTH_FAKE_REMOTE_DEVICE_LIFE_CYCLE_H_
  6. #include "ash/components/multidevice/remote_device_ref.h"
  7. #include "ash/components/proximity_auth/remote_device_life_cycle.h"
  8. // TODO(https://crbug.com/1164001): move to forward declaration.
  9. #include "ash/services/secure_channel/public/cpp/client/client_channel.h"
  10. #include "base/observer_list.h"
  11. namespace proximity_auth {
  12. class FakeRemoteDeviceLifeCycle : public RemoteDeviceLifeCycle {
  13. public:
  14. explicit FakeRemoteDeviceLifeCycle(
  15. ash::multidevice::RemoteDeviceRef remote_device,
  16. absl::optional<ash::multidevice::RemoteDeviceRef> local_device);
  17. FakeRemoteDeviceLifeCycle(const FakeRemoteDeviceLifeCycle&) = delete;
  18. FakeRemoteDeviceLifeCycle& operator=(const FakeRemoteDeviceLifeCycle&) =
  19. delete;
  20. ~FakeRemoteDeviceLifeCycle() override;
  21. // RemoteDeviceLifeCycle:
  22. void Start() override;
  23. ash::multidevice::RemoteDeviceRef GetRemoteDevice() const override;
  24. ash::secure_channel::ClientChannel* GetChannel() const override;
  25. State GetState() const override;
  26. Messenger* GetMessenger() override;
  27. void AddObserver(Observer* observer) override;
  28. void RemoveObserver(Observer* observer) override;
  29. // Changes state and notifies observers.
  30. void ChangeState(State new_state);
  31. void set_messenger(Messenger* messenger) { messenger_ = messenger; }
  32. void set_channel(ash::secure_channel::ClientChannel* channel) {
  33. channel_ = channel;
  34. }
  35. bool started() { return started_; }
  36. ash::multidevice::RemoteDeviceRef local_device() { return *local_device_; }
  37. base::ObserverList<Observer>::Unchecked& observers() { return observers_; }
  38. private:
  39. ash::multidevice::RemoteDeviceRef remote_device_;
  40. absl::optional<ash::multidevice::RemoteDeviceRef> local_device_;
  41. base::ObserverList<Observer>::Unchecked observers_;
  42. bool started_;
  43. State state_;
  44. ash::secure_channel::ClientChannel* channel_;
  45. Messenger* messenger_;
  46. };
  47. } // namespace proximity_auth
  48. #endif // ASH_COMPONENTS_PROXIMITY_AUTH_FAKE_REMOTE_DEVICE_LIFE_CYCLE_H_