aboutsummaryrefslogtreecommitdiff
path: root/src/privet/wifi_ssid_generator.h
blob: 2b86f281694e78e2bbdf5b3a50ed42fea651838a (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2015 The Weave Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBWEAVE_SRC_PRIVET_WIFI_SSID_GENERATOR_H_
#define LIBWEAVE_SRC_PRIVET_WIFI_SSID_GENERATOR_H_

#include <string>

#include <base/callback.h>

namespace weave {
namespace privet {

class CloudDelegate;
class WifiDelegate;

class WifiSsidGenerator final {
 public:
  WifiSsidGenerator(const CloudDelegate* gcd, const WifiDelegate* wifi);
  ~WifiSsidGenerator() = default;

  std::string GenerateFlags() const;

  // Can return empty string if CloudDelegate is not ready.
  std::string GenerateSsid() const;

 private:
  friend class WifiSsidGeneratorTest;

  // Sets object to use |n| instead of random number for SSID generation.
  void SetRandomForTests(int n);
  std::string GenerateFlagsInternal(bool for_ssid) const;

  const CloudDelegate* gcd_{nullptr};
  const WifiDelegate* wifi_{nullptr};

  base::Callback<int(void)> get_random_;

  DISALLOW_COPY_AND_ASSIGN(WifiSsidGenerator);
};

}  // namespace privet
}  // namespace weave

#endif  // LIBWEAVE_SRC_PRIVET_WIFI_SSID_GENERATOR_H_