| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); | 42 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); |
| 43 | 43 |
| 44 // 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 |
| 45 // chunk_index and event_index fields in TraceEventHandle | 45 // chunk_index and event_index fields in TraceEventHandle |
| 46 // (in trace_event_impl.h). | 46 // (in trace_event_impl.h). |
| 47 static const size_t kMaxChunkIndex = (1u << 26) - 1; | 47 static const size_t kMaxChunkIndex = (1u << 26) - 1; |
| 48 static const size_t kTraceBufferChunkSize = 64; | 48 static const size_t kTraceBufferChunkSize = 64; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 size_t next_free_; | 51 size_t next_free_; |
| 52 scoped_ptr<TraceEventMemoryOverhead> cached_overhead_estimate_; | 52 std::unique_ptr<TraceEventMemoryOverhead> cached_overhead_estimate_; |
| 53 TraceEvent chunk_[kTraceBufferChunkSize]; | 53 TraceEvent chunk_[kTraceBufferChunkSize]; |
| 54 uint32_t seq_; | 54 uint32_t seq_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // TraceBuffer holds the events as they are collected. | 57 // TraceBuffer holds the events as they are collected. |
| 58 class BASE_EXPORT TraceBuffer { | 58 class BASE_EXPORT TraceBuffer { |
| 59 public: | 59 public: |
| 60 virtual ~TraceBuffer() {} | 60 virtual ~TraceBuffer() {} |
| 61 | 61 |
| 62 virtual scoped_ptr<TraceBufferChunk> GetChunk(size_t* index) = 0; | 62 virtual std::unique_ptr<TraceBufferChunk> GetChunk(size_t* index) = 0; |
| 63 virtual void ReturnChunk(size_t index, | 63 virtual void ReturnChunk(size_t index, |
| 64 scoped_ptr<TraceBufferChunk> chunk) = 0; | 64 std::unique_ptr<TraceBufferChunk> chunk) = 0; |
| 65 | 65 |
| 66 virtual bool IsFull() const = 0; | 66 virtual bool IsFull() const = 0; |
| 67 virtual size_t Size() const = 0; | 67 virtual size_t Size() const = 0; |
| 68 virtual size_t Capacity() const = 0; | 68 virtual size_t Capacity() const = 0; |
| 69 virtual TraceEvent* GetEventByHandle(TraceEventHandle handle) = 0; | 69 virtual TraceEvent* GetEventByHandle(TraceEventHandle handle) = 0; |
| 70 | 70 |
| 71 // For iteration. Each TraceBuffer can only be iterated once. | 71 // For iteration. Each TraceBuffer can only be iterated once. |
| 72 virtual const TraceBufferChunk* NextChunk() = 0; | 72 virtual const TraceBufferChunk* NextChunk() = 0; |
| 73 | 73 |
| 74 | 74 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 OutputCallback output_callback_; | 123 OutputCallback output_callback_; |
| 124 bool append_comma_; | 124 bool append_comma_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace trace_event | 127 } // namespace trace_event |
| 128 } // namespace base | 128 } // namespace base |
| 129 | 129 |
| 130 #endif // BASE_TRACE_EVENT_TRACE_BUFFER_H_ | 130 #endif // BASE_TRACE_EVENT_TRACE_BUFFER_H_ |
| OLD | NEW |