Bug 1261052 - Move C++ histogram implementation code into a separate module. r=gfritzsche.

--HG--
extra : rebase_source : 8799fa405c655795fc42350666e0f3baffd316fc
This commit is contained in:
Julian Seward 2016-05-17 15:05:19 +02:00
Родитель 287629d51c
Коммит 7a4c826078
7 изменённых файлов: 2272 добавлений и 1792 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -12,6 +12,8 @@
#include "nsTArray.h"
#include "nsStringGlue.h"
#include "mozilla/TelemetryHistogramEnums.h"
/******************************************************************************
* This implements the Telemetry system.
* It allows recording into histograms as well some more specialized data
@ -30,8 +32,6 @@ namespace HangMonitor {
} // namespace HangMonitor
namespace Telemetry {
#include "mozilla/TelemetryHistogramEnums.h"
enum TimerResolution {
Millisecond,
Microsecond

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef TelemetryHistogram_h__
#define TelemetryHistogram_h__
#include "mozilla/TelemetryHistogramEnums.h"
// This module is internal to Telemetry. It encapsulates Telemetry's
// histogram accumulation and storage logic. It should only be used by
// Telemetry.cpp. These functions should not be used anywhere else.
// For the public interface to Telemetry functionality, see Telemetry.h.
namespace TelemetryHistogram {
void InitializeGlobalState(bool canRecordBase, bool canRecordExtended);
void DeInitializeGlobalState();
#ifdef DEBUG
bool GlobalStateHasBeenInitialized();
#endif
bool CanRecordBase();
void SetCanRecordBase(bool b);
bool CanRecordExtended();
void SetCanRecordExtended(bool b);
void InitHistogramRecordingEnabled();
void SetHistogramRecordingEnabled(mozilla::Telemetry::ID aID, bool aEnabled);
nsresult SetHistogramRecordingEnabled(const nsACString &id, bool aEnabled);
void Accumulate(mozilla::Telemetry::ID aHistogram, uint32_t aSample);
void Accumulate(mozilla::Telemetry::ID aID, const nsCString& aKey,
uint32_t aSample);
void Accumulate(const char* name, uint32_t sample);
void Accumulate(const char* name, const nsCString& key, uint32_t sample);
void
ClearHistogram(mozilla::Telemetry::ID aId);
nsresult
GetHistogramById(const nsACString &name, JSContext *cx,
JS::MutableHandle<JS::Value> ret);
nsresult
GetKeyedHistogramById(const nsACString &name, JSContext *cx,
JS::MutableHandle<JS::Value> ret);
const char*
GetHistogramName(mozilla::Telemetry::ID id);
nsresult
NewHistogram(const nsACString &name, const nsACString &expiration,
uint32_t histogramType, uint32_t min, uint32_t max,
uint32_t bucketCount, JSContext *cx,
uint8_t optArgCount, JS::MutableHandle<JS::Value> ret);
nsresult
NewKeyedHistogram(const nsACString &name, const nsACString &expiration,
uint32_t histogramType, uint32_t min, uint32_t max,
uint32_t bucketCount, JSContext *cx,
uint8_t optArgCount, JS::MutableHandle<JS::Value> ret);
nsresult
HistogramFrom(const nsACString &name, const nsACString &existing_name,
JSContext *cx, JS::MutableHandle<JS::Value> ret);
nsresult
CreateHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret,
bool subsession, bool clearSubsession);
nsresult
RegisteredHistograms(uint32_t aDataset, uint32_t *aCount,
char*** aHistograms);
nsresult
RegisteredKeyedHistograms(uint32_t aDataset, uint32_t *aCount,
char*** aHistograms);
nsresult
GetKeyedHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret);
nsresult
RegisterAddonHistogram(const nsACString &id, const nsACString &name,
uint32_t histogramType, uint32_t min, uint32_t max,
uint32_t bucketCount, uint8_t optArgCount);
nsresult
GetAddonHistogram(const nsACString &id, const nsACString &name,
JSContext *cx, JS::MutableHandle<JS::Value> ret);
nsresult
UnregisterAddonHistograms(const nsACString &id);
nsresult
GetAddonHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret);
size_t
GetMapShallowSizesOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf);
size_t
GetHistogramSizesofIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
} // namespace TelemetryHistogram
#endif // TelemetryHistogram_h__

Просмотреть файл

@ -71,7 +71,7 @@ def print_array_entry(output, histogram, name_index, exp_index):
def write_histogram_table(output, histograms):
table = StringTable()
print("const TelemetryHistogram gHistograms[] = {", file=output)
print("const HistogramInfo gHistograms[] = {", file=output)
for histogram in histograms:
name_index = table.stringIndex(histogram.name())
exp_index = table.stringIndex(histogram.expiration())

Просмотреть файл

@ -23,6 +23,10 @@ banner = """/* This file is auto-generated, see gen-histogram-enum.py. */
def main(output, *filenames):
print(banner, file=output)
print("#ifndef mozilla_TelemetryHistogramEnums_h", file=output);
print("#define mozilla_TelemetryHistogramEnums_h", file=output);
print("namespace mozilla {", file=output)
print("namespace Telemetry {", file=output)
print("enum ID : uint32_t {", file=output)
groups = itertools.groupby(histogram_tools.from_files(filenames),
@ -63,6 +67,9 @@ def main(output, *filenames):
print(" HistogramLastUseCounter = 0,", file=output)
print(" HistogramUseCounterCount = 0", file=output)
print("};", file=output)
print("} // namespace mozilla", file=output)
print("} // namespace Telemetry", file=output)
print("#endif // mozilla_TelemetryHistogramEnums_h", file=output);
if __name__ == '__main__':
main(sys.stdout, *sys.argv[1:])

Просмотреть файл

@ -23,6 +23,7 @@ EXPORTS.mozilla += [
SOURCES += [
'Telemetry.cpp',
'TelemetryHistogram.cpp',
'WebrtcTelemetry.cpp',
]