OLD | NEW |
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/metrics/persistent_histogram_allocator.h" | 5 #include "base/metrics/persistent_histogram_allocator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 } | 778 } |
779 if (out_active_path) { | 779 if (out_active_path) { |
780 *out_active_path = | 780 *out_active_path = |
781 dir.AppendASCII(name.as_string() + std::string("-active")) | 781 dir.AppendASCII(name.as_string() + std::string("-active")) |
782 .AddExtension(PersistentMemoryAllocator::kFileExtension); | 782 .AddExtension(PersistentMemoryAllocator::kFileExtension); |
783 } | 783 } |
784 } | 784 } |
785 #endif // !defined(OS_NACL) | 785 #endif // !defined(OS_NACL) |
786 | 786 |
787 // static | 787 // static |
788 void GlobalHistogramAllocator::CreateWithSharedMemory( | |
789 std::unique_ptr<SharedMemory> memory, | |
790 size_t size, | |
791 uint64_t id, | |
792 StringPiece name) { | |
793 if ((!memory->memory() && !memory->Map(size)) || | |
794 !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*memory)) { | |
795 NOTREACHED(); | |
796 return; | |
797 } | |
798 | |
799 DCHECK_LE(memory->mapped_size(), size); | |
800 Set(WrapUnique( | |
801 new GlobalHistogramAllocator(MakeUnique<SharedPersistentMemoryAllocator>( | |
802 std::move(memory), 0, StringPiece(), /*readonly=*/false)))); | |
803 } | |
804 | |
805 // static | |
806 void GlobalHistogramAllocator::CreateWithSharedMemoryHandle( | 788 void GlobalHistogramAllocator::CreateWithSharedMemoryHandle( |
807 const SharedMemoryHandle& handle, | 789 const SharedMemoryHandle& handle, |
808 size_t size) { | 790 size_t size) { |
809 std::unique_ptr<SharedMemory> shm( | 791 std::unique_ptr<SharedMemory> shm( |
810 new SharedMemory(handle, /*readonly=*/false)); | 792 new SharedMemory(handle, /*readonly=*/false)); |
811 if (!shm->Map(size) || | 793 if (!shm->Map(size) || |
812 !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*shm)) { | 794 !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*shm)) { |
813 NOTREACHED(); | 795 NOTREACHED(); |
814 return; | 796 return; |
815 } | 797 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 while (true) { | 926 while (true) { |
945 std::unique_ptr<HistogramBase> histogram = | 927 std::unique_ptr<HistogramBase> histogram = |
946 import_iterator_.GetNextWithIgnore(record_to_ignore); | 928 import_iterator_.GetNextWithIgnore(record_to_ignore); |
947 if (!histogram) | 929 if (!histogram) |
948 break; | 930 break; |
949 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); | 931 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); |
950 } | 932 } |
951 } | 933 } |
952 | 934 |
953 } // namespace base | 935 } // namespace base |
OLD | NEW |