ota_activator.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_OTA_ACTIVATOR_H_
  5. #define ASH_SERVICES_CELLULAR_SETUP_OTA_ACTIVATOR_H_
  6. #include "ash/services/cellular_setup/public/mojom/cellular_setup.mojom.h"
  7. #include "base/callback.h"
  8. #include "mojo/public/cpp/bindings/pending_remote.h"
  9. #include "mojo/public/cpp/bindings/receiver.h"
  10. namespace ash::cellular_setup {
  11. // Activates a cellular SIM using the OTA mechanism. This class makes a single
  12. // attempt at activation, then fires a callback on completion, regardless of
  13. // success or failure. An OtaActivator object can only be used for one
  14. // attempt; to perform a new activation attempt, use a separate OtaActivator
  15. // instance.
  16. class OtaActivator : public mojom::CarrierPortalHandler {
  17. public:
  18. OtaActivator(const OtaActivator&) = delete;
  19. OtaActivator& operator=(const OtaActivator&) = delete;
  20. ~OtaActivator() override;
  21. // Generates a mojo::PendingRemote<> bound to this instance. Only one
  22. // mojo::PendingRemote<> may be bound to a single OtaActivator instance, so
  23. // this function can only be called once.
  24. mojo::PendingRemote<mojom::CarrierPortalHandler> GenerateRemote();
  25. protected:
  26. explicit OtaActivator(base::OnceClosure on_finished_callback);
  27. void InvokeOnFinishedCallback();
  28. base::OnceClosure on_finished_callback_;
  29. mojo::Receiver<mojom::CarrierPortalHandler> receiver_{this};
  30. };
  31. } // namespace ash::cellular_setup
  32. #endif // ASH_SERVICES_CELLULAR_SETUP_OTA_ACTIVATOR_H_