PerformanceNavigation.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_dom_PerformanceNavigation_h
  6. #define mozilla_dom_PerformanceNavigation_h
  7. #include "mozilla/Attributes.h"
  8. #include "mozilla/dom/Performance.h"
  9. #include "nsDOMNavigationTiming.h"
  10. #include "nsWrapperCache.h"
  11. namespace mozilla {
  12. namespace dom {
  13. // Script "performance.navigation" object
  14. class PerformanceNavigation final : public nsWrapperCache
  15. {
  16. public:
  17. explicit PerformanceNavigation(Performance* aPerformance);
  18. NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PerformanceNavigation)
  19. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PerformanceNavigation)
  20. nsDOMNavigationTiming* GetDOMTiming() const
  21. {
  22. return mPerformance->GetDOMTiming();
  23. }
  24. PerformanceTiming* GetPerformanceTiming() const
  25. {
  26. return mPerformance->Timing();
  27. }
  28. Performance* GetParentObject() const
  29. {
  30. return mPerformance;
  31. }
  32. virtual JSObject* WrapObject(JSContext *cx,
  33. JS::Handle<JSObject*> aGivenProto) override;
  34. // PerformanceNavigation WebIDL methods
  35. uint16_t Type() const
  36. {
  37. return GetDOMTiming()->GetType();
  38. }
  39. uint16_t RedirectCount() const;
  40. private:
  41. ~PerformanceNavigation();
  42. RefPtr<Performance> mPerformance;
  43. };
  44. } // namespace dom
  45. } // namespace mozilla
  46. #endif // mozilla_dom_PerformanceNavigation_h