EarlyHintsService.h (1576B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 ts=8 et tw=80 : */ 3 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #ifndef mozilla_net_EarlyHintsService_h 9 #define mozilla_net_EarlyHintsService_h 10 11 #include "mozilla/dom/ipc/IdType.h" 12 #include "mozilla/Maybe.h" 13 #include "mozilla/RefPtr.h" 14 #include "mozilla/TimeStamp.h" 15 #include "nsStringFwd.h" 16 #include "nsTArray.h" 17 18 class nsIChannel; 19 class nsIURI; 20 class nsIInterfaceRequestor; 21 namespace mozilla::dom { 22 class CanonicalBrowsingContext; 23 } 24 25 namespace mozilla::net { 26 27 class EarlyHintConnectArgs; 28 class OngoingEarlyHints; 29 30 class EarlyHintsService { 31 public: 32 EarlyHintsService(); 33 ~EarlyHintsService(); 34 void EarlyHint(const nsACString& aLinkHeader, nsIURI* aBaseURI, 35 nsIChannel* aChannel, const nsACString& aReferrerPolicy, 36 const nsACString& aCSPHeader, 37 dom::CanonicalBrowsingContext* aLoadingBrowsingContext); 38 void Reset(); 39 void Cancel(const nsACString& aReason); 40 41 void RegisterLinksAndGetConnectArgs( 42 dom::ContentParentId aCpId, nsTArray<EarlyHintConnectArgs>& aOutLinks); 43 44 uint32_t LinkType() const { return mLinkType; } 45 46 private: 47 Maybe<TimeStamp> mFirstEarlyHint; 48 uint32_t mEarlyHintsCount{0}; 49 50 RefPtr<OngoingEarlyHints> mOngoingEarlyHints; 51 uint32_t mLinkType = 0; 52 }; 53 54 } // namespace mozilla::net 55 56 #endif // mozilla_net_EarlyHintsService_h