TimelineMarker.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* -*- Mode: C++; tab-width: 8; 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 mozilla_TimelineMarker_h_
  6. #define mozilla_TimelineMarker_h_
  7. #include "AbstractTimelineMarker.h"
  8. #include "js/RootingAPI.h"
  9. namespace mozilla {
  10. // Objects of this type can be added to the timeline if there is an interested
  11. // consumer. The class can also be subclassed to let a given marker creator
  12. // provide custom details.
  13. class TimelineMarker : public AbstractTimelineMarker
  14. {
  15. public:
  16. TimelineMarker(const char* aName,
  17. MarkerTracingType aTracingType,
  18. MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
  19. TimelineMarker(const char* aName,
  20. const TimeStamp& aTime,
  21. MarkerTracingType aTracingType,
  22. MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
  23. virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override;
  24. virtual JSObject* GetStack() override;
  25. protected:
  26. void CaptureStack();
  27. private:
  28. // While normally it is not a good idea to make a persistent root,
  29. // in this case changing nsDocShell to participate in cycle
  30. // collection was deemed too invasive, and the markers are only held
  31. // here temporarily to boot.
  32. JS::PersistentRooted<JSObject*> mStackTrace;
  33. void CaptureStackIfNecessary(MarkerTracingType aTracingType,
  34. MarkerStackRequest aStackRequest);
  35. };
  36. } // namespace mozilla
  37. #endif /* mozilla_TimelineMarker_h_ */