2015-03-19 10:48:28 +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/. */
|
|
|
|
|
2015-10-12 05:36:31 +03:00
|
|
|
#ifndef mozilla_dom_PresentationConnection_h
|
|
|
|
#define mozilla_dom_PresentationConnection_h
|
2015-03-19 10:48:28 +03:00
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2015-10-12 05:36:31 +03:00
|
|
|
#include "mozilla/dom/PresentationConnectionBinding.h"
|
2016-05-30 09:48:00 +03:00
|
|
|
#include "mozilla/dom/PresentationConnectionClosedEventBinding.h"
|
2015-04-22 11:01:38 +03:00
|
|
|
#include "nsIPresentationListener.h"
|
2016-05-30 09:48:00 +03:00
|
|
|
#include "nsIRequest.h"
|
|
|
|
#include "nsWeakReference.h"
|
2015-03-19 10:48:28 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-05-29 20:59:00 +03:00
|
|
|
class PresentationConnectionList;
|
|
|
|
|
2015-10-12 05:36:31 +03:00
|
|
|
class PresentationConnection final : public DOMEventTargetHelper
|
|
|
|
, public nsIPresentationSessionListener
|
2016-05-30 09:48:00 +03:00
|
|
|
, public nsIRequest
|
2015-03-19 10:48:28 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2015-10-12 05:36:31 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationConnection,
|
2015-03-19 10:48:28 +03:00
|
|
|
DOMEventTargetHelper)
|
2015-04-22 11:01:38 +03:00
|
|
|
NS_DECL_NSIPRESENTATIONSESSIONLISTENER
|
2016-05-30 09:48:00 +03:00
|
|
|
NS_DECL_NSIREQUEST
|
2015-03-19 10:48:28 +03:00
|
|
|
|
2016-05-29 20:59:00 +03:00
|
|
|
static already_AddRefed<PresentationConnection>
|
|
|
|
Create(nsPIDOMWindowInner* aWindow,
|
|
|
|
const nsAString& aId,
|
|
|
|
const uint8_t aRole,
|
|
|
|
PresentationConnectionList* aList = nullptr);
|
2015-09-10 11:29:08 +03:00
|
|
|
|
|
|
|
virtual void DisconnectFromOwner() override;
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2015-03-19 10:48:28 +03:00
|
|
|
|
|
|
|
// WebIDL (public APIs)
|
|
|
|
void GetId(nsAString& aId) const;
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-10-12 05:36:31 +03:00
|
|
|
PresentationConnectionState State() const;
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-10-08 13:11:10 +03:00
|
|
|
void Send(const nsAString& aData,
|
|
|
|
ErrorResult& aRv);
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-10-08 13:11:10 +03:00
|
|
|
void Close(ErrorResult& aRv);
|
|
|
|
|
|
|
|
void Terminate(ErrorResult& aRv);
|
2015-03-19 10:48:28 +03:00
|
|
|
|
2016-05-30 09:48:00 +03:00
|
|
|
IMPL_EVENT_HANDLER(connect);
|
|
|
|
IMPL_EVENT_HANDLER(close);
|
|
|
|
IMPL_EVENT_HANDLER(terminate);
|
2015-03-19 10:48:28 +03:00
|
|
|
IMPL_EVENT_HANDLER(message);
|
|
|
|
|
|
|
|
private:
|
2016-01-30 20:05:36 +03:00
|
|
|
PresentationConnection(nsPIDOMWindowInner* aWindow,
|
2015-10-12 05:36:31 +03:00
|
|
|
const nsAString& aId,
|
2016-04-18 03:19:00 +03:00
|
|
|
const uint8_t aRole,
|
2016-05-29 20:59:00 +03:00
|
|
|
PresentationConnectionList* aList);
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-10-12 05:36:31 +03:00
|
|
|
~PresentationConnection();
|
2015-03-19 10:48:28 +03:00
|
|
|
|
|
|
|
bool Init();
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-03-19 10:48:28 +03:00
|
|
|
void Shutdown();
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2016-05-30 09:48:00 +03:00
|
|
|
nsresult ProcessStateChanged(nsresult aReason);
|
|
|
|
|
|
|
|
nsresult DispatchConnectionClosedEvent(PresentationConnectionClosedReason aReason,
|
|
|
|
const nsAString& aMessage);
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-04-22 11:01:38 +03:00
|
|
|
nsresult DispatchMessageEvent(JS::Handle<JS::Value> aData);
|
2015-03-19 10:48:28 +03:00
|
|
|
|
2016-05-30 09:48:00 +03:00
|
|
|
nsresult ProcessConnectionWentAway();
|
|
|
|
|
2016-07-13 01:18:00 +03:00
|
|
|
nsresult AddIntoLoadGroup();
|
|
|
|
|
|
|
|
nsresult RemoveFromLoadGroup();
|
|
|
|
|
2015-03-19 10:48:28 +03:00
|
|
|
nsString mId;
|
2016-04-18 03:19:00 +03:00
|
|
|
uint8_t mRole;
|
2015-10-12 05:36:31 +03:00
|
|
|
PresentationConnectionState mState;
|
2016-05-29 20:59:00 +03:00
|
|
|
RefPtr<PresentationConnectionList> mOwningConnectionList;
|
2016-05-30 09:48:00 +03:00
|
|
|
nsWeakPtr mWeakLoadGroup;;
|
2015-03-19 10:48:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-10-12 05:36:31 +03:00
|
|
|
#endif // mozilla_dom_PresentationConnection_h
|