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_ |