1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_ObservedDocShell_h_ 8 #define mozilla_ObservedDocShell_h_ 9 10 #include "MarkersStorage.h" 11 #include "mozilla/RefPtr.h" 12 #include "mozilla/UniquePtr.h" 13 #include "nsTArray.h" 14 15 class nsIDocShell; 16 17 namespace mozilla { 18 class AbstractTimelineMarker; 19 20 namespace dom { 21 struct ProfileTimelineMarker; 22 } 23 24 // # ObservedDocShell 25 // 26 // A wrapper around a docshell for which docshell-specific markers are 27 // allowed to exist. See TimelineConsumers for register/unregister logic. 28 class ObservedDocShell : public MarkersStorage { 29 private: 30 RefPtr<nsIDocShell> mDocShell; 31 32 // Main thread only. 33 nsTArray<UniquePtr<AbstractTimelineMarker>> mTimelineMarkers; 34 bool mPopping; 35 36 // Off the main thread only. 37 nsTArray<UniquePtr<AbstractTimelineMarker>> mOffTheMainThreadTimelineMarkers; 38 39 public: 40 explicit ObservedDocShell(nsIDocShell* aDocShell); 41 nsIDocShell* operator*() const { return mDocShell.get(); } 42 43 void AddMarker(UniquePtr<AbstractTimelineMarker>&& aMarker) override; 44 void AddOTMTMarker(UniquePtr<AbstractTimelineMarker>&& aMarker) override; 45 void ClearMarkers() override; 46 void PopMarkers(JSContext* aCx, 47 nsTArray<dom::ProfileTimelineMarker>& aStore) override; 48 }; 49 50 } // namespace mozilla 51 52 #endif /* mozilla_ObservedDocShell_h_ */ 53