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

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: moved Create-Result histogram to private space and added to histograms.xml Created 4 years, 10 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 // Histogram containing creation results. Visible for testing.
20 BASE_EXPORT HistogramBase* GetCreateHistogramResultHistogram();
21
22 // Access a PersistentMemoryAllocator for storing histograms in space that
23 // can be persisted or shared between processes. There is only ever one
24 // allocator for all such histograms created by a single process though one
25 // process may access the histograms created by other processes if it has a
26 // handle on its memory segment. This takes ownership of the object and
27 // should not be changed without great care as it is likely that there will
28 // be pointers to data held in that space.
29 BASE_EXPORT void SetPersistentHistogramMemoryAllocator(
30 PersistentMemoryAllocator* allocator);
31 BASE_EXPORT PersistentMemoryAllocator* GetPersistentHistogramMemoryAllocator();
32
33 // This access to the persistent allocator is only for testing; it extracts
34 // the current allocator completely. This allows easy creation of histograms
35 // within persistent memory segments which can then be extracted and used
36 // in other ways.
37 BASE_EXPORT PersistentMemoryAllocator*
38 ReleasePersistentHistogramMemoryAllocator();
39
40 // Recreate a Histogram from data held in persistent memory. Though this
41 // object will be local to the current process, the sample data will be
42 // shared with all other threads referencing it. This method takes a |ref|
43 // to the top- level histogram data and the |allocator| on which it is found.
44 // This method will return nullptr if any problem is detected with the data.
45 // The |allocator| may or may not be the same as the PersistentMemoryAllocator
46 // set for general use so that this method can be used to extract Histograms
47 // from persistent memory segments other than the default place that this
48 // process is creating its own histograms. The caller must take ownership of
49 // the returned object and destroy it when no longer needed.
50 BASE_EXPORT HistogramBase* GetPersistentHistogram(
51 PersistentMemoryAllocator* allocator,
52 int32_t ref);
53
54 // Get the next histogram in persistent data based on iterator. The caller
55 // must take ownership of the returned object and destroy it when no longer
56 // needed.
57 BASE_EXPORT HistogramBase* GetNextPersistentHistogram(
58 PersistentMemoryAllocator* allocator,
59 PersistentMemoryAllocator::Iterator* iter);
60
61 // Finalize the creation of the histogram, making it available to other
62 // processes if it is the registered instance.
63 void FinalizePersistentHistogram(PersistentMemoryAllocator::Reference ref,
64 bool register);
65
66 // Allocate a new persistent histogram. This does *not* make the object
67 // iterable in the allocator; call MakeIterable(ref) directly if that is
68 // desired.
69 BASE_EXPORT HistogramBase* AllocatePersistentHistogram(
70 PersistentMemoryAllocator* allocator,
71 HistogramType histogram_type,
72 const std::string& name,
73 int minimum,
74 int maximum,
75 const BucketRanges* bucket_ranges,
76 int32_t flags,
77 PersistentMemoryAllocator::Reference* ref_ptr);
78
79 // Import new histograms from attached PersistentMemoryAllocator. It's
80 // possible for other processes to create histograms in the attached memory
81 // segment; this adds those to the internal list of known histograms to
82 // avoid creating duplicates that would have to merged during reporting.
83 // Every call to this method resumes from the last entry it saw so it costs
84 // nothing if nothing new has been added.
85 void ImportPersistentHistograms();
86
87 } // namespace base
88
89 #endif // BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram_delta_serialization_unittest.cc ('k') | base/metrics/histogram_persistence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698