Vitaly Buka | 4615e0d | 2015-10-14 15:35:12 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
Vitaly Buka | 7ce499f | 2015-06-09 08:04:11 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Vitaly Buka | 912b698 | 2015-07-06 11:13:03 -0700 | [diff] [blame] | 5 | #ifndef LIBWEAVE_SRC_PRIVET_WIFI_SSID_GENERATOR_H_ |
| 6 | #define LIBWEAVE_SRC_PRIVET_WIFI_SSID_GENERATOR_H_ |
Vitaly Buka | 7ce499f | 2015-06-09 08:04:11 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/callback.h> |
| 11 | |
Vitaly Buka | b6f015a | 2015-07-09 14:59:23 -0700 | [diff] [blame] | 12 | namespace weave { |
| 13 | namespace privet { |
Vitaly Buka | 7ce499f | 2015-06-09 08:04:11 -0700 | [diff] [blame] | 14 | |
| 15 | class CloudDelegate; |
| 16 | class WifiDelegate; |
| 17 | |
| 18 | class WifiSsidGenerator final { |
| 19 | public: |
| 20 | WifiSsidGenerator(const CloudDelegate* gcd, const WifiDelegate* wifi); |
| 21 | ~WifiSsidGenerator() = default; |
| 22 | |
| 23 | std::string GenerateFlags() const; |
| 24 | |
| 25 | // Can return empty string if CloudDelegate is not ready. |
| 26 | std::string GenerateSsid() const; |
| 27 | |
| 28 | private: |
| 29 | friend class WifiSsidGeneratorTest; |
| 30 | |
| 31 | // Sets object to use |n| instead of random number for SSID generation. |
| 32 | void SetRandomForTests(int n); |
| 33 | |
| 34 | const CloudDelegate* gcd_{nullptr}; |
| 35 | const WifiDelegate* wifi_{nullptr}; |
| 36 | |
| 37 | base::Callback<int(void)> get_random_; |
| 38 | |
| 39 | DISALLOW_COPY_AND_ASSIGN(WifiSsidGenerator); |
| 40 | }; |
| 41 | |
Vitaly Buka | b6f015a | 2015-07-09 14:59:23 -0700 | [diff] [blame] | 42 | } // namespace privet |
| 43 | } // namespace weave |
Vitaly Buka | 7ce499f | 2015-06-09 08:04:11 -0700 | [diff] [blame] | 44 | |
Vitaly Buka | 912b698 | 2015-07-06 11:13:03 -0700 | [diff] [blame] | 45 | #endif // LIBWEAVE_SRC_PRIVET_WIFI_SSID_GENERATOR_H_ |