mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
9e4ed9857d
- Bug 1183825 - Hide PushMessageData methods until we support sending push data. r=mt,smaug (c07f6b6c9) - Bug 1186880 - Performance timing api in workers should output entries if preference is enabled. r=baku (642bd335a) - Bug 1188091 - Fix the exposure of Push interfaces; r=dougt,bzbarsky,nsm Currently we don't check the dom.push.enabled pref in some cases for some of these interfaces. This patch unifies how all of these interfaces are exposed to Window, Worker, and ServiceWorker. (dbe4ebfcc) - Bug 1188062 - Unship Request.context; r=baku (6ca2ebcf6) - Bug 1162714 - Don't let YCM generate machc. r=ehsan (7c5f36c12) - Bug 1160897 - Fixing .ycm_extra_conf for Fennec. r=ehsan (22adf0705) - goanna->gecko (94b69bd6c) - improve (e87b53162) - Bug 1147939 - The expression decompiler can't assume that it's called directly from script. (r=bhackett) (4759a5210) - Bug 1188609 - Remove mirroring support from RokuApp (Toolkit) r=snorp (81a0bb66a) - Bug 1050749 - Expose BatteryManager via getBattery() returning a Promise. r=bz, r=baku, r=jgraham (67d2dd502) - Bug 1182347 - Remove nsIPrincipal::cookieJar. r=sicking (855d0e8ce) - remove double method, probably misspach (3c256c5b4) - Bug 1182357 - Add an API to mint nsExpandedPrincipals. r=mrbkap (42de17cfd) - Bug 1172080 - Part 1: Throw when requesting origin for poorly behaved URIs, r=bholley (c8410f3c6) - Bug 1124126 - Retry database connection for the case of corrupted permissions.sqlite. r=bsmedberg (748e9205a)
247 lines
6.2 KiB
C++
247 lines
6.2 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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_serviceworkerevents_h__
|
|
#define mozilla_dom_workers_serviceworkerevents_h__
|
|
|
|
#include "mozilla/dom/Event.h"
|
|
#include "mozilla/dom/ExtendableEventBinding.h"
|
|
#include "mozilla/dom/FetchEventBinding.h"
|
|
#include "mozilla/dom/Promise.h"
|
|
#include "mozilla/dom/Response.h"
|
|
#include "mozilla/dom/workers/bindings/ServiceWorker.h"
|
|
|
|
#ifndef MOZ_SIMPLEPUSH
|
|
#include "mozilla/dom/PushEventBinding.h"
|
|
#include "mozilla/dom/PushMessageDataBinding.h"
|
|
#endif
|
|
|
|
#include "nsProxyRelease.h"
|
|
#include "nsContentUtils.h"
|
|
|
|
class nsIInterceptedChannel;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
class Blob;
|
|
class Request;
|
|
class ResponseOrPromise;
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
class ServiceWorkerClient;
|
|
|
|
class FetchEvent final : public Event
|
|
{
|
|
nsMainThreadPtrHandle<nsIInterceptedChannel> mChannel;
|
|
nsMainThreadPtrHandle<ServiceWorker> mServiceWorker;
|
|
nsRefPtr<ServiceWorkerClient> mClient;
|
|
nsRefPtr<Request> mRequest;
|
|
nsAutoPtr<ServiceWorkerClientInfo> mClientInfo;
|
|
bool mIsReload;
|
|
bool mWaitToRespond;
|
|
protected:
|
|
explicit FetchEvent(EventTarget* aOwner);
|
|
~FetchEvent();
|
|
|
|
public:
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FetchEvent, Event)
|
|
NS_FORWARD_TO_EVENT
|
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
|
{
|
|
return FetchEventBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
void PostInit(nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
|
|
nsMainThreadPtrHandle<ServiceWorker>& aServiceWorker,
|
|
nsAutoPtr<ServiceWorkerClientInfo>& aClientInfo);
|
|
|
|
static already_AddRefed<FetchEvent>
|
|
Constructor(const GlobalObject& aGlobal,
|
|
const nsAString& aType,
|
|
const FetchEventInit& aOptions,
|
|
ErrorResult& aRv);
|
|
|
|
bool
|
|
WaitToRespond() const
|
|
{
|
|
return mWaitToRespond;
|
|
}
|
|
|
|
Request*
|
|
Request_() const
|
|
{
|
|
return mRequest;
|
|
}
|
|
|
|
already_AddRefed<ServiceWorkerClient>
|
|
GetClient();
|
|
|
|
bool
|
|
IsReload() const
|
|
{
|
|
return mIsReload;
|
|
}
|
|
|
|
void
|
|
RespondWith(Promise& aArg, ErrorResult& aRv);
|
|
|
|
already_AddRefed<Promise>
|
|
ForwardTo(const nsAString& aUrl);
|
|
|
|
already_AddRefed<Promise>
|
|
Default();
|
|
};
|
|
|
|
class ExtendableEvent : public Event
|
|
{
|
|
nsRefPtr<Promise> mPromise;
|
|
|
|
protected:
|
|
explicit ExtendableEvent(mozilla::dom::EventTarget* aOwner);
|
|
~ExtendableEvent() {}
|
|
|
|
public:
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ExtendableEvent, Event)
|
|
NS_FORWARD_TO_EVENT
|
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
|
{
|
|
return mozilla::dom::ExtendableEventBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
static already_AddRefed<ExtendableEvent>
|
|
Constructor(mozilla::dom::EventTarget* aOwner,
|
|
const nsAString& aType,
|
|
const EventInit& aOptions)
|
|
{
|
|
nsRefPtr<ExtendableEvent> e = new ExtendableEvent(aOwner);
|
|
bool trusted = e->Init(aOwner);
|
|
e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
|
|
e->SetTrusted(trusted);
|
|
return e.forget();
|
|
}
|
|
|
|
static already_AddRefed<ExtendableEvent>
|
|
Constructor(const GlobalObject& aGlobal,
|
|
const nsAString& aType,
|
|
const EventInit& aOptions,
|
|
ErrorResult& aRv)
|
|
{
|
|
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports());
|
|
return Constructor(target, aType, aOptions);
|
|
}
|
|
|
|
void
|
|
WaitUntil(Promise& aPromise);
|
|
|
|
already_AddRefed<Promise>
|
|
GetPromise() const
|
|
{
|
|
nsRefPtr<Promise> p = mPromise;
|
|
return p.forget();
|
|
}
|
|
|
|
virtual ExtendableEvent* AsExtendableEvent() override
|
|
{
|
|
return this;
|
|
}
|
|
};
|
|
|
|
#ifndef MOZ_SIMPLEPUSH
|
|
|
|
class PushMessageData final : public nsISupports,
|
|
public nsWrapperCache
|
|
{
|
|
nsString mData;
|
|
|
|
public:
|
|
NS_DECL_ISUPPORTS
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
|
{
|
|
return mozilla::dom::PushMessageDataBinding_workers::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
nsISupports* GetParentObject() const {
|
|
return nullptr;
|
|
}
|
|
|
|
void Json(JSContext* cx, JS::MutableHandle<JSObject*> aRetval);
|
|
void Text(nsAString& aData);
|
|
void ArrayBuffer(JSContext* cx, JS::MutableHandle<JSObject*> aRetval);
|
|
mozilla::dom::Blob* Blob();
|
|
|
|
explicit PushMessageData(const nsAString& aData);
|
|
private:
|
|
~PushMessageData();
|
|
|
|
};
|
|
|
|
class PushEvent final : public ExtendableEvent
|
|
{
|
|
nsString mData;
|
|
nsMainThreadPtrHandle<ServiceWorker> mServiceWorker;
|
|
|
|
protected:
|
|
explicit PushEvent(mozilla::dom::EventTarget* aOwner);
|
|
~PushEvent() {}
|
|
|
|
public:
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
NS_FORWARD_TO_EVENT
|
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
|
{
|
|
return mozilla::dom::PushEventBinding_workers::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
static already_AddRefed<PushEvent>
|
|
Constructor(mozilla::dom::EventTarget* aOwner,
|
|
const nsAString& aType,
|
|
const PushEventInit& aOptions)
|
|
{
|
|
nsRefPtr<PushEvent> e = new PushEvent(aOwner);
|
|
bool trusted = e->Init(aOwner);
|
|
e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
|
|
e->SetTrusted(trusted);
|
|
if(aOptions.mData.WasPassed()){
|
|
e->mData = aOptions.mData.Value();
|
|
}
|
|
return e.forget();
|
|
}
|
|
|
|
static already_AddRefed<PushEvent>
|
|
Constructor(const GlobalObject& aGlobal,
|
|
const nsAString& aType,
|
|
const PushEventInit& aOptions,
|
|
ErrorResult& aRv)
|
|
{
|
|
nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
|
|
return Constructor(owner, aType, aOptions);
|
|
}
|
|
|
|
void PostInit(nsMainThreadPtrHandle<ServiceWorker>& aServiceWorker)
|
|
{
|
|
mServiceWorker = aServiceWorker;
|
|
}
|
|
|
|
already_AddRefed<PushMessageData> Data()
|
|
{
|
|
nsRefPtr<PushMessageData> data = new PushMessageData(mData);
|
|
return data.forget();
|
|
}
|
|
};
|
|
#endif /* ! MOZ_SIMPLEPUSH */
|
|
|
|
END_WORKERS_NAMESPACE
|
|
#endif /* mozilla_dom_workers_serviceworkerevents_h__ */
|