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

Unified Diff: chromeos/dbus/biod_biometrics_manager_client.h

Issue 2567813002: cros: DBUS client to interact with fingerprint DBUS API. (Closed)
Patch Set: Fixed patch set 4 errors. Created 3 years, 9 months 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: chromeos/dbus/biod_biometrics_manager_client.h
diff --git a/chromeos/dbus/biod_biometrics_manager_client.h b/chromeos/dbus/biod_biometrics_manager_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac9e142cace9cae84c529e64e7333f6ed2e5fc55
--- /dev/null
+++ b/chromeos/dbus/biod_biometrics_manager_client.h
@@ -0,0 +1,113 @@
+// Copyright 2017 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 CHROMEOS_DBUS_BIOD_BIOMETRICS_MANAGER_CLIENT_H_
+#define CHROMEOS_DBUS_BIOD_BIOMETRICS_MANAGER_CLIENT_H_
+
+#include <stdint.h>
+
+#include <unordered_map>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/dbus/dbus_client.h"
+#include "chromeos/dbus/dbus_client_implementation_type.h"
+#include "chromeos/dbus/dbus_method_call_status.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
+
+namespace chromeos {
+
+// Each time the sensor detects a scan, an object containing all the users, each
+// with the labels of all the matched stored fingerprints is returned.
+using AuthScanMatches =
+ std::unordered_map<std::string, std::vector<std::string>>;
+
+// BiodBiometricsManagerClient is used to communicate with the biod dbus
+// interface.
+class CHROMEOS_EXPORT BiodBiometricsManagerClient : public DBusClient {
+ public:
+ // Interface for observing changes from the biometrics.
+ class Observer {
+ public:
+ // Called when biometrics manager powers up or is restarted.
+ virtual void ClientRestarted() {}
+
+ // Called whenever a user attempts a scan. |scan_result| tells whether the
+ // scan was succesful. |is_complete| tells whether enrollment is complete
+ // and now over.
+ virtual void EnrollScanDoneReceived(uint32_t scan_result,
stevenjb 2017/03/21 18:46:16 EnrollScanCompleteReceived ?
sammiequon 2017/03/21 20:50:19 These signals are based of the dbus signal names f
+ bool is_complete) {}
+
+ // Called to indicate a bad scan of any kind, or a succesful scan. If scan
+ // is successful, |matches| will equal all the enrollment IDs that match the
+ // scan, and the labels of the matched fingeprints.
+ virtual void AuthScanDoneReceived(uint32_t scan_result,
stevenjb 2017/03/21 18:46:16 Complete?
sammiequon 2017/03/21 20:50:18 See above.
+ const AuthScanMatches& matches) {}
+
+ // Called during either mode to indicate a failure. Any enrollment that was
+ // underway is thrown away and authentication will no longer be happening.
+ virtual void ScanFailedReceived() {}
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ ~BiodBiometricsManagerClient() override;
+
+ // Adds and removes the observer.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
stevenjb 2017/03/21 18:46:16 nit: blank line here
sammiequon 2017/03/21 20:50:19 Done.
+ // Returns true if this object has the given observer.
+ virtual bool HasObserver(const Observer* observer) const = 0;
+
+ // ObjectPathArrayCallback is used for the GetRecordsForUser method. It
+ // receives one argument which contains a list of the stored records object
+ // paths for a given user.
stevenjb 2017/03/21 18:46:17 We should either name this type more specifically
sammiequon 2017/03/21 20:50:18 Done.
+ using ObjectPathArrayCallback =
+ base::Callback<void(const std::vector<dbus::ObjectPath>&)>;
+
+ // BiometricTypeCallback is used for the GetType method. It receives
+ // one argument which states the type of biometric.
+ using BiometricTypeCallback = base::Callback<void(biod::BiometricType)>;
+
+ // Starts the biometric enroll session.
stevenjb 2017/03/21 18:46:17 Describe what is passed to |callback|.
sammiequon 2017/03/21 20:50:19 Done.
+ virtual void StartEnrollSession(const std::string& user_id,
+ const std::string& label,
+ const ObjectPathCallback& callback) = 0;
+
+ // Gets all the records registered with this biometric.
stevenjb 2017/03/21 18:46:16 See above
sammiequon 2017/03/21 20:50:19 Done.
+ virtual void GetRecordsForUser(const std::string& user_id,
+ const ObjectPathArrayCallback& callback) = 0;
+
+ // Irreversibly destroys all records registered with this biometric.
+ virtual void DestroyAllRecords() = 0;
+
+ // Starts the biometric authentication session.
stevenjb 2017/03/21 18:46:16 What gets passed to |calback|?
sammiequon 2017/03/21 20:50:19 Done.
+ virtual void StartAuthSession(const ObjectPathCallback& callback) = 0;
+
+ // Gets the type of biometric.
stevenjb 2017/03/21 18:46:16 nit: s/gets/requests/
sammiequon 2017/03/21 20:50:19 Done.
+ virtual void GetType(const BiometricTypeCallback& callback) = 0;
+
+ // Same as above but is synchronous.
+ virtual biod::BiometricType GetTypeBlocking() = 0;
stevenjb 2017/03/21 18:46:16 We should avoid using blocking dbus calls like thi
sammiequon 2017/03/21 20:50:18 Done.
+
+ // Creates the instance.
+ static BiodBiometricsManagerClient* Create(DBusClientImplementationType type);
+
+ protected:
+ friend class BiodBiometricsManagerClientTest;
+
+ // Create() should be used instead.
+ BiodBiometricsManagerClient();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BiodBiometricsManagerClient);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_DBUS_BIOD_BIOMETRICS_MANAGER_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698