Index: base/trace_event/trace_event_unittest.cc |
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc |
index c98c698b6aafb89d70c428ab5b163e1b8907924e..91155ea1fe3456ef925b98dd98b32a22e36737d7 100644 |
--- a/base/trace_event/trace_event_unittest.cc |
+++ b/base/trace_event/trace_event_unittest.cc |
@@ -2,11 +2,14 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/trace_event/trace_event.h" |
+ |
#include <math.h> |
#include <stddef.h> |
#include <stdint.h> |
#include <cstdlib> |
+#include <memory> |
#include "base/bind.h" |
#include "base/command_line.h" |
@@ -15,7 +18,6 @@ |
#include "base/location.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted_memory.h" |
-#include "base/memory/scoped_ptr.h" |
#include "base/memory/singleton.h" |
#include "base/process/process_handle.h" |
#include "base/single_thread_task_runner.h" |
@@ -27,7 +29,6 @@ |
#include "base/threading/thread.h" |
#include "base/time/time.h" |
#include "base/trace_event/trace_buffer.h" |
-#include "base/trace_event/trace_event.h" |
#include "base/trace_event/trace_event_synthetic_delay.h" |
#include "base/values.h" |
#include "testing/gmock/include/gmock/gmock.h" |
@@ -183,7 +184,7 @@ void TraceEventTestFixture::OnTraceDataCollected( |
trace_buffer_.AddFragment(events_str->data()); |
trace_buffer_.Finish(); |
- scoped_ptr<Value> root = base::JSONReader::Read( |
+ std::unique_ptr<Value> root = base::JSONReader::Read( |
json_output_.json_output, JSON_PARSE_RFC | JSON_DETACHABLE_CHILDREN); |
if (!root.get()) { |
@@ -196,7 +197,7 @@ void TraceEventTestFixture::OnTraceDataCollected( |
// Move items into our aggregate collection |
while (root_list->GetSize()) { |
- scoped_ptr<Value> item; |
+ std::unique_ptr<Value> item; |
root_list->Remove(0, &item); |
trace_parsed_.Append(item.release()); |
} |
@@ -266,7 +267,7 @@ DictionaryValue* TraceEventTestFixture::FindMatchingTraceEntry( |
} |
void TraceEventTestFixture::DropTracedMetadataRecords() { |
- scoped_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy()); |
+ std::unique_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy()); |
size_t old_trace_parsed_size = old_trace_parsed->GetSize(); |
trace_parsed_.Clear(); |
@@ -1247,8 +1248,8 @@ TEST_F(TraceEventTestFixture, AddMetadataEvent) { |
int* num_calls_; |
}; |
- scoped_ptr<ConvertableToTraceFormat> conv1(new Convertable(&num_calls)); |
- scoped_ptr<Convertable> conv2(new Convertable(&num_calls)); |
+ std::unique_ptr<ConvertableToTraceFormat> conv1(new Convertable(&num_calls)); |
+ std::unique_ptr<Convertable> conv2(new Convertable(&num_calls)); |
BeginTrace(); |
TRACE_EVENT_API_ADD_METADATA_EVENT( |
@@ -2054,19 +2055,20 @@ TEST_F(TraceEventTestFixture, ConvertableTypes) { |
TraceLog::GetInstance()->SetEnabled(TraceConfig(kRecordAllCategoryFilter, ""), |
TraceLog::RECORDING_MODE); |
- scoped_ptr<ConvertableToTraceFormat> data(new MyData()); |
- scoped_ptr<ConvertableToTraceFormat> data1(new MyData()); |
- scoped_ptr<ConvertableToTraceFormat> data2(new MyData()); |
+ std::unique_ptr<ConvertableToTraceFormat> data(new MyData()); |
+ std::unique_ptr<ConvertableToTraceFormat> data1(new MyData()); |
+ std::unique_ptr<ConvertableToTraceFormat> data2(new MyData()); |
TRACE_EVENT1("foo", "bar", "data", std::move(data)); |
TRACE_EVENT2("foo", "baz", "data1", std::move(data1), "data2", |
std::move(data2)); |
- // Check that scoped_ptr<DerivedClassOfConvertable> are properly treated as |
+ // Check that std::unique_ptr<DerivedClassOfConvertable> are properly treated |
+ // as |
// convertable and not accidentally casted to bool. |
- scoped_ptr<MyData> convertData1(new MyData()); |
- scoped_ptr<MyData> convertData2(new MyData()); |
- scoped_ptr<MyData> convertData3(new MyData()); |
- scoped_ptr<MyData> convertData4(new MyData()); |
+ std::unique_ptr<MyData> convertData1(new MyData()); |
+ std::unique_ptr<MyData> convertData2(new MyData()); |
+ std::unique_ptr<MyData> convertData3(new MyData()); |
+ std::unique_ptr<MyData> convertData4(new MyData()); |
TRACE_EVENT2("foo", "string_first", "str", "string value 1", "convert", |
std::move(convertData1)); |
TRACE_EVENT2("foo", "string_second", "convert", std::move(convertData2), |
@@ -2686,7 +2688,8 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferGetReturnChunk) { |
size_t chunk_index; |
EXPECT_EQ(0u, buffer->Size()); |
- scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]); |
+ std::unique_ptr<TraceBufferChunk* []> chunks( |
+ new TraceBufferChunk*[num_chunks]); |
for (size_t i = 0; i < num_chunks; ++i) { |
chunks[i] = buffer->GetChunk(&chunk_index).release(); |
EXPECT_TRUE(chunks[i]); |
@@ -2702,7 +2705,7 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferGetReturnChunk) { |
// Return all chunks in original order. |
for (size_t i = 0; i < num_chunks; ++i) |
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i])); |
// Should recycle the chunks in the returned order. |
for (size_t i = 0; i < num_chunks; ++i) { |
@@ -2715,9 +2718,8 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferGetReturnChunk) { |
// Return all chunks in reverse order. |
for (size_t i = 0; i < num_chunks; ++i) { |
- buffer->ReturnChunk( |
- num_chunks - i - 1, |
- scoped_ptr<TraceBufferChunk>(chunks[num_chunks - i - 1])); |
+ buffer->ReturnChunk(num_chunks - i - 1, std::unique_ptr<TraceBufferChunk>( |
+ chunks[num_chunks - i - 1])); |
} |
// Should recycle the chunks in the returned order. |
@@ -2730,7 +2732,7 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferGetReturnChunk) { |
} |
for (size_t i = 0; i < num_chunks; ++i) |
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i])); |
TraceLog::GetInstance()->SetDisabled(); |
} |
@@ -2747,7 +2749,8 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferHalfIteration) { |
EXPECT_FALSE(buffer->NextChunk()); |
size_t half_chunks = num_chunks / 2; |
- scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[half_chunks]); |
+ std::unique_ptr<TraceBufferChunk* []> chunks( |
+ new TraceBufferChunk*[half_chunks]); |
for (size_t i = 0; i < half_chunks; ++i) { |
chunks[i] = buffer->GetChunk(&chunk_index).release(); |
@@ -2755,7 +2758,7 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferHalfIteration) { |
EXPECT_EQ(i, chunk_index); |
} |
for (size_t i = 0; i < half_chunks; ++i) |
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i])); |
for (size_t i = 0; i < half_chunks; ++i) |
EXPECT_EQ(chunks[i], buffer->NextChunk()); |
@@ -2774,7 +2777,8 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferFullIteration) { |
EXPECT_EQ(0u, buffer->Size()); |
EXPECT_FALSE(buffer->NextChunk()); |
- scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]); |
+ std::unique_ptr<TraceBufferChunk* []> chunks( |
+ new TraceBufferChunk*[num_chunks]); |
for (size_t i = 0; i < num_chunks; ++i) { |
chunks[i] = buffer->GetChunk(&chunk_index).release(); |
@@ -2782,7 +2786,7 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferFullIteration) { |
EXPECT_EQ(i, chunk_index); |
} |
for (size_t i = 0; i < num_chunks; ++i) |
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i])); |
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i])); |
for (size_t i = 0; i < num_chunks; ++i) |
EXPECT_TRUE(chunks[i] == buffer->NextChunk()); |