test_device_id_provider.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 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 REMOTING_TEST_TEST_DEVICE_ID_PROVIDER_H_
  5. #define REMOTING_TEST_TEST_DEVICE_ID_PROVIDER_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/memory/raw_ptr.h"
  9. #include "remoting/signaling/ftl_device_id_provider.h"
  10. namespace remoting {
  11. namespace test {
  12. // The FtlDeviceIdProvider implementation that generates device ID then store
  13. // and reuse it from |token_storage|.
  14. class TestDeviceIdProvider final : public FtlDeviceIdProvider {
  15. public:
  16. class TokenStorage {
  17. public:
  18. TokenStorage() = default;
  19. virtual ~TokenStorage() = default;
  20. virtual std::string FetchDeviceId() = 0;
  21. virtual bool StoreDeviceId(const std::string& device_id) = 0;
  22. };
  23. explicit TestDeviceIdProvider(TokenStorage* token_storage);
  24. TestDeviceIdProvider(const TestDeviceIdProvider&) = delete;
  25. TestDeviceIdProvider& operator=(const TestDeviceIdProvider&) = delete;
  26. ~TestDeviceIdProvider() override;
  27. // FtlDeviceIdProvider implementations.
  28. ftl::DeviceId GetDeviceId() override;
  29. private:
  30. raw_ptr<TokenStorage> token_storage_;
  31. };
  32. } // namespace test
  33. } // namespace remoting
  34. #endif // REMOTING_TEST_TEST_DEVICE_ID_PROVIDER_H_