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

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: fix android_aosp build 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
« no previous file with comments | « components/wifi_sync/wifi_credential.h ('k') | components/wifi_sync/wifi_credential_syncable_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..73fbaf27f96b34281b4f6606c4f959bde6d58305
--- /dev/null
+++ b/components/wifi_sync/wifi_credential.cc
@@ -0,0 +1,48 @@
+// 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() {
+}
+
+std::string WifiCredential::ToString() const {
+ return base::StringPrintf(
+ "[SSID (hex): %s, SecurityClass: %d]",
+ base::HexEncode(&ssid_.front(), 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
« no previous file with comments | « components/wifi_sync/wifi_credential.h ('k') | components/wifi_sync/wifi_credential_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698