Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/presentation/PresentationConnectionList.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_PresentationConnectionList_h
8
#define mozilla_dom_PresentationConnectionList_h
9
10
#include "mozilla/DOMEventTargetHelper.h"
11
#include "nsTArray.h"
12
13
namespace mozilla {
14
namespace dom {
15
16
class PresentationConnection;
17
class Promise;
18
19
class PresentationConnectionList final : public DOMEventTargetHelper
20
{
21
public:
22
  NS_DECL_ISUPPORTS_INHERITED
23
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationConnectionList,
24
                                           DOMEventTargetHelper)
25
26
  PresentationConnectionList(nsPIDOMWindowInner* aWindow,
27
                             Promise* aPromise);
28
29
  virtual JSObject* WrapObject(JSContext* aCx,
30
                               JS::Handle<JSObject*> aGivenProto) override;
31
32
  void GetConnections(nsTArray<RefPtr<PresentationConnection>>& aConnections) const;
33
34
  void NotifyStateChange(const nsAString& aSessionId, PresentationConnection* aConnection);
35
36
  IMPL_EVENT_HANDLER(connectionavailable);
37
38
private:
39
0
  virtual ~PresentationConnectionList() = default;
40
41
  nsresult DispatchConnectionAvailableEvent(PresentationConnection* aConnection);
42
43
  typedef nsTArray<RefPtr<PresentationConnection>> ConnectionArray;
44
  typedef ConnectionArray::index_type ConnectionArrayIndex;
45
46
  ConnectionArrayIndex FindConnectionById(const nsAString& aId);
47
48
  RefPtr<Promise> mGetConnectionListPromise;
49
50
  // This array stores only non-terminsted connections.
51
  ConnectionArray mConnections;
52
};
53
54
} // namespace dom
55
} // namespace mozilla
56
57
#endif // mozilla_dom_PresentationConnectionList_h