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

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

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: fixed compile problems on non-Windows builds 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
6 #define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
7
8 #include "base/base_export.h"
9 #include "base/feature_list.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/histogram_base.h"
12 #include "base/metrics/persistent_memory_allocator.h"
13
14 namespace base {
15
16 // Feature definition for enabling histogram persistence.
17 BASE_EXPORT extern const Feature kPersistentHistogramsFeature;
18
19 // Access a PersistentMemoryAllocator for storing histograms in space that
20 // can be persisted or shared between processes. There is only ever one
21 // allocator for all such histograms created by a single process though one
22 // process may access the histograms created by other processes if it has a
23 // handle on its memory segment. This takes ownership of the object and
24 // should not be changed without great care as it is likely that there will
25 // be pointers to data held in that space.
26 BASE_EXPORT void SetPersistentHistogramMemoryAllocator(
27 PersistentMemoryAllocator* allocator);
28 BASE_EXPORT PersistentMemoryAllocator* GetPersistentHistogramMemoryAllocator();
29
30 // This access to the persistent allocator is only for testing; it extracts
31 // the current allocator completely. This allows easy creation of histograms
32 // within persistent memory segments which can then be extracted and used
33 // in other ways.
34 BASE_EXPORT PersistentMemoryAllocator*
35 ReleasePersistentHistogramMemoryAllocator();
36
37 // Recreate a Histogram from data held in persistent memory. Though this
38 // object will be local to the current process, the sample data will be
39 // shared with all other threads referencing it. This method takes a |ref|
40 // to the top- level histogram data and the |allocator| on which it is found.
41 // This method will return nullptr if any problem is detected with the data.
42 // The |allocator| may or may not be the same as the PersistentMemoryAllocator
43 // set for general use so that this method can be used to extract Histograms
44 // from persistent memory segments other than the default place that this
45 // process is creating its own histograms. The caller must take ownership of
46 // the returned object and destroy it when no longer needed.
47 BASE_EXPORT HistogramBase* GetPersistentHistogram(
48 PersistentMemoryAllocator* allocator,
49 int32_t ref);
50
51 // Get the next histogram in persistent data based on iterator. The caller
52 // must take ownership of the returned object and destroy it when no longer
53 // needed.
54 BASE_EXPORT HistogramBase* GetNextPersistentHistogram(
55 PersistentMemoryAllocator* allocator,
56 PersistentMemoryAllocator::Iterator* iter);
57
58 // Finalize the creation of the histogram, making it available to other
59 // processes if it is the registered instance.
60 void FinalizePersistentHistogram(PersistentMemoryAllocator::Reference ref,
61 bool register);
62
63 // Allocate a new persistent histogram. This does *not* make the object
64 // iterable in the allocator; call MakeIterable(ref) directly if that is
65 // desired.
66 BASE_EXPORT HistogramBase* AllocatePersistentHistogram(
67 PersistentMemoryAllocator* allocator,
68 HistogramType histogram_type,
69 const std::string& name,
70 int minimum,
71 int maximum,
72 const BucketRanges* bucket_ranges,
73 int32_t flags,
74 PersistentMemoryAllocator::Reference* ref_ptr);
75
76 // Import new histograms from attached PersistentMemoryAllocator. It's
77 // possible for other processes to create histograms in the attached memory
78 // segment; this adds those to the internal list of known histograms to
79 // avoid creating duplicates that would have to merged during reporting.
80 // Every call to this method resumes from the last entry it saw so it costs
81 // nothing if nothing new has been added.
82 void ImportPersistentHistograms();
83
84 } // namespace base
85
86 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698