OLD | NEW |
---|---|
(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 #include "components/wifi_sync/wifi_credential.h" | |
6 | |
7 #include <limits> | |
8 #include <string> | |
9 | |
10 #include "base/logging.h" | |
11 #include "base/strings/string_number_conversions.h" | |
12 #include "base/strings/stringprintf.h" | |
13 | |
14 namespace wifi_sync { | |
15 | |
16 WifiCredential::WifiCredential( | |
17 const std::vector<unsigned char>& ssid, | |
18 WifiSecurityClass security_class, | |
19 const std::string& passphrase) | |
20 : ssid_(ssid), | |
21 security_class_(security_class), | |
22 passphrase_(passphrase) { | |
23 } | |
24 | |
25 WifiCredential::~WifiCredential() { | |
26 // Nothing special to do. | |
erikwright (departed)
2014/12/08 21:21:36
remove comment. The reasons for an empty destructo
mukesh agrawal
2014/12/09 01:41:11
Done.
| |
27 } | |
28 | |
29 std::string WifiCredential::ToString() const { | |
30 DCHECK(ssid_.size() <= std::numeric_limits<size_t>::max() / 2); | |
erikwright (departed)
2014/12/08 21:21:36
Is there not some more reasonable upper limit on a
mukesh agrawal
2014/12/09 01:41:11
Done.
You're quite right on all three counts. Aft
| |
31 return base::StringPrintf( | |
32 "[SSID (hex): %s, SecurityClass: %d]", | |
33 base::HexEncode(ssid_.data(), ssid_.size()).c_str(), | |
34 security_class_); // Passphrase deliberately omitted. | |
35 } | |
36 | |
37 // static | |
38 bool WifiCredential::IsLessThan( | |
39 const WifiCredential& a, const WifiCredential& b) { | |
40 return a.ssid_ < b.ssid_ || | |
41 a.security_class_< b.security_class_ || | |
42 a.passphrase_ < b.passphrase_; | |
43 } | |
44 | |
45 // static | |
46 WifiCredential::CredentialSet WifiCredential::MakeSet() { | |
47 return CredentialSet(WifiCredential::IsLessThan); | |
48 } | |
49 | |
50 } // namespace wifi_sync | |
OLD | NEW |