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

Side by Side Diff: components/tracing/core/trace_buffer_writer_unittest.cc

Issue 2303353002: Tracing v2: wire up stubs generated by the protozero protoc plugin (Closed)
Patch Set: petrcermak review Created 4 years, 3 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
« no previous file with comments | « components/tracing/core/trace_buffer_writer.cc ('k') | components/tracing/proto/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/tracing/core/trace_buffer_writer.h" 5 #include "components/tracing/core/trace_buffer_writer.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "components/tracing/core/trace_ring_buffer.h" 9 #include "components/tracing/core/trace_ring_buffer.h"
10 #include "components/tracing/proto/event.pbzero.h"
10 #include "components/tracing/test/golden_protos/events_chunk.pb.h" 11 #include "components/tracing/test/golden_protos/events_chunk.pb.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace tracing { 14 namespace tracing {
14 namespace v2 { 15 namespace v2 {
15 namespace { 16 namespace {
16 17
17 class MockEvent : public ::tracing::proto::Event { 18 class MockEvent : public pbzero::tracing::proto::Event {
18 public: 19 public:
19 static TraceEventHandle Add(TraceBufferWriter* writer, size_t event_size) { 20 static TraceEventHandle Add(TraceBufferWriter* writer, size_t event_size) {
20 TraceEventHandle handle = writer->AddEvent(); 21 TraceEventHandle handle = writer->AddEvent();
21 MockEvent* mock_event = static_cast<MockEvent*>(&*handle); 22 MockEvent* mock_event = static_cast<MockEvent*>(&*handle);
22 23
23 size_t buffer_size = 0; 24 size_t buffer_size = 0;
24 DCHECK_GT(event_size, 2u); 25 DCHECK_GT(event_size, 2u);
25 if (event_size < (1 << 7) + 2) 26 if (event_size < (1 << 7) + 2)
26 buffer_size = event_size - 2; 27 buffer_size = event_size - 2;
27 else if (event_size < (1 << 14) + 3) 28 else if (event_size < (1 << 14) + 3)
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // writer[3] did the last write before the bankrupcy and has one extra event. 303 // writer[3] did the last write before the bankrupcy and has one extra event.
303 ReadBackAndTestChunk(8, writer[3]->writer_id(), 1, 3, true, true); 304 ReadBackAndTestChunk(8, writer[3]->writer_id(), 1, 3, true, true);
304 305
305 // writer[4] overflew in the bankrupcy chunk and has 3 events as well. 306 // writer[4] overflew in the bankrupcy chunk and has 3 events as well.
306 ReadBackAndTestChunk(9, writer[4]->writer_id(), 1, 3, true, true); 307 ReadBackAndTestChunk(9, writer[4]->writer_id(), 1, 3, true, true);
307 } 308 }
308 309
309 } // namespace 310 } // namespace
310 } // namespace v2 311 } // namespace v2
311 } // namespace tracing 312 } // namespace tracing
OLDNEW
« no previous file with comments | « components/tracing/core/trace_buffer_writer.cc ('k') | components/tracing/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698