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

Unified Diff: components/wifi_sync/wifi_credential.h

Issue 709683004: components: add wifi_sync component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-1-security-class
Patch Set: remove stray dependency 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.h
diff --git a/components/wifi_sync/wifi_credential.h b/components/wifi_sync/wifi_credential.h
new file mode 100644
index 0000000000000000000000000000000000000000..f5440d8a44f3f7709fa21f9b8d47c2a89fd09f29
--- /dev/null
+++ b/components/wifi_sync/wifi_credential.h
@@ -0,0 +1,66 @@
+// 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.
+
+#ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_H_
+#define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_H_
+
+#include <stdint.h>
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "components/wifi_sync/wifi_security_class.h"
+
+namespace wifi_sync {
+
+// A container to hold the information required to locate and connect
+// to a WiFi network.
+class WifiCredential final { // final because the class is copyable
+ public:
+ using SsidBytes = std::vector<uint8_t>;
+ using CredentialSet = std::set<
+ WifiCredential,
+ bool(*)(const WifiCredential&a, const WifiCredential& b)>;
+
+ // Constructs a credential with the given |ssid|, |security_class|,
+ // and |passphrase|. No assumptions are made about the input
+ // encoding of |ssid|. The passphrase must be valid UTF-8.
+ WifiCredential(const char* ssid,
+ WifiSecurityClass security_class,
+ const std::string& passphrase);
stevenjb 2014/12/05 20:28:17 nit: blank line between methods
mukesh agrawal 2014/12/05 23:48:11 Acknowledged.
+ // Constructs a credential with the given |ssid|, |security_class|,
+ // and |passphrase|. No assumptions are made about the input
+ // encoding of |ssid|. The passphrase must be valid UTF-8.
+ WifiCredential(const SsidBytes& ssid,
+ WifiSecurityClass security_class,
+ const std::string& passphrase);
stevenjb 2014/12/05 20:28:17 We try to avoid multiple constructors. Do we reall
mukesh agrawal 2014/12/05 23:48:11 Done.
+ ~WifiCredential();
+
+ const SsidBytes& ssid() const { return ssid_; }
+ WifiSecurityClass security_class() const { return security_class_; }
+ const std::string& passphrase() const { return passphrase_; }
+
+ // Returns a string representation of the credential. The string
+ // will not include the credential's passphrase.
+ std::string ToString() const;
+
+ // Returns true if credential |a| comes before credential |b|.
+ static bool IsLessThan(const WifiCredential& a, const WifiCredential& b);
stevenjb 2014/12/05 20:28:17 WS
mukesh agrawal 2014/12/05 23:48:11 Done. Following the pattern of chromeos/network/c
+ // Returns an empty set of WifiCredentials, with the IsLessThan
+ // ordering function plumbed in.
+ static CredentialSet MakeSet();
+
+ private:
+ // The WiFi network's SSID.
+ const SsidBytes ssid_;
+ // The WiFi network's security class (e.g. WEP, PSK).
+ const WifiSecurityClass security_class_;
+ // The passphrase for connecting to the network.
+ const std::string passphrase_;
+};
+
+} // namespace wifi_sync
+
+#endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_H_

Powered by Google App Engine
This is Rietveld 408576698