Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
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_PresentationReceiver_h
8 : #define mozilla_dom_PresentationReceiver_h
9 :
10 : #include "mozilla/ErrorResult.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsCycleCollectionParticipant.h"
13 : #include "nsIPresentationListener.h"
14 : #include "nsWrapperCache.h"
15 : #include "nsString.h"
16 :
17 : class nsPIDOMWindowInner;
18 :
19 : namespace mozilla {
20 : namespace dom {
21 :
22 : class PresentationConnection;
23 : class PresentationConnectionList;
24 : class Promise;
25 :
26 : class PresentationReceiver final : public nsIPresentationRespondingListener
27 : , public nsWrapperCache
28 : {
29 : public:
30 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PresentationReceiver)
32 : NS_DECL_NSIPRESENTATIONRESPONDINGLISTENER
33 :
34 : static already_AddRefed<PresentationReceiver> Create(nsPIDOMWindowInner* aWindow);
35 :
36 : virtual JSObject* WrapObject(JSContext* aCx,
37 : JS::Handle<JSObject*> aGivenProto) override;
38 :
39 0 : nsPIDOMWindowInner* GetParentObject() const
40 : {
41 0 : return mOwner;
42 : }
43 :
44 : // WebIDL (public APIs)
45 : already_AddRefed<Promise> GetConnectionList(ErrorResult& aRv);
46 :
47 : private:
48 : explicit PresentationReceiver(nsPIDOMWindowInner* aWindow);
49 :
50 : virtual ~PresentationReceiver();
51 :
52 : MOZ_IS_CLASS_INIT bool Init();
53 :
54 : void Shutdown();
55 :
56 : void CreateConnectionList();
57 :
58 : // Store the inner window ID for |UnregisterRespondingListener| call in
59 : // |Shutdown| since the inner window may not exist at that moment.
60 : uint64_t mWindowId;
61 :
62 : nsCOMPtr<nsPIDOMWindowInner> mOwner;
63 : nsString mUrl;
64 : RefPtr<Promise> mGetConnectionListPromise;
65 : RefPtr<PresentationConnectionList> mConnectionList;
66 : };
67 :
68 : } // namespace dom
69 : } // namespace mozilla
70 :
71 : #endif // mozilla_dom_PresentationReceiver_h
|