| OLD | NEW |
| 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 | 9 |
| 10 #include <atomic> | 10 #include <atomic> |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // save the contents to persistent storage during process shutdown. It is | 347 // save the contents to persistent storage during process shutdown. It is |
| 348 // also useful for testing. | 348 // also useful for testing. |
| 349 class BASE_EXPORT LocalPersistentMemoryAllocator | 349 class BASE_EXPORT LocalPersistentMemoryAllocator |
| 350 : public PersistentMemoryAllocator { | 350 : public PersistentMemoryAllocator { |
| 351 public: | 351 public: |
| 352 LocalPersistentMemoryAllocator(size_t size, uint64_t id, | 352 LocalPersistentMemoryAllocator(size_t size, uint64_t id, |
| 353 base::StringPiece name); | 353 base::StringPiece name); |
| 354 ~LocalPersistentMemoryAllocator() override; | 354 ~LocalPersistentMemoryAllocator() override; |
| 355 | 355 |
| 356 private: | 356 private: |
| 357 // Allocates a block of local memory of the specified |size|, ensuring that |
| 358 // the memory will not be physically allocated until accessed and will read |
| 359 // as zero when that happens. |
| 360 static void* AllocateLocalMemory(size_t size); |
| 361 |
| 362 // Deallocates a block of local |memory| of the specified |size|. |
| 363 static void DeallocateLocalMemory(void* memory, size_t size); |
| 364 |
| 357 DISALLOW_COPY_AND_ASSIGN(LocalPersistentMemoryAllocator); | 365 DISALLOW_COPY_AND_ASSIGN(LocalPersistentMemoryAllocator); |
| 358 }; | 366 }; |
| 359 | 367 |
| 360 | 368 |
| 361 // This allocator takes a shared-memory object and performs allocation from | 369 // This allocator takes a shared-memory object and performs allocation from |
| 362 // it. The memory must be previously mapped via Map() or MapAt(). The allocator | 370 // it. The memory must be previously mapped via Map() or MapAt(). The allocator |
| 363 // takes ownership of the memory object. | 371 // takes ownership of the memory object. |
| 364 class BASE_EXPORT SharedPersistentMemoryAllocator | 372 class BASE_EXPORT SharedPersistentMemoryAllocator |
| 365 : public PersistentMemoryAllocator { | 373 : public PersistentMemoryAllocator { |
| 366 public: | 374 public: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 416 |
| 409 private: | 417 private: |
| 410 std::unique_ptr<MemoryMappedFile> mapped_file_; | 418 std::unique_ptr<MemoryMappedFile> mapped_file_; |
| 411 | 419 |
| 412 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); | 420 DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator); |
| 413 }; | 421 }; |
| 414 | 422 |
| 415 } // namespace base | 423 } // namespace base |
| 416 | 424 |
| 417 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ | 425 #endif // BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_ |
| OLD | NEW |