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

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

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 #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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698