Chromium Code Reviews| Index: components/wifi_sync/wifi_credential.cc |
| diff --git a/components/wifi_sync/wifi_credential.cc b/components/wifi_sync/wifi_credential.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e2467969ac65c2d680a983baf103694d9bec17c |
| --- /dev/null |
| +++ b/components/wifi_sync/wifi_credential.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/wifi_sync/wifi_credential.h" |
| + |
| +#include <limits> |
| +#include <string> |
| + |
| +#include "base/logging.h" |
| +#include "base/strings/string_number_conversions.h" |
| +#include "base/strings/stringprintf.h" |
| + |
| +namespace wifi_sync { |
| + |
| +WifiCredential::WifiCredential( |
| + const std::vector<unsigned char>& ssid, |
| + WifiSecurityClass security_class, |
| + const std::string& passphrase) |
| + : ssid_(ssid), |
| + security_class_(security_class), |
| + passphrase_(passphrase) { |
| +} |
| + |
| +WifiCredential::~WifiCredential() { |
| + // 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.
|
| +} |
| + |
| +std::string WifiCredential::ToString() const { |
| + 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
|
| + return base::StringPrintf( |
| + "[SSID (hex): %s, SecurityClass: %d]", |
| + base::HexEncode(ssid_.data(), ssid_.size()).c_str(), |
| + security_class_); // Passphrase deliberately omitted. |
| +} |
| + |
| +// static |
| +bool WifiCredential::IsLessThan( |
| + const WifiCredential& a, const WifiCredential& b) { |
| + return a.ssid_ < b.ssid_ || |
| + a.security_class_< b.security_class_ || |
| + a.passphrase_ < b.passphrase_; |
| +} |
| + |
| +// static |
| +WifiCredential::CredentialSet WifiCredential::MakeSet() { |
| + return CredentialSet(WifiCredential::IsLessThan); |
| +} |
| + |
| +} // namespace wifi_sync |