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