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

Unified Diff: base/trace_event/trace_buffer.cc

Issue 1459143002: Remove ScopedVector from trace_buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_buffer.cc
diff --git a/base/trace_event/trace_buffer.cc b/base/trace_event/trace_buffer.cc
index eb7caa5a4a43dd5ebfb323e74277e7f39c156725..5d8a9bfa15bdcdb9d0a760c6647aa584b1e976aa 100644
--- a/base/trace_event/trace_buffer.cc
+++ b/base/trace_event/trace_buffer.cc
@@ -5,8 +5,9 @@
#include "base/trace_event/trace_buffer.h"
#include <utility>
+#include <vector>
-#include "base/memory/scoped_vector.h"
+#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event_impl.h"
namespace base {
@@ -40,7 +41,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
if (*index >= chunks_.size())
chunks_.resize(*index + 1);
- TraceBufferChunk* chunk = chunks_[*index];
+ TraceBufferChunk* chunk = chunks_[*index].release();
chunks_[*index] = NULL; // Put NULL in the slot of a in-flight chunk.
if (chunk)
chunk->Reset(current_chunk_seq_++);
@@ -57,7 +58,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
DCHECK(chunk);
DCHECK_LT(index, chunks_.size());
DCHECK(!chunks_[index]);
- chunks_[index] = chunk.release();
+ chunks_[index] = std::move(chunk);
recyclable_chunks_queue_[queue_tail_] = index;
queue_tail_ = NextQueueIndex(queue_tail_);
}
@@ -76,7 +77,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
TraceEvent* GetEventByHandle(TraceEventHandle handle) override {
if (handle.chunk_index >= chunks_.size())
return NULL;
- TraceBufferChunk* chunk = chunks_[handle.chunk_index];
+ TraceBufferChunk* chunk = chunks_[handle.chunk_index].get();
if (!chunk || chunk->seq() != handle.chunk_seq)
return NULL;
return chunk->GetEventAt(handle.event_index);
@@ -92,7 +93,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
if (chunk_index >= chunks_.size()) // Skip uninitialized chunks.
continue;
DCHECK(chunks_[chunk_index]);
- return chunks_[chunk_index];
+ return chunks_[chunk_index].get();
}
return NULL;
}
@@ -104,8 +105,8 @@ class TraceBufferRingBuffer : public TraceBuffer {
size_t chunk_index = recyclable_chunks_queue_[queue_index];
if (chunk_index >= chunks_.size()) // Skip uninitialized chunks.
continue;
- TraceBufferChunk* chunk = chunks_[chunk_index];
- cloned_buffer->chunks_.push_back(chunk ? chunk->Clone().release() : NULL);
+ TraceBufferChunk* chunk = chunks_[chunk_index].get();
+ cloned_buffer->chunks_.push_back(chunk ? chunk->Clone() : NULL);
}
return std::move(cloned_buffer);
}
@@ -130,7 +131,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
// The only implemented method.
const TraceBufferChunk* NextChunk() override {
return current_iteration_index_ < chunks_.size()
- ? chunks_[current_iteration_index_++]
+ ? chunks_[current_iteration_index_++].get()
: NULL;
}
@@ -157,7 +158,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
}
size_t current_iteration_index_;
- ScopedVector<TraceBufferChunk> chunks_;
+ std::vector<scoped_ptr<TraceBufferChunk>> chunks_;
};
bool QueueIsEmpty() const { return queue_head_ == queue_tail_; }
@@ -183,7 +184,7 @@ class TraceBufferRingBuffer : public TraceBuffer {
}
size_t max_chunks_;
- ScopedVector<TraceBufferChunk> chunks_;
+ std::vector<scoped_ptr<TraceBufferChunk>> chunks_;
scoped_ptr<size_t[]> recyclable_chunks_queue_;
size_t queue_head_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698