Index: content/child/webcrypto/generate_key_result.h |
diff --git a/content/child/webcrypto/generate_key_result.h b/content/child/webcrypto/generate_key_result.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0c52fbaabf9ea01de9283451337acba3d9bc37d4 |
--- /dev/null |
+++ b/content/child/webcrypto/generate_key_result.h |
@@ -0,0 +1,64 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_ |
+#define CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_ |
+ |
+#include "content/common/content_export.h" |
+#include "third_party/WebKit/public/platform/WebCrypto.h" |
+ |
+namespace content { |
+ |
+namespace webcrypto { |
+ |
+// This is the result object when generating keys. It encapsulates either a |
+// secret key, or a public/private key pair. |
+class CONTENT_EXPORT GenerateKeyResult { |
+ public: |
+ enum Type { |
+ // An empty (or "null") result. |
+ TYPE_NULL, |
+ |
+ // The result is a secret key, accessible through secret_key() |
+ TYPE_SECRET_KEY, |
+ |
+ // The result is a public/private key pair, accessible through public_key() |
+ // and private_key() |
+ TYPE_PUBLIC_PRIVATE_KEY_PAIR |
+ }; |
+ |
+ // Initializes a "null" instance. |
+ GenerateKeyResult(); |
+ |
+ Type type() const; |
+ |
+ // Changes the type of the result. To subsequently assign the key(s) use the |
+ // mutable_* methods. |
+ void set_type(Type type); |
+ |
+ const blink::WebCryptoKey& secret_key() const; |
+ const blink::WebCryptoKey& public_key() const; |
+ const blink::WebCryptoKey& private_key() const; |
+ |
+ blink::WebCryptoKey* mutable_secret_key(); |
+ blink::WebCryptoKey* mutable_public_key(); |
+ blink::WebCryptoKey* mutable_private_key(); |
+ |
+ // Sends the key(s) to the Blink result. Should not be called for "null" |
+ // results. |
+ void Complete(blink::WebCryptoResult* out) const; |
+ |
+ private: |
+ Type type_; |
+ |
+ blink::WebCryptoKey secret_key_; |
+ blink::WebCryptoKey public_key_; |
+ blink::WebCryptoKey private_key_; |
Ryan Sleevi
2014/10/17 21:01:58
since blink::WebCryptoKey types are direct-assigna
eroman
2014/10/17 22:43:12
Done. I agree mutable_ was a bit odd and not idiom
|
+}; |
+ |
+} // namespace webcrypto |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_ |