SocketProcessBridgeChild.h (1820B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef mozilla_net_SocketProcessBridgeChild_h 7 #define mozilla_net_SocketProcessBridgeChild_h 8 9 #include <functional> 10 #include "mozilla/net/PSocketProcessBridgeChild.h" 11 #include "nsIObserver.h" 12 13 namespace mozilla { 14 namespace net { 15 16 // The IPC actor implements PSocketProcessBridgeChild in content process. 17 // This is allocated and kept alive by NeckoChild. When "content-child-shutdown" 18 // topic is observed, this actor will be destroyed. 19 class SocketProcessBridgeChild final : public PSocketProcessBridgeChild, 20 public nsIObserver { 21 public: 22 NS_DECL_THREADSAFE_ISUPPORTS 23 NS_DECL_NSIOBSERVER 24 25 static already_AddRefed<SocketProcessBridgeChild> GetSingleton(); 26 using GetPromise = 27 MozPromise<RefPtr<SocketProcessBridgeChild>, nsCString, false>; 28 static RefPtr<GetPromise> GetSocketProcessBridge(); 29 30 mozilla::ipc::IPCResult RecvTest(); 31 void ActorDestroy(ActorDestroyReason aWhy) override; 32 void DeferredDestroy(); 33 bool IsShuttingDown() const { return mShuttingDown; }; 34 ProcessId SocketProcessPid() const { return mSocketProcessPid; }; 35 36 private: 37 DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild); 38 static bool Create(Endpoint<PSocketProcessBridgeChild>&& aEndpoint); 39 explicit SocketProcessBridgeChild(); 40 virtual ~SocketProcessBridgeChild(); 41 42 static StaticRefPtr<SocketProcessBridgeChild> sSocketProcessBridgeChild; 43 bool mShuttingDown; 44 ProcessId mSocketProcessPid; 45 }; 46 47 } // namespace net 48 } // namespace mozilla 49 50 #endif // mozilla_net_SocketProcessBridgeChild_h