Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/broadcastchannel/BroadcastChannelParent.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "BroadcastChannelParent.h"
8
#include "BroadcastChannelService.h"
9
#include "mozilla/dom/File.h"
10
#include "mozilla/dom/IPCBlobUtils.h"
11
#include "mozilla/ipc/BackgroundParent.h"
12
#include "mozilla/ipc/IPCStreamUtils.h"
13
#include "mozilla/Unused.h"
14
#include "nsIScriptSecurityManager.h"
15
16
namespace mozilla {
17
18
using namespace ipc;
19
20
namespace dom {
21
22
BroadcastChannelParent::BroadcastChannelParent(const nsAString& aOriginChannelKey)
23
  : mService(BroadcastChannelService::GetOrCreate())
24
  , mOriginChannelKey(aOriginChannelKey)
25
0
{
26
0
  AssertIsOnBackgroundThread();
27
0
  mService->RegisterActor(this, mOriginChannelKey);
28
0
}
29
30
BroadcastChannelParent::~BroadcastChannelParent()
31
0
{
32
0
  AssertIsOnBackgroundThread();
33
0
}
34
35
mozilla::ipc::IPCResult
36
BroadcastChannelParent::RecvPostMessage(const ClonedMessageData& aData)
37
0
{
38
0
  AssertIsOnBackgroundThread();
39
0
40
0
  if (NS_WARN_IF(!mService)) {
41
0
    return IPC_FAIL_NO_REASON(this);
42
0
  }
43
0
44
0
  mService->PostMessage(this, aData, mOriginChannelKey);
45
0
  return IPC_OK();
46
0
}
47
48
mozilla::ipc::IPCResult
49
BroadcastChannelParent::RecvClose()
50
0
{
51
0
  AssertIsOnBackgroundThread();
52
0
53
0
  if (NS_WARN_IF(!mService)) {
54
0
    return IPC_FAIL_NO_REASON(this);
55
0
  }
56
0
57
0
  mService->UnregisterActor(this, mOriginChannelKey);
58
0
  mService = nullptr;
59
0
60
0
  Unused << Send__delete__(this);
61
0
62
0
  return IPC_OK();
63
0
}
64
65
void
66
BroadcastChannelParent::ActorDestroy(ActorDestroyReason aWhy)
67
0
{
68
0
  AssertIsOnBackgroundThread();
69
0
70
0
  if (mService) {
71
0
    // This object is about to be released and with it, also mService will be
72
0
    // released too.
73
0
    mService->UnregisterActor(this, mOriginChannelKey);
74
0
  }
75
0
}
76
77
} // namespace dom
78
} // namespace mozilla