mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 723846 - Part 1: add FlagHistogram to ipc. r=taras
This commit is contained in:
parent
9299a0663c
commit
2cbd8085c0
@ -916,6 +916,52 @@ BooleanHistogram::BooleanHistogram(const std::string& name)
|
||||
: LinearHistogram(name, 1, 2, 3) {
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// FlagHistogram:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Histogram *
|
||||
FlagHistogram::FactoryGet(const std::string &name, Flags flags)
|
||||
{
|
||||
Histogram *h(nsnull);
|
||||
|
||||
if (!StatisticsRecorder::FindHistogram(name, &h)) {
|
||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||
FlagHistogram *fh = new FlagHistogram(name);
|
||||
fh->InitializeBucketRange();
|
||||
fh->SetFlags(flags);
|
||||
size_t zero_index = fh->BucketIndex(0);
|
||||
fh->Histogram::Accumulate(1, 1, zero_index);
|
||||
h = StatisticsRecorder::RegisterOrDeleteDuplicate(fh);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
FlagHistogram::FlagHistogram(const std::string &name)
|
||||
: BooleanHistogram(name), mSwitched(false) {
|
||||
}
|
||||
|
||||
Histogram::ClassType
|
||||
FlagHistogram::histogram_type() const
|
||||
{
|
||||
return FLAG_HISTOGRAM;
|
||||
}
|
||||
|
||||
void
|
||||
FlagHistogram::Accumulate(Sample value, Count count, size_t index)
|
||||
{
|
||||
if (mSwitched) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSwitched = true;
|
||||
DCHECK_EQ(value, 1);
|
||||
Histogram::Accumulate(value, 1, index);
|
||||
size_t zero_index = BucketIndex(0);
|
||||
Histogram::Accumulate(1, -1, zero_index);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CustomHistogram:
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -276,6 +276,7 @@ class Histogram {
|
||||
HISTOGRAM,
|
||||
LINEAR_HISTOGRAM,
|
||||
BOOLEAN_HISTOGRAM,
|
||||
FLAG_HISTOGRAM,
|
||||
CUSTOM_HISTOGRAM,
|
||||
NOT_VALID_IN_RENDERER
|
||||
};
|
||||
@ -642,7 +643,7 @@ class BooleanHistogram : public LinearHistogram {
|
||||
|
||||
virtual void AddBoolean(bool value);
|
||||
|
||||
private:
|
||||
protected:
|
||||
explicit BooleanHistogram(const std::string& name);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BooleanHistogram);
|
||||
@ -650,6 +651,25 @@ class BooleanHistogram : public LinearHistogram {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// FlagHistogram is like boolean histogram, but only allows a single off/on value.
|
||||
class FlagHistogram : public BooleanHistogram
|
||||
{
|
||||
public:
|
||||
static Histogram *FactoryGet(const std::string &name, Flags flags);
|
||||
|
||||
virtual ClassType histogram_type() const;
|
||||
|
||||
virtual void Accumulate(Sample value, Count count, size_t index);
|
||||
|
||||
private:
|
||||
explicit FlagHistogram(const std::string &name);
|
||||
bool mSwitched;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FlagHistogram);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// CustomHistogram is a histogram for a set of custom integers.
|
||||
class CustomHistogram : public Histogram {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user