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

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

Issue 2907543003: Support persistent system profiles. (Closed)
Patch Set: addressed review comments by asvitkine Created 3 years, 6 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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/metrics/persistent_memory_allocator.h" 5 #include "base/metrics/persistent_memory_allocator.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 : allocator_(allocator), last_record_(0), record_count_(0) { 155 : allocator_(allocator), last_record_(0), record_count_(0) {
156 Reset(starting_after); 156 Reset(starting_after);
157 } 157 }
158 158
159 void PersistentMemoryAllocator::Iterator::Reset() { 159 void PersistentMemoryAllocator::Iterator::Reset() {
160 last_record_.store(kReferenceQueue, std::memory_order_relaxed); 160 last_record_.store(kReferenceQueue, std::memory_order_relaxed);
161 record_count_.store(0, std::memory_order_relaxed); 161 record_count_.store(0, std::memory_order_relaxed);
162 } 162 }
163 163
164 void PersistentMemoryAllocator::Iterator::Reset(Reference starting_after) { 164 void PersistentMemoryAllocator::Iterator::Reset(Reference starting_after) {
165 if (starting_after == 0) {
166 Reset();
167 return;
168 }
169
165 last_record_.store(starting_after, std::memory_order_relaxed); 170 last_record_.store(starting_after, std::memory_order_relaxed);
166 record_count_.store(0, std::memory_order_relaxed); 171 record_count_.store(0, std::memory_order_relaxed);
167 172
168 // Ensure that the starting point is a valid, iterable block (meaning it can 173 // Ensure that the starting point is a valid, iterable block (meaning it can
169 // be read and has a non-zero "next" pointer). 174 // be read and has a non-zero "next" pointer).
170 const volatile BlockHeader* block = 175 const volatile BlockHeader* block =
171 allocator_->GetBlock(starting_after, 0, 0, false, false); 176 allocator_->GetBlock(starting_after, 0, 0, false, false);
172 if (!block || block->next.load(std::memory_order_relaxed) == 0) { 177 if (!block || block->next.load(std::memory_order_relaxed) == 0) {
173 NOTREACHED(); 178 NOTREACHED();
174 last_record_.store(kReferenceQueue, std::memory_order_release); 179 last_record_.store(kReferenceQueue, std::memory_order_release);
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 if (!mem) { 1168 if (!mem) {
1164 // This should never happen but be tolerant if it does as corruption from 1169 // This should never happen but be tolerant if it does as corruption from
1165 // the outside is something to guard against. 1170 // the outside is something to guard against.
1166 NOTREACHED(); 1171 NOTREACHED();
1167 return nullptr; 1172 return nullptr;
1168 } 1173 }
1169 return mem + offset_; 1174 return mem + offset_;
1170 } 1175 }
1171 1176
1172 } // namespace base 1177 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698