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

Unified Diff: device/u2f/u2f_apdu_response.h

Issue 2743623006: Modify U2F apdu classes to use unique pointers (Closed)
Patch Set: Created 3 years, 9 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: device/u2f/u2f_apdu_response.h
diff --git a/device/u2f/u2f_apdu_response.h b/device/u2f/u2f_apdu_response.h
index a52faf1e945d24f0a832943e42dd610443ca296f..44bf7d61af1825c75d31a0b838373b67d0de339d 100644
--- a/device/u2f/u2f_apdu_response.h
+++ b/device/u2f/u2f_apdu_response.h
@@ -5,6 +5,7 @@
#ifndef DEVICE_U2F_U2F_APDU_RESPONSE_H_
#define DEVICE_U2F_U2F_APDU_RESPONSE_H_
+#include <memory>
#include <vector>
#include "base/gtest_prod_util.h"
@@ -15,7 +16,7 @@ namespace device {
// APDU responses are defined as part of ISO 7816-4. Serialized responses
// consist of a data field of varying length, up to a maximum 65536, and a
// two byte status field.
-class U2fApduResponse : public base::RefCountedThreadSafe<U2fApduResponse> {
+class U2fApduResponse {
public:
// Status bytes are specified in ISO 7816-4
enum class Status : uint16_t {
@@ -24,20 +25,19 @@ class U2fApduResponse : public base::RefCountedThreadSafe<U2fApduResponse> {
SW_WRONG_DATA = 0x6A80,
};
+ U2fApduResponse(std::vector<uint8_t> message, Status response_status);
+ ~U2fApduResponse();
+
// Create a APDU response from the serialized message
- static scoped_refptr<U2fApduResponse> CreateFromMessage(
+ static std::unique_ptr<U2fApduResponse> CreateFromMessage(
const std::vector<uint8_t>& data);
std::vector<uint8_t> GetEncodedResponse() const;
const std::vector<uint8_t> data() const { return data_; };
Status status() const { return response_status_; };
private:
- friend class base::RefCountedThreadSafe<U2fApduResponse>;
FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestDeserializeResponse);
- U2fApduResponse(std::vector<uint8_t> message, Status response_status);
- ~U2fApduResponse();
-
Status response_status_;
std::vector<uint8_t> data_;
};

Powered by Google App Engine
This is Rietveld 408576698