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

Side by Side 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: Removed NOT_STARTED state. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
7 7
8 #include <queue>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/linked_ptr.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" 17 #include "chrome/browser/chromeos/platform_keys/platform_keys.h"
16 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
17 19
18 namespace content { 20 namespace content {
19 class BrowserContext; 21 class BrowserContext;
20 } 22 }
21 23
22 namespace base { 24 namespace base {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // certificate dialog. 110 // certificate dialog.
109 void SelectClientCertificates( 111 void SelectClientCertificates(
110 const platform_keys::ClientCertificateRequest& request, 112 const platform_keys::ClientCertificateRequest& request,
111 const std::string& extension_id, 113 const std::string& extension_id,
112 const SelectCertificatesCallback& callback); 114 const SelectCertificatesCallback& callback);
113 115
114 private: 116 private:
115 using GetPlatformKeysCallback = 117 using GetPlatformKeysCallback =
116 base::Callback<void(scoped_ptr<base::ListValue> platform_keys)>; 118 base::Callback<void(scoped_ptr<base::ListValue> platform_keys)>;
117 119
118 // Registers the given public key as newly generated key, which is allowed to 120 class Task;
119 // be used for signing for a single time. Afterwards, calls |callback|. If 121 class SignTask;
120 // registration was successful, passes |true| otherwise |false| to the 122 class PermissionUpdateTask;
121 // callback.
122 void RegisterPublicKey(const std::string& extension_id,
123 const std::string& public_key_spki_der,
124 const base::Closure& callback);
125 123
126 // Gets the current validity of the given public key by reading StateStore. 124 // Starts |task| eventually. To ensures that at most one |Task| is running at
127 // Invalidates the key if it was found to be valid. Finally, calls |callback| 125 // a time, it queues |task| for later execution if necessary.
128 // with the old validity. 126 void StartOrQueueTask(scoped_ptr<Task> task);
129 void ReadValidityAndInvalidateKey(const std::string& extension_id, 127
130 const std::string& public_key_spki_der, 128 // Must be called after |task| is done. |task| will be invalid after this
131 const base::Callback<void(bool)>& callback); 129 // call. This must not be called for any but the task that ran last. If any
130 // other tasks are queued (see StartOrQueueTask()), it will start the next
131 // one.
132 void TaskFinished(Task* task);
132 133
133 // Reads the list of public keys currently registered for |extension_id| from 134 // Reads the list of public keys currently registered for |extension_id| from
134 // StateStore. Calls |callback| with the read list, or a new empty list if 135 // StateStore. Calls |callback| with the read list, or a new empty list if
135 // none existed. If an error occurred, calls |callback| with NULL. 136 // none existed. If an error occurred, calls |callback| with NULL.
136 void GetPlatformKeysOfExtension(const std::string& extension_id, 137 void GetPlatformKeysOfExtension(const std::string& extension_id,
137 const GetPlatformKeysCallback& callback); 138 const GetPlatformKeysCallback& callback);
138 139
139 // Writes |platform_keys| to the state store of the extension with id 140 // Writes |platform_keys| to the state store of the extension with id
140 // |extension_id|. 141 // |extension_id|.
141 void SetPlatformKeysOfExtension(const std::string& extension_id, 142 void SetPlatformKeysOfExtension(const std::string& extension_id,
142 scoped_ptr<base::ListValue> platform_keys); 143 scoped_ptr<base::ListValue> platform_keys);
143 144
144 // Callback used by |GenerateRSAKey|. 145 // Callback used by |GenerateRSAKey|.
145 // If the key generation was successful, registers the generated public key 146 // If the key generation was successful, registers the generated public key
146 // for the given extension. If any error occurs during key generation or 147 // for the given extension. If any error occurs during key generation or
147 // registration, calls |callback| with an error. Otherwise, on success, calls 148 // registration, calls |callback| with an error. Otherwise, on success, calls
148 // |callback| with the public key. 149 // |callback| with the public key.
149 void GenerateRSAKeyCallback(const std::string& extension_id, 150 void GeneratedKey(const std::string& extension_id,
150 const GenerateKeyCallback& callback, 151 const GenerateKeyCallback& callback,
151 const std::string& public_key_spki_der, 152 const std::string& public_key_spki_der,
152 const std::string& error_message); 153 const std::string& error_message);
154
155 // Callback used by |GeneratedKey|.
156 // |public_key_spki_der| will contain the X.509 Subject Public Key Info of
157 // the generated key in DER encoding. |task| points to the finished |Task|
158 // object.
159 void DidRegisterGeneratedKey(const GenerateKeyCallback& callback,
160 const std::string& public_key_spki_der,
161 Task* task);
153 162
154 // Calback used by |SelectClientCertificates|. 163 // Calback used by |SelectClientCertificates|.
155 // If the certificate request could be processed successfully, |matches| will 164 // If the certificate request could be processed successfully, |matches| will
156 // contain the list of matching certificates (maybe empty) and |error_message| 165 // contain the list of matching certificates (maybe empty) and |error_message|
157 // will be empty. If an error occurred, |matches| will be null and 166 // will be empty. If an error occurred, |matches| will be null and
158 // |error_message| contain an error message. 167 // |error_message| contain an error message.
159 void SelectClientCertificatesCallback( 168 void SelectClientCertificatesCallback(
160 const std::string& extension_id, 169 const std::string& extension_id,
161 const SelectCertificatesCallback& callback, 170 const SelectCertificatesCallback& callback,
162 scoped_ptr<net::CertificateList> matches, 171 scoped_ptr<net::CertificateList> matches,
163 const std::string& error_message); 172 const std::string& error_message);
164 173
165 // Callback used by |RegisterPublicKey|.
166 // Updates the old |platform_keys| read from the StateStore and writes the
167 // updated value back to the StateStore.
168 void RegisterPublicKeyGotPlatformKeys(
169 const std::string& extension_id,
170 const std::string& public_key_spki_der,
171 const base::Closure& callback,
172 scoped_ptr<base::ListValue> platform_keys);
173
174 // Callback used by |ReadValidityAndInvalidateKey|.
175 // Invalidates the given public key so that future signing is prohibited and
176 // calls |callback| with the old validity.
177 void InvalidateKey(const std::string& extension_id,
178 const std::string& public_key_spki_der,
179 const base::Callback<void(bool)>& callback,
180 scoped_ptr<base::ListValue> platform_keys);
181
182 // Callback used by |GetPlatformKeysOfExtension|. 174 // Callback used by |GetPlatformKeysOfExtension|.
183 // Is called with |value| set to the PlatformKeys value read from the 175 // Is called with |value| set to the PlatformKeys value read from the
184 // StateStore, which it forwards to |callback|. On error, calls |callback| 176 // StateStore, which it forwards to |callback|. On error, calls |callback|
185 // with NULL; if no value existed, with an empty list. 177 // with NULL; if no value existed, with an empty list.
186 void GotPlatformKeysOfExtension(const std::string& extension_id, 178 void GotPlatformKeysOfExtension(const std::string& extension_id,
187 const GetPlatformKeysCallback& callback, 179 const GetPlatformKeysCallback& callback,
188 scoped_ptr<base::Value> value); 180 scoped_ptr<base::Value> value);
189 181
190 content::BrowserContext* browser_context_; 182 content::BrowserContext* browser_context_;
191 extensions::StateStore* state_store_; 183 extensions::StateStore* state_store_;
192 bool permission_check_enabled_ = true; 184 bool permission_check_enabled_ = true;
185 std::queue<linked_ptr<Task>> tasks_;
193 base::WeakPtrFactory<PlatformKeysService> weak_factory_; 186 base::WeakPtrFactory<PlatformKeysService> weak_factory_;
194 187
195 DISALLOW_COPY_AND_ASSIGN(PlatformKeysService); 188 DISALLOW_COPY_AND_ASSIGN(PlatformKeysService);
196 }; 189 };
197 190
198 } // namespace chromeos 191 } // namespace chromeos
199 192
200 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 193 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698