summaryrefslogtreecommitdiff
path: root/chromium/components/cryptauth/fake_background_eid_generator.cc
blob: 9a8a1881c89477e749670dbbb79d697314bd4cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/cryptauth/fake_background_eid_generator.h"

#include <memory>

namespace cryptauth {

FakeBackgroundEidGenerator::FakeBackgroundEidGenerator() = default;
FakeBackgroundEidGenerator::~FakeBackgroundEidGenerator() = default;

std::vector<DataWithTimestamp> FakeBackgroundEidGenerator::GenerateNearestEids(
    const std::vector<BeaconSeed>& beacon_seed) const {
  return *nearest_eids_;
}

std::string FakeBackgroundEidGenerator::IdentifyRemoteDeviceByAdvertisement(
    const std::string& advertisement_service_data,
    const RemoteDeviceRefList& remote_devices) const {
  // Increment num_identify_calls_. Since this overrides a const method, some
  // hacking is needed to modify the num_identify_calls_ instance variable.
  int* num_identify_calls_ptr = const_cast<int*>(&num_identify_calls_);
  *num_identify_calls_ptr = *num_identify_calls_ptr + 1;

  return identified_device_id_;
}

}  // namespace cryptauth