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

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

Issue 2578323002: Improved support for objects inside persistent memory. (Closed)
Patch Set: addressed review comments by asvitkine Created 3 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 | « base/metrics/field_trial.cc ('k') | base/metrics/persistent_histogram_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 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 #ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ 6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // given |id|. Only one |user| of this data is allowed at a time. This does 49 // given |id|. Only one |user| of this data is allowed at a time. This does
50 // an automatic Acquire() on the records. The user must call Release() on 50 // an automatic Acquire() on the records. The user must call Release() on
51 // the returned object when it is finished with it. Ownership of the records 51 // the returned object when it is finished with it. Ownership of the records
52 // object stays with this manager. 52 // object stays with this manager.
53 PersistentSampleMapRecords* UseSampleMapRecords(uint64_t id, 53 PersistentSampleMapRecords* UseSampleMapRecords(uint64_t id,
54 const void* user); 54 const void* user);
55 55
56 // Convenience method that gets the object for a given reference so callers 56 // Convenience method that gets the object for a given reference so callers
57 // don't have to also keep their own pointer to the appropriate allocator. 57 // don't have to also keep their own pointer to the appropriate allocator.
58 template <typename T> 58 template <typename T>
59 T* GetAsObject(PersistentMemoryAllocator::Reference ref, uint32_t type_id) { 59 T* GetAsObject(PersistentMemoryAllocator::Reference ref) {
60 return allocator_->GetAsObject<T>(ref, type_id); 60 return allocator_->GetAsObject<T>(ref);
61 } 61 }
62 62
63 private: 63 private:
64 friend class PersistentSampleMapRecords; 64 friend class PersistentSampleMapRecords;
65 65
66 // Gets the object holding records for a given sample-map id when |lock_| 66 // Gets the object holding records for a given sample-map id when |lock_|
67 // has already been acquired. 67 // has already been acquired.
68 PersistentSampleMapRecords* GetSampleMapRecordsWhileLocked(uint64_t id); 68 PersistentSampleMapRecords* GetSampleMapRecordsWhileLocked(uint64_t id);
69 69
70 // Loads sample-map records looking for those belonging to the specified 70 // Loads sample-map records looking for those belonging to the specified
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // a reference to it. 124 // a reference to it.
125 PersistentMemoryAllocator::Reference CreateNew(HistogramBase::Sample value); 125 PersistentMemoryAllocator::Reference CreateNew(HistogramBase::Sample value);
126 126
127 // Convenience method that gets the object for a given reference so callers 127 // Convenience method that gets the object for a given reference so callers
128 // don't have to also keep their own pointer to the appropriate allocator. 128 // don't have to also keep their own pointer to the appropriate allocator.
129 // This is expected to be used with the SampleRecord structure defined inside 129 // This is expected to be used with the SampleRecord structure defined inside
130 // the persistent_sample_map.cc file but since that isn't exported (for 130 // the persistent_sample_map.cc file but since that isn't exported (for
131 // cleanliness of the interface), a template is defined that will be 131 // cleanliness of the interface), a template is defined that will be
132 // resolved when used inside that file. 132 // resolved when used inside that file.
133 template <typename T> 133 template <typename T>
134 T* GetAsObject(PersistentMemoryAllocator::Reference ref, uint32_t type_id) { 134 T* GetAsObject(PersistentMemoryAllocator::Reference ref) {
135 return data_manager_->GetAsObject<T>(ref, type_id); 135 return data_manager_->GetAsObject<T>(ref);
136 } 136 }
137 137
138 private: 138 private:
139 friend PersistentSparseHistogramDataManager; 139 friend PersistentSparseHistogramDataManager;
140 140
141 // Weak-pointer to the parent data-manager object. 141 // Weak-pointer to the parent data-manager object.
142 PersistentSparseHistogramDataManager* data_manager_; 142 PersistentSparseHistogramDataManager* data_manager_;
143 143
144 // ID of PersistentSampleMap to which these records apply. 144 // ID of PersistentSampleMap to which these records apply.
145 const uint64_t sample_map_id_; 145 const uint64_t sample_map_id_;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 // The location to which the data should be persisted. 505 // The location to which the data should be persisted.
506 FilePath persistent_location_; 506 FilePath persistent_location_;
507 507
508 DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator); 508 DISALLOW_COPY_AND_ASSIGN(GlobalHistogramAllocator);
509 }; 509 };
510 510
511 } // namespace base 511 } // namespace base
512 512
513 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_ 513 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
OLDNEW
« no previous file with comments | « base/metrics/field_trial.cc ('k') | base/metrics/persistent_histogram_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698