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

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

Issue 1619983004: Restrict volatile section of block header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | base/metrics/persistent_memory_allocator.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 (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 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ 5 #ifndef BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ 6 #define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <atomic> 9 #include <atomic>
10 #include <string> 10 #include <string>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 private: 242 private:
243 struct SharedMetadata; 243 struct SharedMetadata;
244 struct BlockHeader; 244 struct BlockHeader;
245 static const uint32_t kAllocAlignment; 245 static const uint32_t kAllocAlignment;
246 static const Reference kReferenceQueue; 246 static const Reference kReferenceQueue;
247 static const Reference kReferenceNull; 247 static const Reference kReferenceNull;
248 248
249 // The shared metadata is always located at the top of the memory segment. 249 // The shared metadata is always located at the top of the memory segment.
250 // These convenience functions eliminate constant casting of the base 250 // These convenience functions eliminate constant casting of the base
251 // pointer within the code. 251 // pointer within the code.
252 const volatile SharedMetadata* shared_meta() const { 252 const SharedMetadata* shared_meta() const {
253 return reinterpret_cast<const volatile SharedMetadata*>(mem_base_); 253 return reinterpret_cast<const SharedMetadata*>(
254 const_cast<const char*>(mem_base_));
Alexei Svitkine (slow) 2016/02/05 19:31:32 I don't understand why there's a const_cast here?
254 } 255 }
255 volatile SharedMetadata* shared_meta() { 256 SharedMetadata* shared_meta() {
256 return reinterpret_cast<volatile SharedMetadata*>(mem_base_); 257 return reinterpret_cast<SharedMetadata*>(const_cast<char*>(mem_base_));
257 } 258 }
258 259
259 // Actual method for doing the allocation. 260 // Actual method for doing the allocation.
260 Reference AllocateImpl(size_t size, uint32_t type_id); 261 Reference AllocateImpl(size_t size, uint32_t type_id);
261 262
262 // Get the block header associated with a specific reference. 263 // Get the block header associated with a specific reference.
263 const volatile BlockHeader* GetBlock(Reference ref, uint32_t type_id, 264 const volatile BlockHeader* GetBlock(Reference ref, uint32_t type_id,
264 uint32_t size, bool queue_ok, 265 uint32_t size, bool queue_ok,
265 bool free_ok) const; 266 bool free_ok) const;
266 volatile BlockHeader* GetBlock(Reference ref, uint32_t type_id, uint32_t size, 267 volatile BlockHeader* GetBlock(Reference ref, uint32_t type_id, uint32_t size,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // the rest. 325 // the rest.
325 static bool IsFileAcceptable(const MemoryMappedFile& file); 326 static bool IsFileAcceptable(const MemoryMappedFile& file);
326 327
327 private: 328 private:
328 scoped_ptr<MemoryMappedFile> mapped_file_; 329 scoped_ptr<MemoryMappedFile> mapped_file_;
329 }; 330 };
330 331
331 } // namespace base 332 } // namespace base
332 333
333 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ 334 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | base/metrics/persistent_memory_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698