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

Unified Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h

Issue 789793005: Revert of Clean up Smart Lock cryptohome keys logic: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
index 9d838753c09b2047c39b698f42303f3e2f24dd06..ebe9c3fba162fcdf9bef9551b82d9a5406b3e478 100644
--- a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
+++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h
@@ -11,10 +11,11 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/stl_util.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_operation.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_get_keys_operation.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_remove_keys_operation.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h"
namespace base {
@@ -29,8 +30,8 @@
// A class to manage Easy unlock cryptohome keys.
class EasyUnlockKeyManager {
public:
- typedef EasyUnlockRefreshKeysOperation::RefreshKeysCallback
- RefreshKeysCallback;
+ typedef EasyUnlockCreateKeysOperation::CreateKeysCallback RefreshKeysCallback;
+ typedef EasyUnlockRemoveKeysOperation::RemoveKeysCallback RemoveKeysCallback;
typedef EasyUnlockGetKeysOperation::GetKeysCallback GetDeviceDataListCallback;
EasyUnlockKeyManager();
@@ -42,6 +43,12 @@
void RefreshKeys(const UserContext& user_context,
const base::ListValue& remote_devices,
const RefreshKeysCallback& callback);
+
+ // Remove Easy unlock keys starting at the given index for the given
+ // |user_context|.
+ void RemoveKeys(const UserContext& user_context,
+ size_t start_index,
+ const RemoveKeysCallback& callback);
// Retrieves the remote device data from cryptohome keys for the given
// |user_context|.
@@ -75,13 +82,6 @@
static std::string GetKeyLabel(size_t key_index);
private:
- // Runs the next operation if there is one. We first run all the operations in
- // the |write_operation_queue_| and then run all the operations in the
- // |read_operation_queue_|.
- void RunNextOperation();
-
- // Called when the TPM key is ready to be used for creating Easy Unlock key
- // challenges.
void RefreshKeysWithTpmKeyPresent(const UserContext& user_context,
base::ListValue* remote_devices,
const RefreshKeysCallback& callback);
@@ -89,30 +89,34 @@
// Returns true if there are pending operations.
bool HasPendingOperations() const;
- // Callback invoked after refresh keys operation.
- void OnKeysRefreshed(const RefreshKeysCallback& callback,
- bool create_success);
+ // Returns the next operations id. Currently only used for get keys ops.
+ int GetNextOperationId();
+
+ // Runs the first pending op in |pending_ops_|. No-op if |pending_ops_| is
+ // emtpy.
+ void RunNextPendingOp();
+
+ // Callback invoked after create keys op.
+ void OnKeysCreated(size_t remove_start_index,
+ const RefreshKeysCallback& callback,
+ bool create_success);
+
+ // Callback invoked after remove keys op.
+ void OnKeysRemoved(const RemoveKeysCallback& callback, bool remove_success);
// Callback invoked after get keys op.
- void OnKeysFetched(const GetDeviceDataListCallback& callback,
+ void OnKeysFetched(int op_id,
+ const GetDeviceDataListCallback& callback,
bool fetch_success,
const EasyUnlockDeviceKeyDataList& fetched_data);
- // Queued operations are stored as raw pointers, as scoped_ptrs may not behave
- // nicely with std::deque.
- using WriteOperationQueue = std::deque<EasyUnlockRefreshKeysOperation*>;
- using ReadOperationQueue = std::deque<EasyUnlockGetKeysOperation*>;
- WriteOperationQueue write_operation_queue_;
- ReadOperationQueue read_operation_queue_;
+ int operation_id_;
- // Scopes the raw operation pointers to the lifetime of this object.
- STLElementDeleter<WriteOperationQueue> write_queue_deleter_;
- STLElementDeleter<ReadOperationQueue> read_queue_deleter_;
+ scoped_ptr<EasyUnlockCreateKeysOperation> create_keys_op_;
+ scoped_ptr<EasyUnlockRemoveKeysOperation> remove_keys_op_;
+ std::map<int, EasyUnlockGetKeysOperation*> get_keys_ops_;
- // Stores the current operation in progress. At most one of these variables
- // can be non-null at any time.
- scoped_ptr<EasyUnlockRefreshKeysOperation> pending_write_operation_;
- scoped_ptr<EasyUnlockGetKeysOperation> pending_read_operation_;
+ std::deque<base::Closure> pending_ops_;
base::WeakPtrFactory<EasyUnlockKeyManager> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698