| Index: base/metrics/histogram_base.h
|
| diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h
|
| index 45e5126849b430bc00486105d6eed456fd88179b..d270d38360f638c59607535d555148f9bd4ecf11 100644
|
| --- a/base/metrics/histogram_base.h
|
| +++ b/base/metrics/histogram_base.h
|
| @@ -133,10 +133,12 @@ class BASE_EXPORT HistogramBase {
|
| NEVER_EXCEEDED_VALUE = 0x10,
|
| };
|
|
|
| - explicit HistogramBase(const std::string& name);
|
| + // Construct the base histogram. The name is not copied; it's up to the
|
| + // caller to ensure that it lives at least as long as this object.
|
| + explicit HistogramBase(const char* name);
|
| virtual ~HistogramBase();
|
|
|
| - const std::string& histogram_name() const { return histogram_name_; }
|
| + const char* histogram_name() const { return histogram_name_; }
|
|
|
| // Comapres |name| to the histogram name and triggers a DCHECK if they do not
|
| // match. This is a helper function used by histogram macros, which results in
|
| @@ -261,6 +263,10 @@ class BASE_EXPORT HistogramBase {
|
| // passing |sample| as the parameter.
|
| void FindAndRunCallback(Sample sample) const;
|
|
|
| + // Gets a permanent string that can be used for histogram objects when the
|
| + // original is not a code constant or held in persistent memory.
|
| + static const char* GetPermanentName(const std::string& name);
|
| +
|
| // Update report with an |activity| that occurred for |histogram|.
|
| static void ReportHistogramActivity(const HistogramBase& histogram,
|
| ReportActivity activicty);
|
| @@ -271,7 +277,14 @@ class BASE_EXPORT HistogramBase {
|
| private:
|
| friend class HistogramBaseTest;
|
|
|
| - const std::string histogram_name_;
|
| + // A pointer to permanent storage where the histogram name is held. This can
|
| + // be code space or the output of GetPermanentName() or any other storage
|
| + // that is known to never change. This is not StringPiece because (a) char*
|
| + // is 1/2 the size and (b) StringPiece transparently casts from std::string
|
| + // which can easily lead to a pointer to non-permanent space.
|
| + const char* const histogram_name_;
|
| +
|
| + // Additional information about the histogram.
|
| AtomicCount flags_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(HistogramBase);
|
|
|