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

Unified Diff: chromeos/dbus/biod/biod_client.h

Issue 2567813002: cros: DBUS client to interact with fingerprint DBUS API. (Closed)
Patch Set: s/BiodBiometricsManagerClient/BiodClient 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/biod_client.h
diff --git a/chromeos/dbus/biod/biod_client.h b/chromeos/dbus/biod/biod_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..aa30b151bc62275591848441206873906284fb4e
--- /dev/null
+++ b/chromeos/dbus/biod/biod_client.h
@@ -0,0 +1,115 @@
+// 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_BIOD_CLIENT_H_
+#define CHROMEOS_DBUS_BIOD_BIOD_CLIENT_H_
+
+#include <stdint.h>
Daniel Erat 2017/03/31 04:30:09 are you actually using this?
sammiequon 2017/03/31 22:52:13 Nope. That was for when the scan results were uint
+
Daniel Erat 2017/03/31 04:30:10 #include <string>
sammiequon 2017/03/31 22:52:12 Done.
+#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.
Daniel Erat 2017/03/31 04:30:10 please go into more details about the actual value
sammiequon 2017/03/31 22:52:12 Theres another ongoing discussion (not involving m
Daniel Erat 2017/04/01 00:46:26 i think it's okay to document it as being assigned
sammiequon 2017/04/01 01:22:43 Acknowledged.
+using AuthScanMatches =
+ std::unordered_map<std::string, std::vector<std::string>>;
+
+// BiodClient is used to communicate with a biod D-Bus manager
+// interface.
+class CHROMEOS_EXPORT BiodClient : public DBusClient {
+ public:
+ // Interface for observing changes from the biometrics manager.
+ class Observer {
+ public:
+ // Called when biometrics manager powers up or is restarted.
Daniel Erat 2017/03/31 04:30:10 does this actually get called if biod is already r
sammiequon 2017/03/31 22:52:13 Let me quickly test this out and I'll get back to
sammiequon 2017/04/01 01:22:43 Yeah it gets called when biod is already running a
+ virtual void BiodServiceRestarted() {}
+
+ // Called whenever a user attempts a scan. |scan_result| tells whether the
Daniel Erat 2017/03/31 04:30:10 Called whenever a user attempts a scan during enro
sammiequon 2017/03/31 22:52:12 Done.
+ // scan was succesful. |enroll_session_complete| tells whether enroll
+ // session is complete and is now over.
+ virtual void BiodEnrollScanDoneReceived(biod::ScanResult scan_result,
+ bool enroll_session_complete) {}
+
+ // Called to indicate a bad scan of any kind, or a successful scan. If scan
Daniel Erat 2017/03/31 04:30:09 Called when an authentication scan is performed.
sammiequon 2017/03/31 22:52:12 Done.
+ // is successful, |matches| will equal all the enrollment IDs that match the
+ // scan, and the labels of the matched fingeprints.
+ virtual void BiodAuthScanDoneReceived(biod::ScanResult scan_result,
+ const AuthScanMatches& matches) {}
+
+ // Called during either session to indicate a failure. Any enrollment that
Daniel Erat 2017/03/31 04:30:10 s/either session/an enrollment or authentication s
sammiequon 2017/03/31 22:52:12 Done.
+ // was underway is thrown away and auth will no longer be happening.
+ virtual void BiodSessionFailedReceived() {}
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ ~BiodClient() override;
+
+ // Adds and removes the observer.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
+ // Returns true if this object has the given observer.
+ virtual bool HasObserver(const Observer* observer) const = 0;
+
+ // UserRecordsCallback is used for the GetRecordsForUser method. It receives
+ // one argument which contains a list of the stored records object paths for
Daniel Erat 2017/03/31 04:30:10 s/records/records'/
sammiequon 2017/03/31 22:52:12 Done.
+ // a given user.
+ using UserRecordsCallback =
+ 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. |callback| is called with the object
+ // path of the current enroll session after the method succeeds.
+ virtual void StartEnrollSession(const std::string& user_id,
Daniel Erat 2017/03/31 04:30:10 same comment re |user_id|, also document what |lab
sammiequon 2017/03/31 22:52:12 Done.
+ const std::string& label,
+ const ObjectPathCallback& callback) = 0;
+
+ // Gets all the records registered with this biometric. |callback| is called
Daniel Erat 2017/03/31 04:30:09 do you mean "... with this user"?
sammiequon 2017/03/31 22:52:12 Done.
+ // with all the object paths of the records after this method succeeds.
+ virtual void GetRecordsForUser(const std::string& user_id,
Daniel Erat 2017/03/31 04:30:10 as above, document what the id actually is and ide
sammiequon 2017/03/31 22:52:13 Done.
+ const UserRecordsCallback& callback) = 0;
+
+ // Irreversibly destroys all records registered with this biometric.
Daniel Erat 2017/03/31 04:30:09 should you drop text like "with this biometric" if
sammiequon 2017/03/31 22:52:12 Done.
+ virtual void DestroyAllRecords() = 0;
+
+ // Starts the biometric auth session. |callback| is called with the object
+ // path of the auth session after the method succeeds.
+ virtual void StartAuthSession(const ObjectPathCallback& callback) = 0;
+
+ // Requests the type of biometric. |callback| is called with the biometric
+ // type after the method succeeds.
+ virtual void RequestType(const BiometricTypeCallback& callback) = 0;
+
+ // Creates the instance.
+ static BiodClient* Create(DBusClientImplementationType type);
+
+ protected:
+ friend class BiodClientTest;
+
+ // Create() should be used instead.
+ BiodClient();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BiodClient);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_DBUS_BIOD_BIOD_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698