Chromium Code Reviews| Index: chrome/browser/chromeos/platform_keys/platform_keys_service.h |
| diff --git a/chrome/browser/chromeos/platform_keys/platform_keys_service.h b/chrome/browser/chromeos/platform_keys/platform_keys_service.h |
| index af7efc7ffe5f14dd207e25ddffb1453072b8c3c5..0cb6467ecc131f75130df90a4094f54bd2b4864c 100644 |
| --- a/chrome/browser/chromeos/platform_keys/platform_keys_service.h |
| +++ b/chrome/browser/chromeos/platform_keys/platform_keys_service.h |
| @@ -5,11 +5,13 @@ |
| #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ |
| #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ |
| +#include <queue> |
| #include <string> |
| #include <vector> |
| #include "base/callback_forward.h" |
| #include "base/macros.h" |
| +#include "base/memory/linked_ptr.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| #include "chrome/browser/chromeos/platform_keys/platform_keys.h" |
| @@ -115,20 +117,18 @@ class PlatformKeysService : public KeyedService { |
| using GetPlatformKeysCallback = |
| base::Callback<void(scoped_ptr<base::ListValue> platform_keys)>; |
| - // Registers the given public key as newly generated key, which is allowed to |
| - // be used for signing for a single time. Afterwards, calls |callback|. If |
| - // registration was successful, passes |true| otherwise |false| to the |
| - // callback. |
| - void RegisterPublicKey(const std::string& extension_id, |
| - const std::string& public_key_spki_der, |
| - const base::Closure& callback); |
| - |
| - // Gets the current validity of the given public key by reading StateStore. |
| - // Invalidates the key if it was found to be valid. Finally, calls |callback| |
| - // with the old validity. |
| - void ReadValidityAndInvalidateKey(const std::string& extension_id, |
| - const std::string& public_key_spki_der, |
| - const base::Callback<void(bool)>& callback); |
| + class Task; |
| + class SignTask; |
| + class PermissionUpdateTask; |
| + |
| + // This ensures to start at most one task at a time. |
|
kaliamoorthi
2015/02/09 10:44:01
|task|
pneubeck (no reviews)
2015/02/09 14:02:38
Done.
|
| + void StartOrQueueTask(scoped_ptr<Task> task); |
| + |
| + // Must be called after |task| is done. |task| will be invalid after this |
| + // call. This must not be called for any but the task that ran last. If any |
| + // other tasks are queued (see StartOrQueueTask()), it will start the next |
| + // one. |
| + void TaskFinished(Task* task); |
| // Reads the list of public keys currently registered for |extension_id| from |
| // StateStore. Calls |callback| with the read list, or a new empty list if |
| @@ -146,10 +146,15 @@ class PlatformKeysService : public KeyedService { |
| // for the given extension. If any error occurs during key generation or |
| // registration, calls |callback| with an error. Otherwise, on success, calls |
| // |callback| with the public key. |
| - void GenerateRSAKeyCallback(const std::string& extension_id, |
| - const GenerateKeyCallback& callback, |
| - const std::string& public_key_spki_der, |
| - const std::string& error_message); |
| + void GeneratedKey(const std::string& extension_id, |
| + const GenerateKeyCallback& callback, |
| + const std::string& public_key_spki_der, |
| + const std::string& error_message); |
| + |
| + // Callback used by |GeneratedKey|. |
|
kaliamoorthi
2015/02/09 10:44:01
Expand this comment.
pneubeck (no reviews)
2015/02/09 14:02:38
Done.
|
| + void DidRegisterGeneratedKey(const GenerateKeyCallback& callback, |
| + const std::string& public_key_spki_der, |
| + Task* task); |
| // Calback used by |SelectClientCertificates|. |
| // If the certificate request could be processed successfully, |matches| will |
| @@ -162,23 +167,6 @@ class PlatformKeysService : public KeyedService { |
| scoped_ptr<net::CertificateList> matches, |
| const std::string& error_message); |
| - // Callback used by |RegisterPublicKey|. |
| - // Updates the old |platform_keys| read from the StateStore and writes the |
| - // updated value back to the StateStore. |
| - void RegisterPublicKeyGotPlatformKeys( |
| - const std::string& extension_id, |
| - const std::string& public_key_spki_der, |
| - const base::Closure& callback, |
| - scoped_ptr<base::ListValue> platform_keys); |
| - |
| - // Callback used by |ReadValidityAndInvalidateKey|. |
| - // Invalidates the given public key so that future signing is prohibited and |
| - // calls |callback| with the old validity. |
| - void InvalidateKey(const std::string& extension_id, |
| - const std::string& public_key_spki_der, |
| - const base::Callback<void(bool)>& callback, |
| - scoped_ptr<base::ListValue> platform_keys); |
| - |
| // Callback used by |GetPlatformKeysOfExtension|. |
| // Is called with |value| set to the PlatformKeys value read from the |
| // StateStore, which it forwards to |callback|. On error, calls |callback| |
| @@ -190,6 +178,7 @@ class PlatformKeysService : public KeyedService { |
| content::BrowserContext* browser_context_; |
| extensions::StateStore* state_store_; |
| bool permission_check_enabled_ = true; |
| + std::queue<linked_ptr<Task>> tasks_; |
| base::WeakPtrFactory<PlatformKeysService> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(PlatformKeysService); |