Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: components/wifi_sync/wifi_credential.h

Issue 709683004: components: add wifi_sync component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-1-security-class
Patch Set: address style issues from stevenjb's review of PS9 Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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
5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_H_
6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_H_
7
8 #include <stdint.h>
9
10 #include <set>
11 #include <string>
12 #include <vector>
13
14 #include "components/wifi_sync/wifi_security_class.h"
15
16 namespace wifi_sync {
17
18 // A container to hold the information required to locate and connect
19 // to a WiFi network.
20 class WifiCredential final { // final because the class is copyable
21 public:
22 using SsidBytes = std::vector<uint8_t>;
23 using CredentialSet = std::set<
24 WifiCredential,
25 bool(*)(const WifiCredential&a, const WifiCredential& b)>;
26
27 // Constructs a credential with the given |ssid|, |security_class|,
28 // and |passphrase|. No assumptions are made about the input
29 // encoding of |ssid|. The passphrase must be valid UTF-8.
30 WifiCredential(const SsidBytes& ssid,
31 WifiSecurityClass security_class,
32 const std::string& passphrase);
33 ~WifiCredential();
34
35 const SsidBytes& ssid() const { return ssid_; }
36 WifiSecurityClass security_class() const { return security_class_; }
37 const std::string& passphrase() const { return passphrase_; }
38
39 // Returns a string representation of the credential. The string
erikwright (departed) 2014/12/08 21:21:36 Document the intended usage of the string. Debuggi
mukesh agrawal 2014/12/09 01:41:11 Done.
40 // will not include the credential's passphrase.
41 std::string ToString() const;
42
43 // Returns true if credential |a| comes before credential |b|.
44 static bool IsLessThan(const WifiCredential& a, const WifiCredential& b);
45
46 // Returns an empty set of WifiCredentials, with the IsLessThan
47 // ordering function plumbed in.
48 static CredentialSet MakeSet();
49
50 private:
51 // The WiFi network's SSID.
52 const SsidBytes ssid_;
53 // The WiFi network's security class (e.g. WEP, PSK).
54 const WifiSecurityClass security_class_;
55 // The passphrase for connecting to the network.
56 const std::string passphrase_;
57 };
58
59 } // namespace wifi_sync
60
61 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698