OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_SPDY_SPDY_FRAME_READER_H_ | 5 #ifndef NET_SPDY_SPDY_FRAME_READER_H_ |
6 #define NET_SPDY_SPDY_FRAME_READER_H_ | 6 #define NET_SPDY_SPDY_FRAME_READER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
9 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
10 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
11 | 13 |
12 namespace net { | 14 namespace net { |
13 | 15 |
14 // Used for reading SPDY frames. Though there isn't really anything terribly | 16 // Used for reading SPDY frames. Though there isn't really anything terribly |
15 // SPDY-specific here, it's a helper class that's useful when doing SPDY | 17 // SPDY-specific here, it's a helper class that's useful when doing SPDY |
16 // framing. | 18 // framing. |
17 // | 19 // |
18 // To use, simply construct a SpdyFramerReader using the underlying buffer that | 20 // To use, simply construct a SpdyFramerReader using the underlying buffer that |
(...skipping 10 matching lines...) Expand all Loading... |
29 public: | 31 public: |
30 // Caller must provide an underlying buffer to work on. | 32 // Caller must provide an underlying buffer to work on. |
31 SpdyFrameReader(const char* data, const size_t len); | 33 SpdyFrameReader(const char* data, const size_t len); |
32 | 34 |
33 // Empty destructor. | 35 // Empty destructor. |
34 ~SpdyFrameReader() {} | 36 ~SpdyFrameReader() {} |
35 | 37 |
36 // Reads an 8-bit unsigned integer into the given output parameter. | 38 // Reads an 8-bit unsigned integer into the given output parameter. |
37 // Forwards the internal iterator on success. | 39 // Forwards the internal iterator on success. |
38 // Returns true on success, false otherwise. | 40 // Returns true on success, false otherwise. |
39 bool ReadUInt8(uint8* result); | 41 bool ReadUInt8(uint8_t* result); |
40 | 42 |
41 // Reads a 16-bit unsigned integer into the given output parameter. | 43 // Reads a 16-bit unsigned integer into the given output parameter. |
42 // Forwards the internal iterator on success. | 44 // Forwards the internal iterator on success. |
43 // Returns true on success, false otherwise. | 45 // Returns true on success, false otherwise. |
44 bool ReadUInt16(uint16* result); | 46 bool ReadUInt16(uint16_t* result); |
45 | 47 |
46 // Reads a 32-bit unsigned integer into the given output parameter. | 48 // Reads a 32-bit unsigned integer into the given output parameter. |
47 // Forwards the internal iterator on success. | 49 // Forwards the internal iterator on success. |
48 // Returns true on success, false otherwise. | 50 // Returns true on success, false otherwise. |
49 bool ReadUInt32(uint32* result); | 51 bool ReadUInt32(uint32_t* result); |
50 | 52 |
51 // Reads a 64-bit unsigned integer into the given output parameter. | 53 // Reads a 64-bit unsigned integer into the given output parameter. |
52 // Forwards the internal iterator on success. | 54 // Forwards the internal iterator on success. |
53 // Returns true on success, false otherwise. | 55 // Returns true on success, false otherwise. |
54 bool ReadUInt64(uint64* result); | 56 bool ReadUInt64(uint64_t* result); |
55 | 57 |
56 // Reads a 31-bit unsigned integer into the given output parameter. This is | 58 // Reads a 31-bit unsigned integer into the given output parameter. This is |
57 // equivalent to ReadUInt32() above except that the highest-order bit is | 59 // equivalent to ReadUInt32() above except that the highest-order bit is |
58 // discarded. | 60 // discarded. |
59 // Forwards the internal iterator (by 4B) on success. | 61 // Forwards the internal iterator (by 4B) on success. |
60 // Returns true on success, false otherwise. | 62 // Returns true on success, false otherwise. |
61 bool ReadUInt31(uint32* result); | 63 bool ReadUInt31(uint32_t* result); |
62 | 64 |
63 // Reads a 24-bit unsigned integer into the given output parameter. | 65 // Reads a 24-bit unsigned integer into the given output parameter. |
64 // Forwards the internal iterator (by 3B) on success. | 66 // Forwards the internal iterator (by 3B) on success. |
65 // Returns true on success, false otherwise. | 67 // Returns true on success, false otherwise. |
66 bool ReadUInt24(uint32* result); | 68 bool ReadUInt24(uint32_t* result); |
67 | 69 |
68 // Reads a string prefixed with 16-bit length into the given output parameter. | 70 // Reads a string prefixed with 16-bit length into the given output parameter. |
69 // | 71 // |
70 // NOTE: Does not copy but rather references strings in the underlying buffer. | 72 // NOTE: Does not copy but rather references strings in the underlying buffer. |
71 // This should be kept in mind when handling memory management! | 73 // This should be kept in mind when handling memory management! |
72 // | 74 // |
73 // Forwards the internal iterator on success. | 75 // Forwards the internal iterator on success. |
74 // Returns true on success, false otherwise. | 76 // Returns true on success, false otherwise. |
75 bool ReadStringPiece16(base::StringPiece* result); | 77 bool ReadStringPiece16(base::StringPiece* result); |
76 | 78 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // The length of the data buffer that we're reading from. | 121 // The length of the data buffer that we're reading from. |
120 const size_t len_; | 122 const size_t len_; |
121 | 123 |
122 // The location of the next read from our data buffer. | 124 // The location of the next read from our data buffer. |
123 size_t ofs_; | 125 size_t ofs_; |
124 }; | 126 }; |
125 | 127 |
126 } // namespace net | 128 } // namespace net |
127 | 129 |
128 #endif // NET_SPDY_SPDY_FRAME_READER_H_ | 130 #endif // NET_SPDY_SPDY_FRAME_READER_H_ |
OLD | NEW |