OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BASE_TRACE_EVENT_TRACE_BUFFER_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACE_BUFFER_H_ |
6 #define BASE_TRACE_EVENT_TRACE_BUFFER_H_ | 6 #define BASE_TRACE_EVENT_TRACE_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 TraceEvent* GetEventAt(size_t index) { | 33 TraceEvent* GetEventAt(size_t index) { |
34 DCHECK(index < size()); | 34 DCHECK(index < size()); |
35 return &chunk_[index]; | 35 return &chunk_[index]; |
36 } | 36 } |
37 const TraceEvent* GetEventAt(size_t index) const { | 37 const TraceEvent* GetEventAt(size_t index) const { |
38 DCHECK(index < size()); | 38 DCHECK(index < size()); |
39 return &chunk_[index]; | 39 return &chunk_[index]; |
40 } | 40 } |
41 | 41 |
42 scoped_ptr<TraceBufferChunk> Clone() const; | |
43 | |
44 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); | 42 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); |
45 | 43 |
46 // These values must be kept consistent with the numbers of bits of | 44 // These values must be kept consistent with the numbers of bits of |
47 // chunk_index and event_index fields in TraceEventHandle | 45 // chunk_index and event_index fields in TraceEventHandle |
48 // (in trace_event_impl.h). | 46 // (in trace_event_impl.h). |
49 static const size_t kMaxChunkIndex = (1u << 26) - 1; | 47 static const size_t kMaxChunkIndex = (1u << 26) - 1; |
50 static const size_t kTraceBufferChunkSize = 64; | 48 static const size_t kTraceBufferChunkSize = 64; |
51 | 49 |
52 private: | 50 private: |
53 size_t next_free_; | 51 size_t next_free_; |
(...skipping 12 matching lines...) Expand all Loading... |
66 scoped_ptr<TraceBufferChunk> chunk) = 0; | 64 scoped_ptr<TraceBufferChunk> chunk) = 0; |
67 | 65 |
68 virtual bool IsFull() const = 0; | 66 virtual bool IsFull() const = 0; |
69 virtual size_t Size() const = 0; | 67 virtual size_t Size() const = 0; |
70 virtual size_t Capacity() const = 0; | 68 virtual size_t Capacity() const = 0; |
71 virtual TraceEvent* GetEventByHandle(TraceEventHandle handle) = 0; | 69 virtual TraceEvent* GetEventByHandle(TraceEventHandle handle) = 0; |
72 | 70 |
73 // For iteration. Each TraceBuffer can only be iterated once. | 71 // For iteration. Each TraceBuffer can only be iterated once. |
74 virtual const TraceBufferChunk* NextChunk() = 0; | 72 virtual const TraceBufferChunk* NextChunk() = 0; |
75 | 73 |
76 virtual scoped_ptr<TraceBuffer> CloneForIteration() const = 0; | |
77 | 74 |
78 // Computes an estimate of the size of the buffer, including all the retained | 75 // Computes an estimate of the size of the buffer, including all the retained |
79 // objects. | 76 // objects. |
80 virtual void EstimateTraceMemoryOverhead( | 77 virtual void EstimateTraceMemoryOverhead( |
81 TraceEventMemoryOverhead* overhead) = 0; | 78 TraceEventMemoryOverhead* overhead) = 0; |
82 | 79 |
83 static TraceBuffer* CreateTraceBufferRingBuffer(size_t max_chunks); | 80 static TraceBuffer* CreateTraceBufferRingBuffer(size_t max_chunks); |
84 static TraceBuffer* CreateTraceBufferVectorOfSize(size_t max_chunks); | 81 static TraceBuffer* CreateTraceBufferVectorOfSize(size_t max_chunks); |
85 }; | 82 }; |
86 | 83 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 121 |
125 private: | 122 private: |
126 OutputCallback output_callback_; | 123 OutputCallback output_callback_; |
127 bool append_comma_; | 124 bool append_comma_; |
128 }; | 125 }; |
129 | 126 |
130 } // namespace trace_event | 127 } // namespace trace_event |
131 } // namespace base | 128 } // namespace base |
132 | 129 |
133 #endif // BASE_TRACE_EVENT_TRACE_BUFFER_H_ | 130 #endif // BASE_TRACE_EVENT_TRACE_BUFFER_H_ |
OLD | NEW |