2014-10-27 14:03:00 +03:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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_workers_serviceworkerclient_h
|
|
|
|
#define mozilla_dom_workers_serviceworkerclient_h
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2015-02-09 20:43:00 +03:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2015-03-06 16:04:49 +03:00
|
|
|
#include "mozilla/dom/ClientBinding.h"
|
2014-10-27 14:03:00 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace workers {
|
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
class ServiceWorkerClient;
|
|
|
|
class ServiceWorkerWindowClient;
|
|
|
|
|
|
|
|
// Used as a container object for information needed to create
|
|
|
|
// client objects.
|
2015-03-21 19:28:04 +03:00
|
|
|
class ServiceWorkerClientInfo final
|
2015-03-06 16:04:49 +03:00
|
|
|
{
|
|
|
|
friend class ServiceWorkerClient;
|
|
|
|
friend class ServiceWorkerWindowClient;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ServiceWorkerClientInfo(nsIDocument* aDoc);
|
|
|
|
|
|
|
|
private:
|
2015-03-13 09:15:25 +03:00
|
|
|
nsString mClientId;
|
|
|
|
uint64_t mWindowId;
|
2015-03-06 16:04:49 +03:00
|
|
|
nsString mUrl;
|
|
|
|
|
|
|
|
// Window Clients
|
|
|
|
VisibilityState mVisibilityState;
|
|
|
|
bool mFocused;
|
|
|
|
FrameType mFrameType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ServiceWorkerClient : public nsISupports,
|
|
|
|
public nsWrapperCache
|
2014-10-27 14:03:00 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClient)
|
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
ServiceWorkerClient(nsISupports* aOwner,
|
|
|
|
const ServiceWorkerClientInfo& aClientInfo)
|
2015-04-07 16:25:08 +03:00
|
|
|
: mOwner(aOwner)
|
|
|
|
, mId(aClientInfo.mClientId)
|
|
|
|
, mUrl(aClientInfo.mUrl)
|
|
|
|
, mWindowId(aClientInfo.mWindowId)
|
2014-10-27 14:03:00 +03:00
|
|
|
{
|
2015-03-06 16:04:49 +03:00
|
|
|
MOZ_ASSERT(aOwner);
|
2014-10-27 14:03:00 +03:00
|
|
|
}
|
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
nsISupports*
|
|
|
|
GetParentObject() const
|
2014-10-27 14:03:00 +03:00
|
|
|
{
|
2015-03-06 16:04:49 +03:00
|
|
|
return mOwner;
|
2014-10-27 14:03:00 +03:00
|
|
|
}
|
|
|
|
|
2015-03-13 09:15:25 +03:00
|
|
|
void GetId(nsString& aRetval) const
|
|
|
|
{
|
|
|
|
aRetval = mId;
|
|
|
|
}
|
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
void
|
|
|
|
GetUrl(nsAString& aUrl) const
|
2014-10-27 14:03:00 +03:00
|
|
|
{
|
2015-03-06 16:04:49 +03:00
|
|
|
aUrl.Assign(mUrl);
|
2014-10-27 14:03:00 +03:00
|
|
|
}
|
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
void
|
|
|
|
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const Optional<Sequence<JS::Value>>& aTransferable,
|
|
|
|
ErrorResult& aRv);
|
2015-02-09 20:43:00 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-10-27 14:03:00 +03:00
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
protected:
|
|
|
|
virtual ~ServiceWorkerClient()
|
|
|
|
{ }
|
2014-10-27 14:03:00 +03:00
|
|
|
|
2015-03-06 16:04:49 +03:00
|
|
|
private:
|
2014-10-27 14:03:00 +03:00
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
2015-03-13 09:15:25 +03:00
|
|
|
nsString mId;
|
2015-03-06 16:04:49 +03:00
|
|
|
nsString mUrl;
|
2015-04-07 16:25:08 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
uint64_t mWindowId;
|
2014-10-27 14:03:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace workers
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_workers_serviceworkerclient_h
|