BackgroundChannelRegistrar.h (1882B)
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_net_BackgroundChannelRegistrar_h__ 8 #define mozilla_net_BackgroundChannelRegistrar_h__ 9 10 #include "nsIBackgroundChannelRegistrar.h" 11 #include "nsRefPtrHashtable.h" 12 #include "mozilla/AlreadyAddRefed.h" 13 14 namespace mozilla { 15 namespace net { 16 17 class HttpBackgroundChannelParent; 18 class HttpChannelParent; 19 20 class BackgroundChannelRegistrar final : public nsIBackgroundChannelRegistrar { 21 using ChannelHashtable = 22 nsRefPtrHashtable<nsUint64HashKey, HttpChannelParent>; 23 using BackgroundChannelHashtable = 24 nsRefPtrHashtable<nsUint64HashKey, HttpBackgroundChannelParent>; 25 26 public: 27 NS_DECL_ISUPPORTS 28 NS_DECL_NSIBACKGROUNDCHANNELREGISTRAR 29 30 explicit BackgroundChannelRegistrar(); 31 32 // Singleton accessor 33 static already_AddRefed<nsIBackgroundChannelRegistrar> GetOrCreate(); 34 35 private: 36 virtual ~BackgroundChannelRegistrar(); 37 38 // A helper function for BackgroundChannelRegistrar itself to callback 39 // HttpChannelParent and HttpBackgroundChannelParent when both objects are 40 // ready. aChannelParent and aBgParent is the pair of HttpChannelParent and 41 // HttpBackgroundChannelParent that should be linked together. 42 void NotifyChannelLinked(HttpChannelParent* aChannelParent, 43 HttpBackgroundChannelParent* aBgParent); 44 45 // Store unlinked HttpChannelParent objects. 46 ChannelHashtable mChannels; 47 48 // Store unlinked HttpBackgroundChannelParent objects. 49 BackgroundChannelHashtable mBgChannels; 50 }; 51 52 } // namespace net 53 } // namespace mozilla 54 55 #endif // mozilla_net_BackgroundChannelRegistrar_h__