TelemetryScalar.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 TelemetryScalar_h__
  6. #define TelemetryScalar_h__
  7. #include "mozilla/TelemetryScalarEnums.h"
  8. // This module is internal to Telemetry. It encapsulates Telemetry's
  9. // scalar accumulation and storage logic. It should only be used by
  10. // Telemetry.cpp. These functions should not be used anywhere else.
  11. // For the public interface to Telemetry functionality, see Telemetry.h.
  12. namespace TelemetryScalar {
  13. void InitializeGlobalState(bool canRecordBase, bool canRecordExtended);
  14. void DeInitializeGlobalState();
  15. void SetCanRecordBase(bool b);
  16. void SetCanRecordExtended(bool b);
  17. // JS API Endpoints.
  18. nsresult Add(const nsACString& aName, JS::HandleValue aVal, JSContext* aCx);
  19. nsresult Set(const nsACString& aName, JS::HandleValue aVal, JSContext* aCx);
  20. nsresult SetMaximum(const nsACString& aName, JS::HandleValue aVal, JSContext* aCx);
  21. nsresult CreateSnapshots(unsigned int aDataset, bool aClearScalars,
  22. JSContext* aCx, uint8_t optional_argc,
  23. JS::MutableHandle<JS::Value> aResult);
  24. // Keyed JS API Endpoints.
  25. nsresult Add(const nsACString& aName, const nsAString& aKey, JS::HandleValue aVal,
  26. JSContext* aCx);
  27. nsresult Set(const nsACString& aName, const nsAString& aKey, JS::HandleValue aVal,
  28. JSContext* aCx);
  29. nsresult SetMaximum(const nsACString& aName, const nsAString& aKey, JS::HandleValue aVal,
  30. JSContext* aCx);
  31. nsresult CreateKeyedSnapshots(unsigned int aDataset, bool aClearScalars,
  32. JSContext* aCx, uint8_t optional_argc,
  33. JS::MutableHandle<JS::Value> aResult);
  34. // C++ API Endpoints.
  35. void Add(mozilla::Telemetry::ScalarID aId, uint32_t aValue);
  36. void Set(mozilla::Telemetry::ScalarID aId, uint32_t aValue);
  37. void Set(mozilla::Telemetry::ScalarID aId, const nsAString& aValue);
  38. void Set(mozilla::Telemetry::ScalarID aId, bool aValue);
  39. void SetMaximum(mozilla::Telemetry::ScalarID aId, uint32_t aValue);
  40. // Keyed C++ API Endpoints.
  41. void Add(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, uint32_t aValue);
  42. void Set(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, uint32_t aValue);
  43. void Set(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, bool aValue);
  44. void SetMaximum(mozilla::Telemetry::ScalarID aId, const nsAString& aKey, uint32_t aValue);
  45. // Only to be used for testing.
  46. void ClearScalars();
  47. size_t GetMapShallowSizesOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf);
  48. size_t GetScalarSizesOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
  49. } // namespace TelemetryScalar
  50. #endif // TelemetryScalar_h__