| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROME_PROFILING_MEMLOG_STREAM_PARSER_H_ | 5 #ifndef CHROME_PROFILING_MEMLOG_STREAM_PARSER_H_ |
| 6 #define CHROME_PROFILING_MEMLOG_STREAM_PARSER_H_ | 6 #define CHROME_PROFILING_MEMLOG_STREAM_PARSER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 std::unique_ptr<char[]> data; | 31 std::unique_ptr<char[]> data; |
| 32 size_t size; | 32 size_t size; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 enum ReadStatus { | 35 enum ReadStatus { |
| 36 READ_OK, // Read OK. | 36 READ_OK, // Read OK. |
| 37 READ_ERROR, // Fatal error, don't send more data. | 37 READ_ERROR, // Fatal error, don't send more data. |
| 38 READ_NO_DATA // Not enough data, try again when we get more | 38 READ_NO_DATA // Not enough data, try again when we get more |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 ~MemlogStreamParser() override; | 41 ~MemlogStreamParser(); |
| 42 | 42 |
| 43 // Returns true if the given number of bytes are available now. | 43 // Returns true if the given number of bytes are available now. |
| 44 bool AreBytesAvailable(size_t count) const; | 44 bool AreBytesAvailable(size_t count) const; |
| 45 | 45 |
| 46 // Returns false if not enough bytes are available. On failure, the dest | 46 // Returns false if not enough bytes are available. On failure, the dest |
| 47 // buffer will be in an undefined state (it may be written partially). | 47 // buffer will be in an undefined state (it may be written partially). |
| 48 bool PeekBytes(size_t count, void* dest) const; | 48 bool PeekBytes(size_t count, void* dest) const; |
| 49 bool ReadBytes(size_t count, void* dest); | 49 bool ReadBytes(size_t count, void* dest); |
| 50 void ConsumeBytes(size_t count); // Bytes must be available. | 50 void ConsumeBytes(size_t count); // Bytes must be available. |
| 51 | 51 |
| 52 ReadStatus ParseHeader(); | 52 ReadStatus ParseHeader(); |
| 53 ReadStatus ParseAlloc(); | 53 ReadStatus ParseAlloc(); |
| 54 ReadStatus ParseFree(); | 54 ReadStatus ParseFree(); |
| 55 | 55 |
| 56 MemlogReceiver* receiver_; // Not owned by this class. | 56 MemlogReceiver* receiver_; // Not owned by this class. |
| 57 | 57 |
| 58 std::deque<Block> blocks_; | 58 std::deque<Block> blocks_; |
| 59 | 59 |
| 60 bool received_header_ = false; | 60 bool received_header_ = false; |
| 61 | 61 |
| 62 // Current offset into blocks_[0] of the next packet to process. | 62 // Current offset into blocks_[0] of the next packet to process. |
| 63 size_t block_zero_offset_ = 0; | 63 size_t block_zero_offset_ = 0; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(MemlogStreamParser); | 65 DISALLOW_COPY_AND_ASSIGN(MemlogStreamParser); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace profiling | 68 } // namespace profiling |
| 69 | 69 |
| 70 #endif // CHROME_PROFILING_MEMLOG_STREAM_PARSER_H_ | 70 #endif // CHROME_PROFILING_MEMLOG_STREAM_PARSER_H_ |
| OLD | NEW |