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

Side by Side Diff: base/metrics/persistent_sample_map_unittest.cc

Issue 2258713003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/metrics/persistent_sample_map.h" 5 #include "base/metrics/persistent_sample_map.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/persistent_histogram_allocator.h" 10 #include "base/metrics/persistent_histogram_allocator.h"
11 #include "base/test/gtest_util.h" 11 #include "base/test/gtest_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace base { 14 namespace base {
15 namespace { 15 namespace {
16 16
17 std::unique_ptr<PersistentHistogramAllocator> CreateHistogramAllocator( 17 std::unique_ptr<PersistentHistogramAllocator> CreateHistogramAllocator(
18 size_t bytes) { 18 size_t bytes) {
19 return WrapUnique(new PersistentHistogramAllocator( 19 return MakeUnique<PersistentHistogramAllocator>(
20 WrapUnique(new LocalPersistentMemoryAllocator(bytes, 0, "")))); 20 MakeUnique<LocalPersistentMemoryAllocator>(bytes, 0, ""));
21 } 21 }
22 22
23 std::unique_ptr<PersistentHistogramAllocator> DuplicateHistogramAllocator( 23 std::unique_ptr<PersistentHistogramAllocator> DuplicateHistogramAllocator(
24 PersistentHistogramAllocator* original) { 24 PersistentHistogramAllocator* original) {
25 return WrapUnique( 25 return MakeUnique<PersistentHistogramAllocator>(
26 new PersistentHistogramAllocator(WrapUnique(new PersistentMemoryAllocator( 26 MakeUnique<PersistentMemoryAllocator>(
27 const_cast<void*>(original->data()), original->length(), 0, 27 const_cast<void*>(original->data()), original->length(), 0,
28 original->Id(), original->Name(), false)))); 28 original->Id(), original->Name(), false));
29 } 29 }
30 30
31 TEST(PersistentSampleMapTest, AccumulateTest) { 31 TEST(PersistentSampleMapTest, AccumulateTest) {
32 std::unique_ptr<PersistentHistogramAllocator> allocator = 32 std::unique_ptr<PersistentHistogramAllocator> allocator =
33 CreateHistogramAllocator(64 << 10); // 64 KiB 33 CreateHistogramAllocator(64 << 10); // 64 KiB
34 HistogramSamples::Metadata meta; 34 HistogramSamples::Metadata meta;
35 PersistentSampleMap samples(1, allocator.get(), &meta); 35 PersistentSampleMap samples(1, allocator.get(), &meta);
36 36
37 samples.Accumulate(1, 100); 37 samples.Accumulate(1, 100);
38 samples.Accumulate(2, 200); 38 samples.Accumulate(2, 200);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 EXPECT_DCHECK_DEATH(it->Next()); 252 EXPECT_DCHECK_DEATH(it->Next());
253 253
254 samples.Accumulate(1, 100); 254 samples.Accumulate(1, 100);
255 it = samples.Iterator(); 255 it = samples.Iterator();
256 EXPECT_FALSE(it->Done()); 256 EXPECT_FALSE(it->Done());
257 } 257 }
258 258
259 } // namespace 259 } // namespace
260 } // namespace base 260 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator_unittest.cc ('k') | base/task_scheduler/priority_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698