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

Side by Side Diff: base/trace_event/trace_buffer.cc

Issue 1546033002: Switch to standard integer types in base/trace_event/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 | « base/trace_event/trace_buffer.h ('k') | base/trace_event/trace_config.h » ('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 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 #include "base/trace_event/trace_buffer.h" 5 #include "base/trace_event/trace_buffer.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/trace_event/trace_event_impl.h" 12 #include "base/trace_event/trace_event_impl.h"
12 13
13 namespace base { 14 namespace base {
14 namespace trace_event { 15 namespace trace_event {
15 16
16 namespace { 17 namespace {
17 18
18 class TraceBufferRingBuffer : public TraceBuffer { 19 class TraceBufferRingBuffer : public TraceBuffer {
19 public: 20 public:
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 185 }
185 186
186 size_t max_chunks_; 187 size_t max_chunks_;
187 std::vector<scoped_ptr<TraceBufferChunk>> chunks_; 188 std::vector<scoped_ptr<TraceBufferChunk>> chunks_;
188 189
189 scoped_ptr<size_t[]> recyclable_chunks_queue_; 190 scoped_ptr<size_t[]> recyclable_chunks_queue_;
190 size_t queue_head_; 191 size_t queue_head_;
191 size_t queue_tail_; 192 size_t queue_tail_;
192 193
193 size_t current_iteration_index_; 194 size_t current_iteration_index_;
194 uint32 current_chunk_seq_; 195 uint32_t current_chunk_seq_;
195 196
196 DISALLOW_COPY_AND_ASSIGN(TraceBufferRingBuffer); 197 DISALLOW_COPY_AND_ASSIGN(TraceBufferRingBuffer);
197 }; 198 };
198 199
199 class TraceBufferVector : public TraceBuffer { 200 class TraceBufferVector : public TraceBuffer {
200 public: 201 public:
201 TraceBufferVector(size_t max_chunks) 202 TraceBufferVector(size_t max_chunks)
202 : in_flight_chunk_count_(0), 203 : in_flight_chunk_count_(0),
203 current_iteration_index_(0), 204 current_iteration_index_(0),
204 max_chunks_(max_chunks) { 205 max_chunks_(max_chunks) {
205 chunks_.reserve(max_chunks_); 206 chunks_.reserve(max_chunks_);
206 } 207 }
207 208
208 scoped_ptr<TraceBufferChunk> GetChunk(size_t* index) override { 209 scoped_ptr<TraceBufferChunk> GetChunk(size_t* index) override {
209 // This function may be called when adding normal events or indirectly from 210 // This function may be called when adding normal events or indirectly from
210 // AddMetadataEventsWhileLocked(). We can not DECHECK(!IsFull()) because we 211 // AddMetadataEventsWhileLocked(). We can not DECHECK(!IsFull()) because we
211 // have to add the metadata events and flush thread-local buffers even if 212 // have to add the metadata events and flush thread-local buffers even if
212 // the buffer is full. 213 // the buffer is full.
213 *index = chunks_.size(); 214 *index = chunks_.size();
214 chunks_.push_back(NULL); // Put NULL in the slot of a in-flight chunk. 215 chunks_.push_back(NULL); // Put NULL in the slot of a in-flight chunk.
215 ++in_flight_chunk_count_; 216 ++in_flight_chunk_count_;
216 // + 1 because zero chunk_seq is not allowed. 217 // + 1 because zero chunk_seq is not allowed.
217 return scoped_ptr<TraceBufferChunk>( 218 return scoped_ptr<TraceBufferChunk>(
218 new TraceBufferChunk(static_cast<uint32>(*index) + 1)); 219 new TraceBufferChunk(static_cast<uint32_t>(*index) + 1));
219 } 220 }
220 221
221 void ReturnChunk(size_t index, scoped_ptr<TraceBufferChunk> chunk) override { 222 void ReturnChunk(size_t index, scoped_ptr<TraceBufferChunk> chunk) override {
222 DCHECK_GT(in_flight_chunk_count_, 0u); 223 DCHECK_GT(in_flight_chunk_count_, 0u);
223 DCHECK_LT(index, chunks_.size()); 224 DCHECK_LT(index, chunks_.size());
224 DCHECK(!chunks_[index]); 225 DCHECK(!chunks_[index]);
225 --in_flight_chunk_count_; 226 --in_flight_chunk_count_;
226 chunks_[index] = chunk.release(); 227 chunks_[index] = chunk.release();
227 } 228 }
228 229
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 size_t in_flight_chunk_count_; 283 size_t in_flight_chunk_count_;
283 size_t current_iteration_index_; 284 size_t current_iteration_index_;
284 size_t max_chunks_; 285 size_t max_chunks_;
285 ScopedVector<TraceBufferChunk> chunks_; 286 ScopedVector<TraceBufferChunk> chunks_;
286 287
287 DISALLOW_COPY_AND_ASSIGN(TraceBufferVector); 288 DISALLOW_COPY_AND_ASSIGN(TraceBufferVector);
288 }; 289 };
289 290
290 } // namespace 291 } // namespace
291 292
292 TraceBufferChunk::TraceBufferChunk(uint32 seq) : next_free_(0), seq_(seq) {} 293 TraceBufferChunk::TraceBufferChunk(uint32_t seq) : next_free_(0), seq_(seq) {}
293 294
294 TraceBufferChunk::~TraceBufferChunk() {} 295 TraceBufferChunk::~TraceBufferChunk() {}
295 296
296 void TraceBufferChunk::Reset(uint32 new_seq) { 297 void TraceBufferChunk::Reset(uint32_t new_seq) {
297 for (size_t i = 0; i < next_free_; ++i) 298 for (size_t i = 0; i < next_free_; ++i)
298 chunk_[i].Reset(); 299 chunk_[i].Reset();
299 next_free_ = 0; 300 next_free_ = 0;
300 seq_ = new_seq; 301 seq_ = new_seq;
301 cached_overhead_estimate_.reset(); 302 cached_overhead_estimate_.reset();
302 } 303 }
303 304
304 TraceEvent* TraceBufferChunk::AddTraceEvent(size_t* event_index) { 305 TraceEvent* TraceBufferChunk::AddTraceEvent(size_t* event_index) {
305 DCHECK(!IsFull()); 306 DCHECK(!IsFull());
306 *event_index = next_free_++; 307 *event_index = next_free_++;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 TraceBuffer* TraceBuffer::CreateTraceBufferRingBuffer(size_t max_chunks) { 391 TraceBuffer* TraceBuffer::CreateTraceBufferRingBuffer(size_t max_chunks) {
391 return new TraceBufferRingBuffer(max_chunks); 392 return new TraceBufferRingBuffer(max_chunks);
392 } 393 }
393 394
394 TraceBuffer* TraceBuffer::CreateTraceBufferVectorOfSize(size_t max_chunks) { 395 TraceBuffer* TraceBuffer::CreateTraceBufferVectorOfSize(size_t max_chunks) {
395 return new TraceBufferVector(max_chunks); 396 return new TraceBufferVector(max_chunks);
396 } 397 }
397 398
398 } // namespace trace_event 399 } // namespace trace_event
399 } // namespace base 400 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_buffer.h ('k') | base/trace_event/trace_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698