Backed out 10 changesets (bug 1803810) for xpcshell failures on test_import_global...
[gecko.git] / netwerk / ipc / SocketProcessBackgroundChild.h
blobb83c8dbcc11616464b1b29cd1ed86b76a190163a
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_SocketProcessBackgroundChild_h
7 #define mozilla_net_SocketProcessBackgroundChild_h
9 #include "mozilla/MoveOnlyFunction.h"
10 #include "mozilla/net/PSocketProcessBackgroundChild.h"
11 #include "mozilla/StaticMutex.h"
12 #include "mozilla/StaticPtr.h"
14 namespace mozilla {
15 namespace net {
17 class SocketProcessBackgroundChild final
18 : public PSocketProcessBackgroundChild {
19 public:
20 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SocketProcessBackgroundChild, final)
22 static void Create(ipc::Endpoint<PSocketProcessBackgroundChild>&& aEndpoint);
23 static void Shutdown();
24 // |aCallback| will be called with the actor asynchronously on |sTaskQueue|.
25 static nsresult WithActor(
26 const char* aName,
27 MoveOnlyFunction<void(SocketProcessBackgroundChild*)> aCallback);
29 private:
30 SocketProcessBackgroundChild();
31 virtual ~SocketProcessBackgroundChild();
33 static RefPtr<SocketProcessBackgroundChild> GetSingleton();
34 static already_AddRefed<nsISerialEventTarget> TaskQueue();
36 static StaticMutex sMutex;
37 static StaticRefPtr<SocketProcessBackgroundChild> sInstance
38 MOZ_GUARDED_BY(sMutex);
39 static StaticRefPtr<nsISerialEventTarget> sTaskQueue MOZ_GUARDED_BY(sMutex);
42 } // namespace net
43 } // namespace mozilla
45 #endif // mozilla_net_SocketProcessBackgroundChild_h