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

Unified Diff: content/renderer/webcrypto_digest.h

Issue 19757011: WebCrypto: Implement digest() using NSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More documentation of interfaces, use of scoped_ptr for better memory management. Created 7 years, 4 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
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/webcrypto_digest_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webcrypto_digest.h
diff --git a/content/renderer/webcrypto_digest.h b/content/renderer/webcrypto_digest.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b42aa14cb7ea3ca3509b2ad52d8b0c4f13f73f1
--- /dev/null
+++ b/content/renderer/webcrypto_digest.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2013 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_RENDERER_WEBCRYPTO_DIGEST_H_
+#define CONTENT_RENDERER_WEBCRYPTO_DIGEST_H_
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+
+#include "third_party/WebKit/public/platform/WebCrypto.h"
+#include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
+
+#if defined(USE_NSS)
+typedef struct HASHContextStr HASHContext;
+#endif
+
+namespace content {
+
+class WebCryptoDigest : public WebKit::WebCryptoOperation {
+ public:
+ explicit WebCryptoDigest(const WebKit::WebCryptoOperationResult& result);
+ virtual ~WebCryptoDigest();
+
+ bool Initialize(const WebKit::WebCryptoAlgorithm& algorithm);
+
+ // WebKit::WebCryptoOperation implementation
+ //
+ // Feeds data to the digest operation.
+ // - |bytes| may be 0 if |size| is 0
+ // - |bytes| is valid only until process() returns
+ // - process() will not be called after abort() or finish()
+ virtual void process(const unsigned char* bytes, size_t size);
+ // Cancels the in-process digest operation.
+ virtual void abort();
+ // Indicates that there is no more data to receive.
+ virtual void finish();
+
+ private:
+ WebKit::WebCryptoOperationResult result_;
+
+#if defined(USE_NSS)
+ struct HASHDeleter {
+ void operator()(void* ptr) const;
+ };
+ scoped_ptr<HASHContext, HASHDeleter> context_;
Ryan Sleevi 2013/08/13 18:58:16 style: You should just be able to forward declare
Bryan Eyler 2013/08/13 23:24:12 I get compile-time errors if I try to forward-decl
Ryan Sleevi 2013/08/13 23:24:47 Yes
Bryan Eyler 2013/08/13 23:34:08 Done.
+#endif
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_WEBCRYPTO_DIGEST_H_
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/webcrypto_digest_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698