ProcessMessageManager.h (1868B)
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_dom_ProcessMessageManager_h 8 #define mozilla_dom_ProcessMessageManager_h 9 10 #include "mozilla/dom/MessageSender.h" 11 12 namespace mozilla::dom { 13 14 class ParentProcessMessageManager; 15 16 /** 17 * ProcessMessageManager is used in a parent process to communicate with a child 18 * process (or with the process itself in a single-process scenario). 19 */ 20 class ProcessMessageManager final : public MessageSender { 21 public: 22 ProcessMessageManager( 23 ipc::MessageManagerCallback* aCallback, 24 ParentProcessMessageManager* aParentManager, 25 MessageManagerFlags aFlags = MessageManagerFlags::MM_NONE); 26 27 virtual JSObject* WrapObject(JSContext* aCx, 28 JS::Handle<JSObject*> aGivenProto) override; 29 30 // ProcessScriptLoader 31 void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad, 32 mozilla::ErrorResult& aError) { 33 LoadScript(aUrl, aAllowDelayedLoad, false, aError); 34 } 35 void RemoveDelayedProcessScript(const nsAString& aURL) { 36 RemoveDelayedScript(aURL); 37 } 38 void GetDelayedProcessScripts(JSContext* aCx, 39 nsTArray<nsTArray<JS::Value>>& aScripts, 40 mozilla::ErrorResult& aError) { 41 GetDelayedScripts(aCx, aScripts, aError); 42 } 43 44 void SetOsPid(int32_t aPid) { mPid = aPid; } 45 int32_t OsPid() const { return mPid; } 46 47 bool IsInProcess() const { return mInProcess; } 48 49 private: 50 int32_t mPid; 51 bool mInProcess; 52 }; 53 54 } // namespace mozilla::dom 55 56 #endif // mozilla_dom_ProcessMessageManager_h