Chromium Code Reviews| 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 ebe9c3fba162fcdf9bef9551b82d9a5406b3e478..f1c3371c84940b72f4e33e8b85c8859b19307c48 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,11 +11,10 @@ |
| #include "base/callback.h" |
| #include "base/macros.h" |
| -#include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| -#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_operation.h" |
| +#include "base/stl_util.h" |
| #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_get_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_refresh_keys_operation.h" |
| #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" |
| namespace base { |
| @@ -30,8 +29,8 @@ class UserContext; |
| // A class to manage Easy unlock cryptohome keys. |
| class EasyUnlockKeyManager { |
| public: |
| - typedef EasyUnlockCreateKeysOperation::CreateKeysCallback RefreshKeysCallback; |
| - typedef EasyUnlockRemoveKeysOperation::RemoveKeysCallback RemoveKeysCallback; |
| + typedef EasyUnlockRefreshKeysOperation::RefreshKeysCallback |
| + RefreshKeysCallback; |
| typedef EasyUnlockGetKeysOperation::GetKeysCallback GetDeviceDataListCallback; |
| EasyUnlockKeyManager(); |
| @@ -44,12 +43,6 @@ class EasyUnlockKeyManager { |
| 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|. |
| void GetDeviceDataList(const UserContext& user_context, |
| @@ -82,6 +75,12 @@ class EasyUnlockKeyManager { |
| 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 actually queue the refresh operation. |
|
tbarzic
2014/12/18 10:49:05
nit:
what do you think about:
...ready to be used
Tim Song
2014/12/18 22:42:54
Done.
|
| void RefreshKeysWithTpmKeyPresent(const UserContext& user_context, |
| base::ListValue* remote_devices, |
| const RefreshKeysCallback& callback); |
| @@ -89,34 +88,30 @@ class EasyUnlockKeyManager { |
| // Returns true if there are pending operations. |
| bool HasPendingOperations() const; |
| - // 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 refresh keys operation. |
| + void OnKeysRefreshed(const RefreshKeysCallback& callback, |
| + bool create_success); |
| // Callback invoked after get keys op. |
| - void OnKeysFetched(int op_id, |
| - const GetDeviceDataListCallback& callback, |
| + void OnKeysFetched(const GetDeviceDataListCallback& callback, |
| bool fetch_success, |
| const EasyUnlockDeviceKeyDataList& fetched_data); |
| - int operation_id_; |
| - |
| - scoped_ptr<EasyUnlockCreateKeysOperation> create_keys_op_; |
| - scoped_ptr<EasyUnlockRemoveKeysOperation> remove_keys_op_; |
| - std::map<int, EasyUnlockGetKeysOperation*> get_keys_ops_; |
| - |
| - std::deque<base::Closure> pending_ops_; |
| + // Queued operations are stored as raw pointers, as scoped_ptrs may not behave |
| + // nicely with std::deque. |
| + typedef std::deque<EasyUnlockRefreshKeysOperation*> WriteOperationQueue; |
|
tbarzic
2014/12/18 10:49:05
nit: I think we can use:
using WriteOperationQueue
Tim Song
2014/12/18 22:42:54
Done.
|
| + typedef std::deque<EasyUnlockGetKeysOperation*> ReadOperationQueue; |
| + WriteOperationQueue write_operation_queue_; |
| + ReadOperationQueue read_operation_queue_; |
| + |
| + // Scopes the raw operation pointers to the lifetime of this object. |
| + STLElementDeleter<WriteOperationQueue> write_queue_deleter_; |
| + STLElementDeleter<ReadOperationQueue> read_queue_deleter_; |
| + |
| + // 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_; |
| base::WeakPtrFactory<EasyUnlockKeyManager> weak_ptr_factory_; |