cellular_setup_impl.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 ASH_SERVICES_CELLULAR_SETUP_CELLULAR_SETUP_IMPL_H_
  5. #define ASH_SERVICES_CELLULAR_SETUP_CELLULAR_SETUP_IMPL_H_
  6. #include <memory>
  7. #include "ash/services/cellular_setup/cellular_setup_base.h"
  8. #include "base/containers/id_map.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "mojo/public/cpp/bindings/pending_remote.h"
  11. namespace ash::cellular_setup {
  12. class OtaActivator;
  13. // Concrete mojom::CellularSetup implementation. This class creates a new
  14. // OtaActivator instance per each StartActivation() invocation and passes a
  15. // pointer back to the client.
  16. class CellularSetupImpl : public CellularSetupBase {
  17. public:
  18. // Creates an instance with a lifetime that is bound to the connection
  19. // that is supplying |receiver|.
  20. static void CreateAndBindToReciever(
  21. mojo::PendingReceiver<mojom::CellularSetup> receiver);
  22. CellularSetupImpl(const CellularSetupImpl&) = delete;
  23. CellularSetupImpl& operator=(const CellularSetupImpl&) = delete;
  24. ~CellularSetupImpl() override;
  25. private:
  26. friend class CellularSetupImplTest;
  27. // For unit tests.
  28. CellularSetupImpl();
  29. // mojom::CellularSetup:
  30. void StartActivation(mojo::PendingRemote<mojom::ActivationDelegate> delegate,
  31. StartActivationCallback callback) override;
  32. void OnActivationAttemptFinished(size_t request_id);
  33. size_t next_request_id_ = 0u;
  34. base::IDMap<std::unique_ptr<OtaActivator>, size_t> ota_activator_map_;
  35. base::WeakPtrFactory<CellularSetupImpl> weak_ptr_factory_{this};
  36. };
  37. } // namespace ash::cellular_setup
  38. #endif // ASH_SERVICES_CELLULAR_SETUP_CELLULAR_SETUP_IMPL_H_