Make //crypto factories return std::unique_ptr<>s
Rather than make callers use base::WrapUnique or .reset(),
have //crypto functions that create new instances return them
in std::unique_ptr<>s
Also fixup NULL vs nullptr where it matters most, and remove
superflous .get() tests from the unique_ptr<>s
BUG=none
[email protected]
Review-Url: https://codereview.chromium.org/2095523002
Cr-Commit-Position: refs/heads/master@{#402368}
diff --git a/crypto/ec_signature_creator.h b/crypto/ec_signature_creator.h
index 47128fed..72e09df 100644
--- a/crypto/ec_signature_creator.h
+++ b/crypto/ec_signature_creator.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include <vector>
@@ -21,7 +22,7 @@
public:
virtual ~ECSignatureCreatorFactory() {}
- virtual ECSignatureCreator* Create(ECPrivateKey* key) = 0;
+ virtual std::unique_ptr<ECSignatureCreator> Create(ECPrivateKey* key) = 0;
};
// Signs data using a bare private key (as opposed to a full certificate).
@@ -35,7 +36,7 @@
// instance outlives the created ECSignatureCreator.
// TODO(rch): This is currently hard coded to use SHA256. Ideally, we should
// pass in the hash algorithm identifier.
- static ECSignatureCreator* Create(ECPrivateKey* key);
+ static std::unique_ptr<ECSignatureCreator> Create(ECPrivateKey* key);
// Set a factory to make the Create function return non-standard
// ECSignatureCreator objects. Because the ECDSA algorithm involves