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_RemoteLazyInputStreamThread_h 8 #define mozilla_RemoteLazyInputStreamThread_h 9 10 #include "mozilla/RemoteLazyInputStreamChild.h" 11 #include "nsIEventTarget.h" 12 #include "nsIObserver.h" 13 #include "nsTArray.h" 14 15 class nsIThread; 16 17 namespace mozilla { 18 19 class RemoteLazyInputStreamChild; 20 21 class RemoteLazyInputStreamThread final : public nsIObserver, 22 public nsIEventTarget { 23 public: 24 NS_DECL_THREADSAFE_ISUPPORTS 25 NS_DECL_NSIOBSERVER 26 NS_DECL_NSIEVENTTARGET 27 28 static bool IsOnFileEventTarget(nsIEventTarget* aEventTarget); 29 30 static RemoteLazyInputStreamThread* Get(); 31 32 static RemoteLazyInputStreamThread* GetOrCreate(); 33 34 void MigrateActor(RemoteLazyInputStreamChild* aActor); 35 36 bool Initialize(); 37 38 void InitializeOnMainThread(); 39 40 private: 41 ~RemoteLazyInputStreamThread() = default; 42 43 void MigrateActorInternal(RemoteLazyInputStreamChild* aActor); 44 45 nsCOMPtr<nsIThread> mThread; 46 47 // This is populated if MigrateActor() is called before the initialization of 48 // the thread. 49 nsTArray<RefPtr<RemoteLazyInputStreamChild>> mPendingActors; 50 }; 51 52 bool IsOnDOMFileThread(); 53 54 void AssertIsOnDOMFileThread(); 55 56 } // namespace mozilla 57 58 #endif // mozilla_RemoteLazyInputStreamThread_h 59