2015-09-14 05:39:57 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_PresentationAvailability_h
|
|
|
|
#define mozilla_dom_PresentationAvailability_h
|
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2015-09-10 11:29:08 +03:00
|
|
|
#include "nsIPresentationListener.h"
|
2016-08-31 05:31:15 +03:00
|
|
|
#include "nsTArray.h"
|
2015-09-14 05:39:57 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-08-31 05:31:15 +03:00
|
|
|
class Promise;
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
class PresentationAvailability final : public DOMEventTargetHelper
|
2015-09-10 11:29:08 +03:00
|
|
|
, public nsIPresentationAvailabilityListener
|
2016-08-17 11:15:32 +03:00
|
|
|
, public SupportsWeakPtr<PresentationAvailability>
|
2015-09-14 05:39:57 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationAvailability,
|
|
|
|
DOMEventTargetHelper)
|
2015-09-10 11:29:08 +03:00
|
|
|
NS_DECL_NSIPRESENTATIONAVAILABILITYLISTENER
|
2016-08-17 11:15:32 +03:00
|
|
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PresentationAvailability)
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
static already_AddRefed<PresentationAvailability>
|
2016-08-31 05:31:15 +03:00
|
|
|
Create(nsPIDOMWindowInner* aWindow,
|
2016-08-17 11:15:32 +03:00
|
|
|
const nsAString& aUrl,
|
2016-08-31 05:31:15 +03:00
|
|
|
RefPtr<Promise>& aPromise);
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2015-09-10 11:29:08 +03:00
|
|
|
virtual void DisconnectFromOwner() override;
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2016-08-17 11:15:32 +03:00
|
|
|
bool Equals(const uint64_t aWindowID, const nsAString& aUrl) const;
|
|
|
|
|
|
|
|
bool IsCachedValueReady();
|
|
|
|
|
|
|
|
void EnqueuePromise(RefPtr<Promise>& aPromise);
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
// WebIDL (public APIs)
|
|
|
|
bool Value() const;
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(change);
|
|
|
|
|
|
|
|
private:
|
2016-08-17 11:15:32 +03:00
|
|
|
explicit PresentationAvailability(nsPIDOMWindowInner* aWindow,
|
|
|
|
const nsAString& aUrl);
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2016-08-31 05:31:15 +03:00
|
|
|
virtual ~PresentationAvailability();
|
2015-09-14 05:39:57 +03:00
|
|
|
|
2016-08-31 05:31:15 +03:00
|
|
|
bool Init(RefPtr<Promise>& aPromise);
|
2015-09-14 05:39:57 +03:00
|
|
|
|
|
|
|
void Shutdown();
|
|
|
|
|
2015-09-10 11:29:08 +03:00
|
|
|
void UpdateAvailabilityAndDispatchEvent(bool aIsAvailable);
|
|
|
|
|
2015-09-14 05:39:57 +03:00
|
|
|
bool mIsAvailable;
|
2016-08-31 05:31:15 +03:00
|
|
|
|
2016-08-17 11:15:32 +03:00
|
|
|
nsTArray<RefPtr<Promise>> mPromises;
|
|
|
|
|
|
|
|
nsString mUrl;
|
2015-09-14 05:39:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_PresentationAvailability_h
|