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 typedef MozPromise<RefPtr<SocketProcessBridgeChild>, nsCString, false> 27 GetPromise; 28 static RefPtr<GetPromise> GetSocketProcessBridge(); 29 30 mozilla::ipc::IPCResult RecvTest(); 31 void ActorDestroy(ActorDestroyReason aWhy) override; 32 void DeferredDestroy(); IsShuttingDown()33 bool IsShuttingDown() const { return mShuttingDown; }; Inited()34 bool Inited() const { return mInited; }; SocketProcessPid()35 ProcessId SocketProcessPid() const { return mSocketProcessPid; }; 36 37 private: 38 DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild); 39 static bool Create(Endpoint<PSocketProcessBridgeChild>&& aEndpoint); 40 explicit SocketProcessBridgeChild( 41 Endpoint<PSocketProcessBridgeChild>&& aEndpoint); 42 virtual ~SocketProcessBridgeChild(); 43 44 static StaticRefPtr<SocketProcessBridgeChild> sSocketProcessBridgeChild; 45 bool mShuttingDown; 46 bool mInited = false; 47 ProcessId mSocketProcessPid; 48 }; 49 50 } // namespace net 51 } // namespace mozilla 52 53 #endif // mozilla_net_SocketProcessBridgeChild_h 54