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"
17 class SocketProcessBackgroundChild final
18 : public PSocketProcessBackgroundChild
{
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(
27 MoveOnlyFunction
<void(SocketProcessBackgroundChild
*)> aCallback
);
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
);
43 } // namespace mozilla
45 #endif // mozilla_net_SocketProcessBackgroundChild_h