Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/BroadcastChannel.h
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
#ifndef mozilla_dom_BroadcastChannel_h
8
#define mozilla_dom_BroadcastChannel_h
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/DOMEventTargetHelper.h"
12
#include "nsAutoPtr.h"
13
#include "nsTArray.h"
14
#include "mozilla/RefPtr.h"
15
16
class nsPIDOMWindowInner;
17
18
namespace mozilla {
19
20
namespace ipc {
21
class PrincipalInfo;
22
} // namespace ipc
23
24
namespace dom {
25
26
class BroadcastChannelChild;
27
class BroadcastChannelMessage;
28
class WorkerRef;
29
30
class BroadcastChannel final
31
  : public DOMEventTargetHelper
32
{
33
  friend class BroadcastChannelChild;
34
35
  typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
36
37
public:
38
  NS_DECL_ISUPPORTS_INHERITED
39
40
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BroadcastChannel,
41
                                           DOMEventTargetHelper)
42
43
  virtual JSObject*
44
  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
45
46
  static already_AddRefed<BroadcastChannel>
47
  Constructor(const GlobalObject& aGlobal, const nsAString& aChannel,
48
              ErrorResult& aRv);
49
50
  void GetName(nsAString& aName) const
51
0
  {
52
0
    aName = mChannel;
53
0
  }
54
55
  void PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
56
                   ErrorResult& aRv);
57
58
  void Close();
59
60
  IMPL_EVENT_HANDLER(message)
61
  IMPL_EVENT_HANDLER(messageerror)
62
63
  void Shutdown();
64
65
private:
66
  BroadcastChannel(nsPIDOMWindowInner* aWindow,
67
                   const nsAString& aChannel);
68
69
  ~BroadcastChannel();
70
71
  void RemoveDocFromBFCache();
72
73
  void DisconnectFromOwner() override;
74
75
  RefPtr<BroadcastChannelChild> mActor;
76
77
  RefPtr<WorkerRef> mWorkerRef;
78
79
  nsString mChannel;
80
81
  enum {
82
    StateActive,
83
    StateClosed
84
  } mState;
85
};
86
87
} // namespace dom
88
} // namespace mozilla
89
90
#endif // mozilla_dom_BroadcastChannel_h