Bug 673292. Provide raw histogram data to c++ consumers. r=jmuizelaar

This will be useful for manually controlling histogram values instead of
just acummulating.
This commit is contained in:
Taras Glek 2011-08-05 09:53:48 -04:00
parent d4f71dfd35
commit f66a1bc657
2 changed files with 18 additions and 1 deletions

View File

@ -149,7 +149,7 @@ GetHistogramByEnumId(Telemetry::ID id, Histogram **ret)
const TelemetryHistogram &p = gHistograms[id];
nsresult rv = HistogramGet(p.id, p.min, p.max, p.bucketCount, p.histogramType, &h);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
return rv;
*ret = knownHistograms[id] = h;
return NS_OK;
@ -411,6 +411,14 @@ Accumulate(ID aHistogram, PRUint32 aSample)
h->Add(aSample);
}
base::Histogram*
GetHistogramById(ID id)
{
Histogram *h = NULL;
GetHistogramByEnumId(id, &h);
return h;
}
} // namespace Telemetry
} // namespace mozilla

View File

@ -42,6 +42,10 @@
#include "mozilla/TimeStamp.h"
#include "mozilla/AutoRestore.h"
namespace base {
class Histogram;
}
namespace mozilla {
namespace Telemetry {
@ -62,6 +66,11 @@ HistogramCount
*/
void Accumulate(ID id, PRUint32 sample);
/**
* Return a raw Histogram for direct manipulation for users who can not use Accumulate().
*/
base::Histogram* GetHistogramById(ID id);
template<ID id>
class AutoTimer {
public: