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

Unified Diff: content/renderer/webcrypto/webcrypto_util.h

Issue 145083006: [webcrypto] Add error messages for failed operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check the Status in unittests Created 6 years, 11 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: content/renderer/webcrypto/webcrypto_util.h
diff --git a/content/renderer/webcrypto/webcrypto_util.h b/content/renderer/webcrypto/webcrypto_util.h
index e3ea94b865ecce0d1dd84aa6c67265059fcad7b4..acda3581cdb44a66a9d9e19db680857817dae14f 100644
--- a/content/renderer/webcrypto/webcrypto_util.h
+++ b/content/renderer/webcrypto/webcrypto_util.h
@@ -17,6 +17,58 @@ namespace content {
namespace webcrypto {
+// |Status| indicates whether an operation completed successfully, or with an
Ryan Sleevi 2014/01/24 01:21:50 nit: No | | - this is not a variable, it's a class
eroman 2014/01/24 03:19:21 Shrug. There are examples of both models in Chromi
Ryan Sleevi 2014/01/24 20:27:01 I didn't have strong objections, I just wanted to
+// error.
+class CONTENT_EXPORT Status {
+ public:
+ bool IsError() const;
+ bool IsSuccess() const;
+
+ // Returns a UTF-8 error message (non-localized) describing the error.
+ std::string ToString() const;
+
+ static Status Success();
+ static Status Error();
+
+ static Status ErrorEmptyKeyData();
+ static Status ErrorEmptyData();
+ static Status ErrorEmptySignatureData();
+ static Status ErrorUnexpectedKeyType();
+
+ static Status ErrorJwkNotDictionary();
+ static Status ErrorJwkMissingKty();
+ static Status ErrorJwkExtractableInconsistent();
+ static Status ErrorJwkUnrecognizedAlgorithm();
+ static Status ErrorJwkAlgorithmInconsistent();
+ static Status ErrorJwkAlgorithmMissing();
+ static Status ErrorJwkUnrecognizedUsage();
+ static Status ErrorJwkUsageInconsistent();
+ static Status ErrorJwkDecodeK();
+ static Status ErrorJwkDecodeN();
+ static Status ErrorJwkDecodeE();
+ static Status ErrorJwkRsaPrivateKeyUnsupported();
+ static Status ErrorJwkUnrecognizedKty();
+
+ static Status ErrorIncorrectSizedIv();
+ static Status ErrorDataTooBig();
+ static Status ErrorUnsupported();
+ static Status ErrorUnexpected();
+ static Status ErrorInvalidAesGcmTagLength();
+ static Status ErrorPublicExponent();
+ static Status ErrorMissingAlgorithmRawKey();
+ static Status ErrorEmptyModulus();
+ static Status ErrorEmptyExponent();
+ static Status ErrorKeyNotExtractable();
+ static Status ErrorKeyLength();
Ryan Sleevi 2014/01/24 20:27:01 At the risk of being a real PITA, can I ask you to
eroman 2014/01/25 00:53:10 Done. I have added comments for each of the errors
+
+ private:
+ // |error_details_utf8| can be NULL to indicate there was no error.
+ // Otherwise it is a UTF-8 string literal (the pointer must remain valid).
+ explicit Status(const char* error_details_utf8);
+
+ const char* error_details_;
+};
+
// Returns a pointer to the start of |data|, or NULL if it is empty. This is a
// convenience function for getting the pointer, and should not be used beyond
// the expected lifetime of |data|.

Powered by Google App Engine
This is Rietveld 408576698