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 COMPONENTS_TRACING_TEST_FAKE_SCATTERED_BUFFER_H_ |
| 6 #define COMPONENTS_TRACING_TEST_FAKE_SCATTERED_BUFFER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "components/tracing/core/scattered_stream_writer.h" |
| 14 #include "components/tracing/tracing_export.h" |
| 15 |
| 16 namespace tracing { |
| 17 namespace v2 { |
| 18 |
| 19 // A simple ScatteredStreamWriter::Delegate implementation which just allocates |
| 20 // chunks of a fixed size. |
| 21 class FakeScatteredBuffer : public ScatteredStreamWriter::Delegate { |
| 22 public: |
| 23 explicit FakeScatteredBuffer(size_t chunk_size); |
| 24 ~FakeScatteredBuffer(); |
| 25 |
| 26 // ScatteredStreamWriter::Delegate implementation. |
| 27 ContiguousMemoryRange GetNewBuffer() override; |
| 28 |
| 29 std::string GetChunkAsString(int chunk_index); |
| 30 |
| 31 std::string GetBytesAsString(size_t start, size_t length); |
| 32 |
| 33 const std::vector<std::unique_ptr<uint8_t[]>>& chunks() const { |
| 34 return chunks_; |
| 35 } |
| 36 |
| 37 private: |
| 38 const size_t chunk_size_; |
| 39 std::vector<std::unique_ptr<uint8_t[]>> chunks_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(FakeScatteredBuffer); |
| 42 }; |
| 43 |
| 44 } // namespace v2 |
| 45 } // namespace tracing |
| 46 |
| 47 #endif // COMPONENTS_TRACING_TEST_FAKE_SCATTERED_BUFFER_H_ |
OLD | NEW |