| 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_CORE_SPDY_FRAME_READER_H_ | 5 #ifndef NET_SPDY_CORE_SPDY_FRAME_READER_H_ |
| 6 #define NET_SPDY_CORE_SPDY_FRAME_READER_H_ | 6 #define NET_SPDY_CORE_SPDY_FRAME_READER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "net/base/net_export.h" | 11 #include "net/spdy/platform/api/spdy_export.h" |
| 12 #include "net/spdy/platform/api/spdy_string_piece.h" | 12 #include "net/spdy/platform/api/spdy_string_piece.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 // 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 |
| 17 // 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 |
| 18 // framing. | 18 // framing. |
| 19 // | 19 // |
| 20 // To use, simply construct a SpdyFramerReader using the underlying buffer that | 20 // To use, simply construct a SpdyFramerReader using the underlying buffer that |
| 21 // you'd like to read fields from, then call one of the Read*() methods to | 21 // you'd like to read fields from, then call one of the Read*() methods to |
| 22 // actually do some reading. | 22 // actually do some reading. |
| 23 // | 23 // |
| 24 // This class keeps an internal iterator to keep track of what's already been | 24 // This class keeps an internal iterator to keep track of what's already been |
| 25 // read and each successive Read*() call automatically increments said iterator | 25 // read and each successive Read*() call automatically increments said iterator |
| 26 // on success. On failure, internal state of the SpdyFrameReader should not be | 26 // on success. On failure, internal state of the SpdyFrameReader should not be |
| 27 // trusted and it is up to the caller to throw away the failed instance and | 27 // trusted and it is up to the caller to throw away the failed instance and |
| 28 // handle the error as appropriate. None of the Read*() methods should ever be | 28 // handle the error as appropriate. None of the Read*() methods should ever be |
| 29 // called after failure, as they will also fail immediately. | 29 // called after failure, as they will also fail immediately. |
| 30 class NET_EXPORT_PRIVATE SpdyFrameReader { | 30 class SPDY_EXPORT_PRIVATE SpdyFrameReader { |
| 31 public: | 31 public: |
| 32 // Caller must provide an underlying buffer to work on. | 32 // Caller must provide an underlying buffer to work on. |
| 33 SpdyFrameReader(const char* data, const size_t len); | 33 SpdyFrameReader(const char* data, const size_t len); |
| 34 | 34 |
| 35 // Empty destructor. | 35 // Empty destructor. |
| 36 ~SpdyFrameReader() {} | 36 ~SpdyFrameReader() {} |
| 37 | 37 |
| 38 // Reads an 8-bit unsigned integer into the given output parameter. | 38 // Reads an 8-bit unsigned integer into the given output parameter. |
| 39 // Forwards the internal iterator on success. | 39 // Forwards the internal iterator on success. |
| 40 // Returns true on success, false otherwise. | 40 // Returns true on success, false otherwise. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // The length of the data buffer that we're reading from. | 121 // The length of the data buffer that we're reading from. |
| 122 const size_t len_; | 122 const size_t len_; |
| 123 | 123 |
| 124 // The location of the next read from our data buffer. | 124 // The location of the next read from our data buffer. |
| 125 size_t ofs_; | 125 size_t ofs_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace net | 128 } // namespace net |
| 129 | 129 |
| 130 #endif // NET_SPDY_CORE_SPDY_FRAME_READER_H_ | 130 #endif // NET_SPDY_CORE_SPDY_FRAME_READER_H_ |
| OLD | NEW |