fake_fast_pair_handshake.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2021 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. #include "ash/quick_pair/fast_pair_handshake/fake_fast_pair_handshake.h"
  5. #include <cstdint>
  6. #include <memory>
  7. #include <utility>
  8. #include "ash/quick_pair/common/device.h"
  9. #include "ash/quick_pair/common/pair_failure.h"
  10. #include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h"
  11. #include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h"
  12. #include "base/callback.h"
  13. #include "device/bluetooth/bluetooth_adapter.h"
  14. namespace ash {
  15. namespace quick_pair {
  16. FakeFastPairHandshake::FakeFastPairHandshake(
  17. scoped_refptr<device::BluetoothAdapter> adapter,
  18. scoped_refptr<Device> device,
  19. OnCompleteCallback on_complete,
  20. std::unique_ptr<FastPairDataEncryptor> data_encryptor,
  21. std::unique_ptr<FastPairGattServiceClient> gatt_service_client)
  22. : FastPairHandshake(std::move(adapter),
  23. std::move(device),
  24. std::move(on_complete),
  25. std::move(data_encryptor),
  26. std::move(gatt_service_client)) {}
  27. FakeFastPairHandshake::~FakeFastPairHandshake() = default;
  28. void FakeFastPairHandshake::InvokeCallback(
  29. absl::optional<PairFailure> failure) {
  30. bool has_failure = failure.has_value();
  31. std::move(on_complete_callback_).Run(device_, std::move(failure));
  32. completed_successfully_ = !has_failure;
  33. }
  34. } // namespace quick_pair
  35. } // namespace ash