Backed out 10 changesets (bug 1803810) for xpcshell failures on test_import_global...
[gecko.git] / netwerk / ipc / SocketProcessBridgeChild.h
blob8b1c1ad6cfcddb4403caf83a55b43a5f37218c6e
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/. */
6 #ifndef mozilla_net_SocketProcessBridgeChild_h
7 #define mozilla_net_SocketProcessBridgeChild_h
9 #include <functional>
10 #include "mozilla/net/PSocketProcessBridgeChild.h"
11 #include "nsIObserver.h"
13 namespace mozilla {
14 namespace net {
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
25 static already_AddRefed<SocketProcessBridgeChild> GetSingleton();
26 using GetPromise =
27 MozPromise<RefPtr<SocketProcessBridgeChild>, nsCString, false>;
28 static RefPtr<GetPromise> GetSocketProcessBridge();
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; };
36 private:
37 DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild);
38 static bool Create(Endpoint<PSocketProcessBridgeChild>&& aEndpoint);
39 explicit SocketProcessBridgeChild();
40 virtual ~SocketProcessBridgeChild();
42 static StaticRefPtr<SocketProcessBridgeChild> sSocketProcessBridgeChild;
43 bool mShuttingDown;
44 ProcessId mSocketProcessPid;
47 } // namespace net
48 } // namespace mozilla
50 #endif // mozilla_net_SocketProcessBridgeChild_h