Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_U2F_U2F_PACKET_H_ | |
| 6 #define DEVICE_U2F_U2F_PACKET_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "net/base/io_buffer.h" | |
| 10 | |
| 11 namespace device { | |
| 12 class U2fPacket : public base::RefCountedThreadSafe<U2fPacket> { | |
| 13 public: | |
| 14 static const size_t kChannelIdSize = 4; | |
| 15 // Packet size of 64 bytes + 1 byte report ID | |
| 16 static const size_t kPacketSize = 65; | |
| 17 | |
| 18 U2fPacket(const std::vector<uint8_t> data, | |
| 19 const uint8_t channel_id[kChannelIdSize]); | |
| 20 scoped_refptr<net::IOBufferWithSize> GetBuffer(); | |
| 21 | |
| 22 protected: | |
| 23 std::vector<uint8_t> data_; | |
| 24 uint8_t channel_id_[kChannelIdSize]; | |
| 25 scoped_refptr<net::IOBufferWithSize> serialized_; | |
| 26 virtual ~U2fPacket(); | |
| 27 U2fPacket(); | |
|
Reilly Grant (use Gerrit)
2016/11/30 20:53:47
Same ordering issue here. Destructor and fields sh
Casey Piper
2016/11/30 22:05:46
Done.
| |
| 28 | |
| 29 private: | |
| 30 friend class base::RefCountedThreadSafe<U2fPacket>; | |
| 31 }; | |
| 32 | |
| 33 class U2fInitPacket : public U2fPacket { | |
| 34 public: | |
| 35 U2fInitPacket(const uint8_t channel_id[kChannelIdSize], | |
| 36 const uint8_t cmd, | |
| 37 const std::vector<uint8_t> data, | |
| 38 const uint16_t payload_length); | |
| 39 | |
| 40 scoped_refptr<U2fInitPacket> Create(scoped_refptr<net::IOBufferWithSize> buf); | |
| 41 | |
| 42 protected: | |
| 43 ~U2fInitPacket() final; | |
| 44 | |
| 45 private: | |
| 46 U2fInitPacket(scoped_refptr<net::IOBufferWithSize> buf); | |
| 47 uint8_t command_; | |
| 48 }; | |
| 49 | |
| 50 class U2fContPacket : public U2fPacket { | |
| 51 public: | |
| 52 U2fContPacket(const uint8_t channel_id[kChannelIdSize], | |
| 53 const uint8_t sequence, | |
| 54 std::vector<uint8_t> data); | |
| 55 | |
| 56 protected: | |
| 57 ~U2fContPacket() final; | |
| 58 | |
| 59 private: | |
| 60 uint8_t sequence_; | |
| 61 }; | |
| 62 } // namespace device | |
| 63 | |
| 64 #endif // DEVICE_U2F_U2F_PACKET_H_ | |
| OLD | NEW |