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

Side by Side Diff: components/tracing/core/trace_ring_buffer.h

Issue 2228593004: Revert of tracing v2: Introduce TraceBufferWriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proto_refactor
Patch Set: Created 4 years, 4 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
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_CORE_TRACE_RING_BUFFER_H_ 5 #ifndef COMPONENTS_TRACING_CORE_TRACE_RING_BUFFER_H_
6 #define COMPONENTS_TRACING_CORE_TRACE_RING_BUFFER_H_ 6 #define COMPONENTS_TRACING_CORE_TRACE_RING_BUFFER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "components/tracing/tracing_export.h" 13 #include "components/tracing/tracing_export.h"
14 14
15 namespace tracing { 15 namespace tracing {
16 namespace v2 { 16 namespace v2 {
17 17
18 static const uint32_t kNoChunkOwner = 0; 18 static const uint32_t kNoChunkOwner = 0;
19 static const size_t kChunkSize = 32 * 1024;
20 19
21 class TRACING_EXPORT TraceRingBuffer { 20 class TRACING_EXPORT TraceRingBuffer {
22 public: 21 public:
23 class Chunk { 22 class Chunk {
24 public: 23 public:
25 using Header = base::subtle::Atomic32; 24 using Header = base::subtle::Atomic32;
25 static constexpr size_t kSize = 32 * 1024;
26 26
27 Chunk(); 27 Chunk();
28 ~Chunk(); 28 ~Chunk();
29 29
30 void Initialize(uint8_t* begin); 30 void Initialize(uint8_t* begin);
31 void Clear(); 31 void Clear();
32 32
33 uint8_t* begin() const { return begin_; } 33 uint8_t* begin() const { return begin_; }
34 Header* header() const { return reinterpret_cast<Header*>(begin_); } 34 Header* header() const { return reinterpret_cast<Header*>(begin_); }
35 uint8_t* payload() const { return begin_ + sizeof(Header); } 35 uint8_t* payload() const { return begin_ + sizeof(Header); }
36 uint8_t* end() const { return begin_ + kChunkSize; } 36 uint8_t* end() const { return begin_ + kSize; }
37 37
38 void set_used_size(uint32_t size) { 38 void set_used_size(uint32_t size) {
39 base::subtle::NoBarrier_Store(header(), size); 39 base::subtle::NoBarrier_Store(header(), size);
40 } 40 }
41 uint32_t used_size() const { 41 uint32_t used_size() const {
42 return base::subtle::NoBarrier_Load(header()); 42 return base::subtle::NoBarrier_Load(header());
43 } 43 }
44 44
45 void set_next_in_owner_list(Chunk* next) { next_in_owner_list_ = next; } 45 void set_next_in_owner_list(Chunk* next) { next_in_owner_list_ = next; }
46 Chunk* next_in_owner_list() const { return next_in_owner_list_; } 46 Chunk* next_in_owner_list() const { return next_in_owner_list_; }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 Chunk bankrupcy_chunk_; 95 Chunk bankrupcy_chunk_;
96 std::unique_ptr<uint8_t[]> bankrupcy_chunk_storage_; 96 std::unique_ptr<uint8_t[]> bankrupcy_chunk_storage_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(TraceRingBuffer); 98 DISALLOW_COPY_AND_ASSIGN(TraceRingBuffer);
99 }; 99 };
100 100
101 } // namespace v2 101 } // namespace v2
102 } // namespace tracing 102 } // namespace tracing
103 103
104 #endif // COMPONENTS_TRACING_CORE_TRACE_RING_BUFFER_H_ 104 #endif // COMPONENTS_TRACING_CORE_TRACE_RING_BUFFER_H_
OLDNEW
« no previous file with comments | « components/tracing/core/trace_buffer_writer_unittest.cc ('k') | components/tracing/core/trace_ring_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698