Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: components/tracing/test/fake_scattered_buffer.h

Issue 2138903002: tracing v2: refactor fake_scattered_buffer class for tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: petr review Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW
« no previous file with comments | « components/tracing/core/scattered_stream_writer_unittest.cc ('k') | components/tracing/test/fake_scattered_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698