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

Unified Diff: chrome/browser/chromeos/platform_keys/platform_keys_service.h

Issue 892103003: PlatformKeysService: Process state accessing operations sequentially. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_impl_sign
Patch Set: Addressed comments. Created 5 years, 10 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: 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..41a57478bc312998402d0a17cfe4164001133317 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,19 @@ 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;
+
+ // Starts |task| eventually. To ensures that at most one |Task| is running at
kaliamoorthi 2015/02/09 16:02:10 nit: ensures -> ensure
pneubeck (no reviews) 2015/02/15 09:25:57 Done.
+ // a time, it queues |task| for later execution if necessary.
+ 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 +147,18 @@ 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|.
+ // |public_key_spki_der| will contain the X.509 Subject Public Key Info of
+ // the generated key in DER encoding. |task| points to the finished |Task|
+ // object.
+ 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 +171,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 +182,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);

Powered by Google App Engine
This is Rietveld 408576698