1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #include "mozilla/net/BackgroundDataBridgeChild.h"
6 #include "mozilla/net/HttpBackgroundChannelChild.h"
7
8 namespace mozilla {
9 namespace net {
10
BackgroundDataBridgeChild(HttpBackgroundChannelChild * aBgChild)11 BackgroundDataBridgeChild::BackgroundDataBridgeChild(
12 HttpBackgroundChannelChild* aBgChild)
13 : mBgChild(aBgChild), mBackgroundThread(NS_GetCurrentThread()) {
14 MOZ_ASSERT(aBgChild);
15 }
16
17 BackgroundDataBridgeChild::~BackgroundDataBridgeChild() = default;
18
Destroy()19 void BackgroundDataBridgeChild::Destroy() {
20 RefPtr<BackgroundDataBridgeChild> self = this;
21 MOZ_ALWAYS_SUCCEEDS(mBackgroundThread->Dispatch(
22 NS_NewRunnableFunction("BackgroundDataBridgeParent::Destroy",
23 [self]() {
24 if (self->CanSend()) {
25 Unused << self->Send__delete__(self);
26 }
27 }),
28 NS_DISPATCH_NORMAL));
29 }
30
RecvOnTransportAndData(const uint64_t & offset,const uint32_t & count,const nsCString & data)31 mozilla::ipc::IPCResult BackgroundDataBridgeChild::RecvOnTransportAndData(
32 const uint64_t& offset, const uint32_t& count, const nsCString& data) {
33 MOZ_ASSERT(mBgChild);
34 return mBgChild->RecvOnTransportAndData(NS_OK, NS_NET_STATUS_RECEIVING_FROM,
35 offset, count, data, true);
36 }
37
38 } // namespace net
39 } // namespace mozilla
40