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

Unified 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698