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

Unified Diff: device/u2f/u2f_packet.h

Issue 2771673002: Use vectors instead of IOBuffer for U2fPackets (Closed)
Patch Set: Use vectors instead of IOBuffer for U2fPackets 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_packet.h
diff --git a/device/u2f/u2f_packet.h b/device/u2f/u2f_packet.h
index 97fd1156a0566bcd1ed7ae3a5808aa5d07406e9c..92ecb56aa22275044b24398b50f27b0068d2022f 100644
--- a/device/u2f/u2f_packet.h
+++ b/device/u2f/u2f_packet.h
@@ -10,10 +10,6 @@
#include "base/memory/ref_counted.h"
-namespace net {
-class IOBufferWithSize;
-} // namespace net
-
namespace device {
// U2fPackets are defined by the specification at
@@ -28,7 +24,7 @@ class U2fPacket {
U2fPacket(const std::vector<uint8_t> data, uint32_t channel_id);
virtual ~U2fPacket();
- scoped_refptr<net::IOBufferWithSize> GetSerializedBuffer();
+ virtual std::vector<uint8_t> GetSerializedData() = 0;
std::vector<uint8_t> GetPacketPayload() const;
uint32_t channel_id() { return channel_id_; }
@@ -39,7 +35,6 @@ class U2fPacket {
static constexpr size_t kPacketSize = 65;
std::vector<uint8_t> data_;
uint32_t channel_id_;
- scoped_refptr<net::IOBufferWithSize> serialized_;
private:
friend class U2fMessage;
@@ -57,8 +52,7 @@ class U2fInitPacket : public U2fPacket {
uint8_t cmd,
const std::vector<uint8_t> data,
uint16_t payload_length);
- U2fInitPacket(scoped_refptr<net::IOBufferWithSize> buf,
- size_t* remaining_size);
+ U2fInitPacket(std::vector<uint8_t> serialized, size_t* remaining_size);
Reilly Grant (use Gerrit) 2017/03/22 23:08:17 const std::vector<uint8_t>&
Casey Piper 2017/03/23 03:47:25 Done.
~U2fInitPacket() final;
// Creates a packet from the serialized data of an initialization packet. As
@@ -66,8 +60,9 @@ class U2fInitPacket : public U2fPacket {
// included within the serialized data. Remaining size will be returned to
// inform the callee how many additional packets to expect.
static std::unique_ptr<U2fInitPacket> CreateFromSerializedData(
- scoped_refptr<net::IOBufferWithSize> buf,
+ std::vector<uint8_t> serialized,
Reilly Grant (use Gerrit) 2017/03/22 23:08:17 const std::vector<uint8_t>&
Casey Piper 2017/03/23 03:47:25 Done.
size_t* remaining_size);
+ std::vector<uint8_t> GetSerializedData() final;
uint8_t command() { return command_; }
uint16_t payload_length() { return payload_length_; }
@@ -86,7 +81,7 @@ class U2fContinuationPacket : public U2fPacket {
U2fContinuationPacket(const uint32_t channel_id,
const uint8_t sequence,
std::vector<uint8_t> data);
- U2fContinuationPacket(scoped_refptr<net::IOBufferWithSize> buf,
+ U2fContinuationPacket(std::vector<uint8_t> serialized,
Reilly Grant (use Gerrit) 2017/03/22 23:08:17 const std::vector<uint8_t>&
Casey Piper 2017/03/23 03:47:25 Done.
size_t* remaining_size);
~U2fContinuationPacket() final;
@@ -95,8 +90,9 @@ class U2fContinuationPacket : public U2fPacket {
// the remaining size should be passed to inform the packet of how much data
// to expect.
static std::unique_ptr<U2fContinuationPacket> CreateFromSerializedData(
- scoped_refptr<net::IOBufferWithSize> buf,
+ std::vector<uint8_t> serialized,
size_t* remaining_size);
+ std::vector<uint8_t> GetSerializedData() final;
uint8_t sequence() { return sequence_; }
private:

Powered by Google App Engine
This is Rietveld 408576698