TelemetryHistogram.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef TelemetryHistogram_h__
  6. #define TelemetryHistogram_h__
  7. #include "mozilla/TelemetryHistogramEnums.h"
  8. #include "mozilla/TelemetryComms.h"
  9. #include "nsXULAppAPI.h"
  10. // This module is internal to Telemetry. It encapsulates Telemetry's
  11. // histogram accumulation and storage logic. It should only be used by
  12. // Telemetry.cpp. These functions should not be used anywhere else.
  13. // For the public interface to Telemetry functionality, see Telemetry.h.
  14. namespace TelemetryHistogram {
  15. void CreateStatisticsRecorder();
  16. void DestroyStatisticsRecorder();
  17. void InitializeGlobalState(bool canRecordBase, bool canRecordExtended);
  18. void DeInitializeGlobalState();
  19. #ifdef DEBUG
  20. bool GlobalStateHasBeenInitialized();
  21. #endif
  22. bool CanRecordBase();
  23. void SetCanRecordBase(bool b);
  24. bool CanRecordExtended();
  25. void SetCanRecordExtended(bool b);
  26. void InitHistogramRecordingEnabled();
  27. void SetHistogramRecordingEnabled(mozilla::Telemetry::ID aID, bool aEnabled);
  28. nsresult SetHistogramRecordingEnabled(const nsACString &id, bool aEnabled);
  29. void Accumulate(mozilla::Telemetry::ID aHistogram, uint32_t aSample);
  30. void Accumulate(mozilla::Telemetry::ID aID, const nsCString& aKey,
  31. uint32_t aSample);
  32. void Accumulate(const char* name, uint32_t sample);
  33. void Accumulate(const char* name, const nsCString& key, uint32_t sample);
  34. void AccumulateCategorical(mozilla::Telemetry::ID aId, const nsCString& aLabel);
  35. void AccumulateChild(GeckoProcessType aProcessType,
  36. const nsTArray<mozilla::Telemetry::Accumulation>& aAccumulations);
  37. void AccumulateChildKeyed(GeckoProcessType aProcessType,
  38. const nsTArray<mozilla::Telemetry::KeyedAccumulation>& aAccumulations);
  39. nsresult
  40. GetHistogramById(const nsACString &name, JSContext *cx,
  41. JS::MutableHandle<JS::Value> ret);
  42. nsresult
  43. GetKeyedHistogramById(const nsACString &name, JSContext *cx,
  44. JS::MutableHandle<JS::Value> ret);
  45. const char*
  46. GetHistogramName(mozilla::Telemetry::ID id);
  47. nsresult
  48. CreateHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret,
  49. bool subsession, bool clearSubsession);
  50. nsresult
  51. RegisteredHistograms(uint32_t aDataset, uint32_t *aCount,
  52. char*** aHistograms);
  53. nsresult
  54. RegisteredKeyedHistograms(uint32_t aDataset, uint32_t *aCount,
  55. char*** aHistograms);
  56. nsresult
  57. GetKeyedHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret);
  58. nsresult
  59. RegisterAddonHistogram(const nsACString &id, const nsACString &name,
  60. uint32_t histogramType, uint32_t min, uint32_t max,
  61. uint32_t bucketCount, uint8_t optArgCount);
  62. nsresult
  63. GetAddonHistogram(const nsACString &id, const nsACString &name,
  64. JSContext *cx, JS::MutableHandle<JS::Value> ret);
  65. nsresult
  66. UnregisterAddonHistograms(const nsACString &id);
  67. nsresult
  68. GetAddonHistogramSnapshots(JSContext *cx, JS::MutableHandle<JS::Value> ret);
  69. size_t
  70. GetMapShallowSizesOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf);
  71. size_t
  72. GetHistogramSizesofIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
  73. void
  74. IPCTimerFired(nsITimer* aTimer, void* aClosure);
  75. } // namespace TelemetryHistogram
  76. #endif // TelemetryHistogram_h__