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

Side by Side Diff: base/debug/activity_analyzer.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
« no previous file with comments | « base/containers/mru_cache_unittest.cc ('k') | base/debug/activity_analyzer_unittest.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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/debug/activity_analyzer.h" 5 #include "base/debug/activity_analyzer.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/memory_mapped_file.h" 9 #include "base/files/memory_mapped_file.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Map the file read-write so it can guarantee consistency between 45 // Map the file read-write so it can guarantee consistency between
46 // the analyzer and any trackers that my still be active. 46 // the analyzer and any trackers that my still be active.
47 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); 47 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile());
48 mmfile->Initialize(file_path, MemoryMappedFile::READ_WRITE); 48 mmfile->Initialize(file_path, MemoryMappedFile::READ_WRITE);
49 if (!mmfile->IsValid()) 49 if (!mmfile->IsValid())
50 return nullptr; 50 return nullptr;
51 51
52 if (!FilePersistentMemoryAllocator::IsFileAcceptable(*mmfile, true)) 52 if (!FilePersistentMemoryAllocator::IsFileAcceptable(*mmfile, true))
53 return nullptr; 53 return nullptr;
54 54
55 return WrapUnique(new GlobalActivityAnalyzer( 55 return WrapUnique(
56 WrapUnique(new FilePersistentMemoryAllocator( 56 new GlobalActivityAnalyzer(MakeUnique<FilePersistentMemoryAllocator>(
57 std::move(mmfile), 0, 0, base::StringPiece(), 57 std::move(mmfile), 0, 0, base::StringPiece(), true)));
58 true))));
59 } 58 }
60 #endif // !defined(OS_NACL) 59 #endif // !defined(OS_NACL)
61 60
62 ThreadActivityAnalyzer* GlobalActivityAnalyzer::GetFirstAnalyzer() { 61 ThreadActivityAnalyzer* GlobalActivityAnalyzer::GetFirstAnalyzer() {
63 PrepareAllAnalyzers(); 62 PrepareAllAnalyzers();
64 analyzers_iterator_ = analyzers_.begin(); 63 analyzers_iterator_ = analyzers_.begin();
65 if (analyzers_iterator_ == analyzers_.end()) 64 if (analyzers_iterator_ == analyzers_.end())
66 return nullptr; 65 return nullptr;
67 return analyzers_iterator_->second.get(); 66 return analyzers_iterator_->second.get();
68 } 67 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Add this analyzer to the map of known ones, indexed by a unique thread 119 // Add this analyzer to the map of known ones, indexed by a unique thread
121 // identifier. 120 // identifier.
122 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); 121 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey()));
123 analyzer->allocator_reference_ = ref; 122 analyzer->allocator_reference_ = ref;
124 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); 123 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer);
125 } 124 }
126 } 125 }
127 126
128 } // namespace debug 127 } // namespace debug
129 } // namespace base 128 } // namespace base
OLDNEW
« no previous file with comments | « base/containers/mru_cache_unittest.cc ('k') | base/debug/activity_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698